Perl with Sublime Text 2: <STDIN> not working

一个人想着一个人 提交于 2019-12-04 17:36:52
DVK

According to this - very similar - Python question: " Sublime Text 2 console input " - Sublime Text doesn't support STDIN input. Confirmed here as well.

You can solve this one of 2 ways:

  1. Run your program outside of Sublime, in shell. On Windows, simply save your Perl script as c:\your_directory\your_subdir\your_perl_script.pl ; open the command interpreter ("Start"=>"Run"=>"cmd.exe") and on c:\ prompt in the interpreter, run:

    c:\your_directory\your_subdir\your_perl_script.pl
    

    or if you didn't associate .pl extension with Perl when you installed Perl,

    perl c:\your_directory\your_subdir\your_perl_script.pl
    
  2. Follow the linked SO question's answer and use SublimeREPL

  3. Use the Terminal plugin

Remember to add an "<>;" at the last line of your perl code.

And then: tools->build new system->

{
    "cmd": ["perl","$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.perl",
    "variants":
    [
        {
            "name": "RunInCommand",
            "shell": true,
            "cmd": ["start", "perl","${file_base_name}.pl"]
        }
    ]
}

Now, if you want to run your perl code using a shortcut key, such as "F5", you can add one: preferences->key buildings-user->

[
    {"keys": ["f5"], "command": "build", "args": {"variant": "RunInCommand"}}
]

Enjoy programming.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!