I'm new to Perl programming and I actually posted this question in another forum, but later found out that forum barely had any visitors and thus my question was never really answered. So I'm posting this here hoping someone can help me out
Unfortunately SitePoint hasn't mentioned Perl in like 10 years. I don't know why they have this forum : (
Is Beginning Perl the Apress book? Or Pakt Press? Black and orange/yellow? I remember seeing one like that in the bookstore but I didn't recognise the author name. Or is it the Simon Cozens book? That one is getting a bit old and I don't know if he's updated anything. Hopefully you are starting your Perl career with at least 5.8.x if not higher.
Anyway I would say so long as you know how to make directories in Windows (I have no clue, it's all so much easier in Unix/Linux), do it that way. I don't know DOS except from some barely-remembered time back in my childhood, and I seem to vaguely remember that it was "dir" instead of "mkdir" there... ?
did it this way because this was an exercise from the book I'm learning from (Beginning Perl, 3rd Edition) - this is how the book instructed me to do so. Second, my book then asks me to pop open cmd and create two directories through the cmd (I'm using Windows Vista; 64).
One directory as c:> mkdir begperl
second directory as c:> cd begperl
If that were bash, you're not making a second directory: you're first creating a directory (make directory called "begperl") and then you go to that directory with cd begperl (change directory (to) "begperl"). You should have a single file which initially contains nothing (though I would think it does have some (small) filesize... on my system empty dirs are 4 kb).
My book then asks me to go to cmd again, and type this statement in: $ perl helloworld.pl (it's the file I saved before) - the book tells me that it should produce the phrase "Hello World!" however the command prompt tells me that $ is an unknown character.
$ typically isn't something you type in, but in code examples it's there to show your "command prompt", and $ is typical for non-root users in many Linux systems (it may be something else if you are root like #). But I have no clue what the"command prompt" is in Windows. I don't believe you were meant to type the $.
Was this book written assuming a unix environment or bash?
On my machine (Linux), after I save the perl file, I can manually make it an executable, and then I don't have to use the command "perl" to run them: I can just
and it runs (again I'm not typing the $ there). If I don't, I need to use the "perl" command and also the path if I'm not in my Perl folder.
If I'm at /home/mallory and perl scripts are at /home/mallory/perlstuff
then I would need to
$ perl perlstuff/perlscript.pl
to run it. But that's Linux.
So you are running Strawberry Perl? While I hear that's the more awesome/working way to use Perl on Windows, I can't imagine Perl and Windows being a nice match. Seems like it would be harder to learn, especially if the book is writing commands for bash instead of whatever's on Windows.
Also if you are in Windows are you supposed to start with #!/usr/bin/perl? My perl is definitely there but Windows doesn't use that kind of file system. Or is Windows just ignoring that?
"Unable to initialize device PRN" <-- something to do with Windows thinking this Perl file is a "print" file. Or anyway, it's an error Windows gives people when they are doing printing and trying to "print" stuff.
The problem with -e is you have to escape stuff like quotes everywhere as opposed to inside a full perl file. You definitely don't want to have to do that. You should be able to call a saved file as an executable.
Hm... yeah the fact that you can run this immediately with the -e argument but not as an executable is probably because of your shebang line... that is supposed to tell your OS where "perl" (the interpretor itself) is. Yours can't be there unless you're running Cygwin (and I'm not totally sure how that works with Cygwin anyway).
Besides the irc channel at Strawberry Perl (irc://irc.perl.org/win32), your best place for answers will probably be Perlmonks. There are a good number of people there using Strawberry Perl.
*edit I re-read and see you're on 64-bit Windows, so I dunno where to get 64-bit SP help other than PerlMonks