Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Typo or on purpose? Variable instantiation with string concatenation operator

by Crackers2 (Parson)
on Oct 06, 2015 at 18:07 UTC ( [id://1143959]=note: print w/replies, xml ) Need Help??


in reply to Re: Typo or on purpose? Variable instantiation with string concatenation operator
in thread Typo or on purpose? Variable instantiation with string concatenation operator

Not relevant for this specific case, but there is a difference if the thing being appended is a number:
$ perl -e'use Devel::Peek; my $x = 5; Dump($x) ; my $y .= 5; Dump($y); +' SV = IV(0x2fc84) at 0x2fc88 REFCNT = 1 FLAGS = (PADMY,IOK,pIOK) IV = 5 SV = PV(0x13838) at 0x2fcd8 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0x2ac18 "5"\0 CUR = 1 LEN = 12

i.e. .= will stringify on assigment.

Replies are listed 'Best First'.
Re^3: Typo or on purpose? Variable instantiation with string concatenation operator
by ikegami (Patriarch) on Oct 07, 2015 at 19:37 UTC
    Good point. I'd use the following if I wanted to force stringification:
    my $str1 = "".$self->sanitizeString($input1);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-29 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found