in reply to replace @ARGV args with Getopt::Long switches

if i'm reading this correctly, you're trying to use Getopt::Long to process your file for you, which it won't do.

you still need to read the file into the script:

untested

open ( FILE, $file{in} ) or die "can't open it:$!\n"; my @targets = < FILE >; close FILE; foreach my $target ( @targets ) { #### processing }

should do the trick

Replies are listed 'Best First'.
Re:(2) replace @ARGV args with Getopt::Long switches (graci)
by ybiC (Prior) on Apr 12, 2001 at 02:39 UTC
    Thanks, geektron - that was it!   Well, that or I forgot to use Do::WhatImean   ;^)

    Here's what ended up working:

    use Getopt::Long; GetOptions( 'infile|i=s' => \$opt_infile, ); if (defined $opt_infile) { $file{in} = $opt_infile; open (INFILE, "< $file{in}") or die "Error opening $file{in}: $!"; @targets = <INFILE>; close INFILE or die "Error closing $file{in}: $!"; } else { die "Input file not specified!"; } foreach my $nonsane(@targets) { chomp $nonsane; unless ($nonsane =~ (/^(\w|-|\.)+$/)) { print " $nonsane is an improperly formatted device name.\n"; print " Only alphanumeric, underscore, dash and dot allowed.\ +n"; print " Edit $file{in} to remove puctuation, blank lines and/ +or blank spaces.\n"; exit; } }

        cheers,
        Don
        striving toward Perl Adept
        (it's pronounced "why-bick")
      Minor point, ybiC and no mua-hahaha this time.

      Getopt::Long accepts all unique abreviations to the option, so you don't need to specify your synonym. See Getopt::Long for details, but these should work with 'infile=s'=>\$foo, 'bear=i'=>\$bar...:

      script.pl --infile Myfile -bear 666 script.pl -i Myfile -b 5
      Hope this helps,

      Jeroen
      "We are not alone"(FZ)