Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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 thanx in advance

Replies are listed 'Best First'.
Re: help me please
by cjf (Parson) on Apr 12, 2002 at 06:22 UTC
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 my_file

      #!/usr/bin/perl -w use strict; while( <>) { # reads from my_file ... }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://158492]
Approved by jlk
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2018-06-22 16:11 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.