Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Variable Scoping in Perl: the basics

by aristotle73 (Sexton)
on Dec 20, 2004 at 19:09 UTC ( #416283=note: print w/replies, xml ) Need Help??


in reply to Variable Scoping in Perl: the basics

print "$Robert has canned $name's sorry butt\n"; I tried running this in PERL and it yelled at me saying that it didn't like $name::s. I changed this line of code to: print "$Robert has canned $name sorry butt\n"; And it worked fine 0_o An error in the tutorial perhaps?
  • Comment on Re: Variable Scoping in Perl: the basics

Replies are listed 'Best First'.
Re^2: Variable Scoping in Perl: the basics
by Aristotle (Chancellor) on Dec 24, 2004 at 01:50 UTC

    Try

    print "$Robert has canned ${name}'s sorry butt\n";

    The apostrophe is the old-style package separator, still supported, so $name's is indeed equivalent to $name::s. By putting the curlies in there, you tell Perl exactly which part of the string to consider part of the variable name, and which part to consider a literal value.

    Makeshifts last the longest.

      Thanks :D It works ^_^

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://416283]
help
Chatterbox?
[stevieb]: use metamod::DateTime. Don't fsck around. Seriously. As someone who's done sensitive date/time stuff, don't roll your own. Use what is available and known stable. Do not guess.
[stevieb]: Date::Time even
[stevieb]: ffs I can't make DateTime link properly, so there.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2017-04-29 04:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.