Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

help me please

by Anonymous Monk
on Apr 12, 2002 at 05:47 UTC ( #158492=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

My lecturers in their infinite wisdom have decided to leave out of the textbook how to use command-line options... I need to do the following: specify a file on the command-line to open and use in the script... if anybody can help me, my e-mail is jmarino@cs.rmit.edu.au thanx in advance

Comment on help me please
Re: help me please
by Anonymous Monk on Apr 12, 2002 at 05:49 UTC
    it's me again... it seems like my e-mail is on the blink... just post it here... James
Re: help me please
by BUU (Prior) on Apr 12, 2002 at 06:12 UTC
    /me hopes hes not violating any monastery standards.. everything on the command line is automagically placed into the @argv array, split on spaces. moreoever, the diamond operator automagicaly reads from the first arguement in the argv array (or something like that.. go look it up)

      That would actually be the @ARGV array.

      #!/usr/bin/perl -w use strict; my $filename= shift @ARGV; ....

      As BUU mentionned <> works automagically: you can call the following script with perl test.pl my_file

      #!/usr/bin/perl -w use strict; while( <>) { # reads from my_file ... }
Re: help me please
by cjf (Parson) on Apr 12, 2002 at 06:22 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://158492]
Approved by jlk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-11-26 05:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (162 votes), past polls