Getting Perl to Work

Started by
4 comments, last by WheelsRCool 17 years, 9 months ago
Hey, I am trying to get Perl to work on my computer so I can start practising with that some. I downloaded Perl from ActiveState.com; I downloaded the ActivePerl MSI version for Windows XP. After installing it, I went into Wordpad and typed out the following: #!/usr/local/bin/perl print "Hi there!\n"; Then I saved it into a file named first.pl. Then I went into the command prompt, went to the directory containing the little program, then I typed, perl first.pl . Well a whole bunch of lines came up, saying the following: Backlash found where operator expected at first.pl line 1, near "rtf1\" Backlash found where operator expected at first.pl line 1, near "ansi\" Backlash found where operator expected at first.pl line 1, near "ansicpg1252\" Backlash found where operator expected at first.pl line 1, near "deff0\" Backlash found where operator expected at first.pl line 1, near "f0\" Backlash found where operator expected at first.pl line 1, near "froman\" Backlash found where operator expected at first.pl line 1, near "f1\" Backlash found where operator expected at first.pl line 1, near "fswiss\" syntax error at first.pl line 1, near "rtf1\" syntax error at first.pl line 1, near "f1\" syntax error at first.pl line 1, near "}}" Execution of first.pl aborted due to compilation errors I have read that the line #!/usr/local/bin/perl is standard for all perl programs, but I also read it can vary system to system, now I'm confused. What am I doing wrong here? Thanks, ---Wheels---
Advertisement
/usr/bin/perl is a Unix-style directory. I've never used Perl, but you could try replacing that line with a Windows directory such as #!C:\Program Files\perl. Check your Perl documentation for more information.
------------------------------Support the Blue Skies in Games Campaign!A blog... of sorts.As a general rule, if you don't have a general rule in your signature, you aren't as awesome as someone who does. General rules roxor teh big one one ones.
The first line just gives the location of the perl interpreter. "/usr/local/bin/perl" is the standard unix directory where perl lives. Since your'e on windows, it will probably be:

#!C:/perl
Argh, it still doesn't wanna work.

For the source code of a test program that came with it, the top is like this:

#! ./perl

and it executes from the cmd prompt.

The code for a .pl file called "Example" consists solely of a print line and when I go into the directory and execute it, it works fine. I copy-pasted that same line into my program file, saved it, tried to execute it from the proper directory, and still no go.
Quote:Original post by WheelsRCool
Backlash found where operator expected at first.pl line 1, near "rtf1\"


You saved your code as RTF. Try plain text. :)


Quote:
I have read that the line #!/usr/local/bin/perl is standard for all perl programs, but I also read it can vary system to system, now I'm confused.


AFAIK The Perl interpreter should ignore the shebang (the #!... line) on Windows. You'll have to call the interpreter yourself (as in 'perl foo.pl') or to associate the extension with the Perl interpreter. In either case, the shell doesn't have to determine the eventual interpreter.


Hope this helps.
:) Yay, it works now. I was saving it in Wordpad, so then I just went to Notepad and saved it and it worked :)

Thanks;

This topic is closed to new replies.

Advertisement