At 04:03 PM 6/6/2001, you wrote:
>if (!$ARGV[0]) {
>      print "Enter the file\(s\) to search: ";
>      chomp(@files = <STDIN>);
>}
>print "*";
>@files = glob($ARGV[0]);

Your problem appears to be right here.  If the user didn't put the 
filenames on the command line, then you ask them for them.  Then you come 
down and glob the command line argument anyway, clobbering whatever was in 
@files, which, BTW, isn't what you want.  You might want to try this

<perl>
unless ($ARGV[0]) {
     print "Enter the file(s) to search: ";
     chomp($ARGV[0] = <STDIN>);
}

@files = glob $ARGV[0];
</perl>

This way you see if there's something in $ARGV[0], and if not, you read it 
in and put it there.  Then you go ahead and glob the file spec, regardless 
of where it came from.

Just as a note, sometimes the glob operator looks like <>, but in this case 
you weren't globbing the input, you were reading in a line of input, and 
that's all the <STDIN> will do.  You would have to glob all the file names 
out in a separate step, like you did outside of the until/if ! structure.

Later,

Sean.

Reply via email to