chinamox has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Brothers,

I am finishing up some class work and I wanted to check if I was on the right path or not...

I want to use Getopt::Long to load different data sets into the program I just finished writing. I need to be able to load the files paths in the following forms:

./plc.pl < /myflies/lib/words ./plc.pl /myfiles/lib/words cat /home/programs/perl/myfiles/lib/words | ./plc.pl

My other option is to investigate using something like this:

#!/opt/bin/perl -w # #usage: ./plc.pl url # use strict; my ($url) =@ARGV; while(my $scalar = <>){ #### Main Program here #### }

So am I on the right track with either of these or are they both just a newbee barking up the wrong trees?

As always, thank you in advanced for your guidence and patience.


-mox

Replies are listed 'Best First'.
Re: Using Getopt::Long it input different data sets
by Hofmator (Curate) on Oct 10, 2006 at 13:20 UTC
    The simple while (<>) {} was designed for this case. If you have no command line arguments, this reads from STDIN, otherwise treats all arguments in @ARGV as filenames, tries opening them and reads from all of them sequentially. See perldoc perlop under I/O Operators.

    -- Hofmator

    Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      Thank you very much for your clairification. I am going back over perlop again right now...

A reply falls below the community's threshold of quality. You may see it by logging in.