What's wrong with this program?

Discussion in 'Perl Misc' started by Leon, Jan 5, 2005.

  1. Leon

    Leon Guest

    #!/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.
    Leon, Jan 5, 2005
    #1
    1. Advertising

  2. Leon

    Uri Guttman Guest

    >>>>> "L" == Leon <> writes:

    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

    --
    Uri Guttman ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Jan 5, 2005
    #2
    1. Advertising

  3. Leon

    Tom Regner Guest

    Leon wrote:

    > #!/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
    Tom Regner, Jan 5, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VisionSet

    what's wrong in this program

    VisionSet, Sep 24, 2004, in forum: Java
    Replies:
    12
    Views:
    533
    Thomas G. Marshall
    Sep 28, 2004
  2. Replies:
    7
    Views:
    407
  3. Matthew
    Replies:
    7
    Views:
    651
    Priscilla Walmsley
    Jan 7, 2005
  4. jose luis fernandez diaz

    why this program is wrong on Tru64 OS ?

    jose luis fernandez diaz, Nov 25, 2003, in forum: C++
    Replies:
    2
    Views:
    406
    Stephan Br?nnimann
    Nov 26, 2003
  5. Replies:
    5
    Views:
    1,580
Loading...

Share This Page