Bill Jastram wrote:
>
> When I use the following portion of Perl code:
> __________________________________________________
>
> #!/usr/bin/perl
> # use with:
> # perl IfThenElse tfcfam (Use all of this at the command line!)
>
> use strict;
> use warnings;
>
> print "Search by name: ";
>
> my $name = <STDIN>;
> 'egrep $name testing.txt'
>
> #my(@col1, @col2, @col3);
> my @col1;
> my @col2;
> my @col3;
> my $col = 1;
> my ($find);
>
> __________________________________________________
>
> I get the following error:
>
> syntax error at trashthistest2 line 17, near "my "
> Global symbol "@col1" requires explicit package name at trashthistest2 line 17.
> Global symbol"@col1" requires explicit package name at trashthistest2 line 40.
> Global symbol "@col1" requires explicit package name at trashthistest2 line 53.
> Global symbol "@col1" requires explicit package name at trashthistest2 line 59.
> Global symbol "@col1" requires explicit package name at trashthistest2 line 81.
> Execution of trashthistest2 aborted due to compilation errors.
>
> __________________________________________________
>
> If I have declared my @col1 at line 17, why am I getting these errors?

Hi Bill.

Your code isn't the most maintainable I've seen (your line 17 is the 14th in
the code you showed) but what's the stray string

> 'egrep $name testing.txt'

doing at 'line 14'? Slap a semicolon after it and it will compile, but then
you've just shelled out, run 'egrep' and thrown the results away.

May I also make a preemptive strike and say that you seem to be writing a
shell script in Perl. Almost all backticks or 'system' calls are a bad idea:
Perl usually knows how to do it better than you do, so code it in Perl.

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to