LoginSignup
0
0

More than 3 years have passed since last update.

PerlのAtCoder向けVSCode設定(tasks.json)

Last updated at Posted at 2020-02-16

はじめに

競技プログラミングには、タイムトライアル要素もあります。
そこで、ワンタッチでプログラム実行できるセッティングを行いました。

Perl の実行コマンド

AtCoderのPerl実行コマンドは、次の通りです。

    Perl -X Main.pl

これをローカルで毎回実行しないといけないわけです。

tasks.jsonの設定

tasks.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "perl",
            "type": "shell",
            "command": "perl",
            "args": [
                "-X",
                "${workspaceFolder}/main.pl"
            ],
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": true,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": true
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

tasks.jsonを設定しますと、

Ctrl + Shift +B

で設定したコマンドが実行されます。

簡単な補足

  • "command": "perl" perl.exeへのパスが通っていない場合はフルパスを設定
  • "args": [ "-X", "${workspaceFolder}/main.pl" ] ファイルを開くではなく、フォルダーを開くを使用した場合、ソースへのパスを上手いことやってくれる
  • "presentation": { "reveal": "always", "focus": true, ターミナルを開きフォーカスを当てるので、データの入力が簡単

実行例

ABC 086 A - Product

> Executing task: perl -X C:\Users\user\Documents\atcoder\abc086a\main.pl <

3 4
Even

文法誤りの場合

> Executing task: perl -X C:\Users\user\Documents\atcoder\abc086a\main.pl <

syntax error at C:\Users\user\Documents\atcoder\abc086a\main.pl line 
13, near "print"
Execution of C:\Users\user\Documents\atcoder\abc086a\main.pl aborted 
due to compilation errors.
ターミナルの処理が終了しました (終了コード: 255)

まとめ

  • 本来はビルドタスク プログラマーには、三つの美徳が絶対に必要です
  • Thanks Larry.
  • Perlに限らずほかの言語にも応用可能です
  • 競プロ、頑張りましょう

参照したサイト
VSCodeのタスク機能でRails Serverをコマンド一発で起動する

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0