Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Perl Context - concatenation operator

by shmem (Chancellor)
on Dec 21, 2006 at 14:21 UTC ( [id://591111]=note: print w/replies, xml ) Need Help??


in reply to Perl Context - concatenation operator

As chargrill<update>, Herkum and BrowserUK</update> says, a bunch of numbers with more than one dot in between don't evaluate to what you expected. That could also be a packed IP address (see gethostbyname):
perl -le '$lo = 127.0.0.1; $l = (gethostbyname("localhost"))[4];print +"yup" if $lo eq $l' yup

Anyways, it's a packed structure of bytes. To get back what you expected, use the %v format directive of sprintf:

perl -le 'printf "%vd\n", (gethostbyname("localhost"))[4]' 127.0.0.1

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://591111]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found