Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Crackers2 (Parson)
on Oct 06, 2015 at 18:07 UTC ( #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.

  • Comment on Re^2: Typo or on purpose? Variable instantiation with string concatenation operator
  • Download Code

Replies are listed 'Best First'.
Re^3: Typo or on purpose? Variable instantiation with string concatenation operator
by ikegami (Pope) 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
Node Status?
node history
Node Type: note [id://1143959]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2020-10-22 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (225 votes). Check out past polls.

    Notices?