Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Global symbol "$buidTarget" requires explicit package name

by Anonymous Monk
on May 13, 2020 at 15:16 UTC ( [id://11116758]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am getting following error while running the script even though i have used my before $buildTarget, Global symbol "$buidTarget" requires explicit package name at ./fileTest.pl line 10. Execution of ./fileTest.pl aborted due to compilation errors.

1 #!/grid/common/bin/perl 2 3 use strict; 4 use warnings; 5 6 7 8 9 my $buildTarget = "/home/abc/depot"; 10 if ( -s -x "$buildTarget/abc.txt" && -s -x "$buidTarget/def.txt" ) + { 11 print "test passed"; 12 } 13 else { 14 print "test failed"; 15 } 16

Replies are listed 'Best First'.
Re: Global symbol "$buidTarget" requires explicit package name
by hippo (Bishop) on May 13, 2020 at 15:21 UTC

    That's because you have mis-spelled $buildTarget by omitting the letter l. Using strict has saved your bacon.

      Don't feel bad because even those of us who've been doing this for ages will still occasionally sit there and blank out despite the error message explicitly telling what's wrong. It's only obvious after you've bothered to show it to someone else. And you read it again. And then sit down and actually read it. And then there's the "Derp."

      If you ever have a debugging problem like this where you're not seeing the problem, go walk off for 5-10 minutes and do something unrelated. When you come back and look at it fresh it can help.

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

        Back in the '80s when I was using IBM BASICA, I got stuck for three weeks because I typed

        F0R X = 1 TO MAX

        at the start of a very long line with multiple statements, instead of

        FOR X = 1 TO MAX

        I do not know when syntax highlighting was invented but it's great stuff.

      thank you!

Re: Global symbol "$buidTarget" requires explicit package name
by karlgoethebier (Abbot) on May 13, 2020 at 21:29 UTC

    Shit happens and #MeToo. As already mentioned. My very best error was when I typed use Net::SNMP instead of use Net::SMTP many years ago and wondered why the stuff I programmed didn’t work. I wrote an email to the author and received a very friendly reply. You may also consider Pair Programming 🤪😎🦆 Best regards

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

      This gives me an idea for a perl critic policy that warns against declaring package names, subroutine names, variable names, or even hash keys that are prone to misspellings. Wondering what metrics should I use.

        I happened upon this list of common misspellings just the other day. Not convinced that many of them would turn up frequently in code anyway, but it might be one place to start. Maybe different policies for different (natural) languages would be easiest?

        ... metrics ...

        Anything that's spelled. That's what I usually mispel. :)


        Give a man a fish:  <%-{-{-{-<

        I’m dreaming since years about something like this: use Acme::LapsusLinguae;. If I wrote use Cuke; but meant use Nose; I would get an compile time error with some in-depth explanation.

        «The Crux of the Biscuit is the Apostrophe»

        perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

        Maybe a policy that prohibits variables within a given minimum Levenshtein distance? That might work regardless of language.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11116758]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-23 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found