Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing Perl script inside IntelliJ Idea

I'm trying to use IntelliJ Idea to work on a perl script. I installed the perl plugin for IDEA as well as Strawberry Perl for Windows (10).

The syntax highlighting and other features work, but this is what happens when I try to run the program:

Running the Program

I'm a beginner at perl, so I'm still just using command line stuff and ASCII graphics. I was hoping to simply run, test, and debug my perl programs in IntelliJ, but the print statement isn't putting anything in this dialog when perl runs...

I can still type stuff in the above image where the cursor is, and typing the wrong stuff can throw errors as it is supposed to. So <STDIN> seems to be properly mapped, but <STDOUT> is not? Or is something else wrong?

If I copy the command that it shows it is running to cmd, it works perfectly:

Mancala working

So is there a way to configure intellij to get <STDOUT> in this dialog? Any help would be appreciated.


Now, following Chankey's answer, I've made a test script, and that one works:

Test.pl working

Maybe the problem is that I imported the perl file from an external source, and IntelliJ doesn't realize it is a script, or something like that? But if I copy the code into the new file, it doesn't work either...

The test.pl had one difference: use warnings FATAL => 'all'; instead of use warnings;. When I try this, it works until I type a string where numeric input is expected, and then prints a whole bunch of what it should have been printing all along as it quits the program:

Some of the output shown now

Again, the output works fine in cmd, so I think this is an issue with IntelliJ. Any ideas? Maybe the @ symbols are creating issues? Something else? If anyone uses IDEA for windows and wants to toy around with my code, it's available on github.

like image 931
Menasheh Avatar asked Oct 06 '16 04:10

Menasheh


People also ask

Does Intellij support Perl?

This plugin provides Perl5 & Pod support. Basic functionality may be extended with additional plugins: Languages and Frameworks: Mojolicious.


1 Answers

Works fine for me. Below are the steps:

  1. Create a project
  2. Right click on project and select New, then select Perl5 file
  3. Give a name to file and select Script from dropdown
  4. Write your script, save it
  5. Press CTRL+SHIFT+F10
  6. Provide some data as user input then press Enter

Output:

enter image description here

If it still does not work for you then perhaps you have not setup your Perl properly.

Go to File->Project Structure and add perl to Project SDK.

enter image description here

As per your screenshot I can see that you are using absolute path for perl.exe. That means you have not added perl to your PATH. That seems to be the issue why IntelliJ is not finding it to execute your script.

Do

set PATH=C:\Strawberry\perl\bin;%PATH%

If that also doesn't fix the issue for you then go through the wiki page of Camelcade plugin. Author has provided step by step instructions there on how to setup this plugin.

like image 128
Chankey Pathak Avatar answered Sep 19 '22 06:09

Chankey Pathak