LA.pm: Regex

David Pisoni david at cnation.com
Fri Oct 19 19:17:36 CDT 2001


Methinks the && construction will short circuit (read, not print anything) if $x->{'Foo'} has no whitespace at all.  IMHO your original advice is best -- do the substitution first.

Enjoy,
David

At 15.55 -0700 10/19/2001, Samy Kamkar [CommPort5] wrote:
>If I were you, I'd just do it in seperate functions...here's a way, but there may be better ways (although best way is to just to first s/// then do the print :)
>
>print join(", ", "foo", ($x->{'Foo'} =~ s/\s+//g) && $x->{'Foo'}, "bar\n");
>
>Arkadiy Sudarikov wrote:
>
>>Call me dumb mofo, but... I still don't get it...
>>
>>I mean, I have this string in hash ref, accessible as $hashref->{'Foo'}.
>>That string contains, like, numbers and spaces.
>>
>>Now, I need to do print join ', ', 'foo', $hashref->{'Foo'}, 'bar'; but I
>>need to strip spaces from $hashref->{'Foo'}. So, how can I do my s/\s+//g
>>within this context, on the same line? Something like print join ', ',
>>'foo', $hashref->{'Foo'}=~ s/\s+//g, 'bar';
>>
>>Thanks for help,
>>Private Arkadiy
>>
>
>--
>Samy Kamkar -- (877) 898-1424 -- cp5 at LucidX.com
>LucidX.com / LA.pm.org / pdump.org / code.LucidX.com




More information about the Losangeles-pm mailing list