What's wrong with this program?

L

Leon

#!/usr/bin/perl
use File::Find;

find(\&d, @ARGV);
sub d{
my $file=$File::Find::name;
$file =~ tr/A-Z/a-z/g;
print $file, "\n";
}

The error message is:
Bareword found where operator expected at re.sh line 7, near
"tr/A-Z/a-z/g"
syntax error at re.sh line 7, near "tr/A-Z/a-z/g"
Execution of re.sh aborted due to compilation errors.
What's wrong with this program?
Thanks a lot.
 
U

Uri Guttman

L> #!/usr/bin/perl
L> use File::Find;

L> find(\&d, @ARGV);
L> sub d{
L> my $file=$File::Find::name;
L> $file =~ tr/A-Z/a-z/g;
^
L> print $file, "\n";
L> }

L> The error message is:
L> Bareword found where operator expected at re.sh line 7, near
L> "tr/A-Z/a-z/g"
L> syntax error at re.sh line 7, near "tr/A-Z/a-z/g"

tr IS NOT a regex nor is it s///. it has its own modifiers.

perldoc -f tr

uri
 
T

Tom Regner

Leon said:
#!/usr/bin/perl
use File::Find;

find(\&d, @ARGV);
sub d{
my $file=$File::Find::name;
$file =~ tr/A-Z/a-z/g;
print $file, "\n";
}
read perldoc perlop again, and then take out the not existing g modifier :)

regards,
tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top