I have written a small script in Perl which I am executing on Windows with ActivePerl as below:
C:\Documents and Settings\Administrator> perl io.pl io.pl
#!/usr/bin/perl
use warnings;
sub test6 {
while (defined($_ = <>)) {
#chomp($_);
print $_;
}
}
test6;
As you can see, the code is similar to the Unix cat command:
C:\Documents and Settings\Administrator> perl io.pl io.pl
If I want to execute this script without the perl keyword on the command line, what needs to be done? I want the script to be executed as:
C:\Documents and Settings\Administrator> ./io.pl io.pl
The .pl extension needs to be associated with the Perl interpreter, for one thing. This is easily done by trying to open the script from Windows Explorer — when you’re asked what program to use to open it, browse to perl.exe. And make sure the “always use this program…” box is checked.
Windows likes to check the current directory first, so you don’t need to have the “./” in there.