[Chicago-talk] scalar manipulation
Richard Reina
richard at rushlogistics.com
Fri Mar 31 13:07:09 PST 2006
Thank you very much Andy and Steve for the instructive replies. Have a great weekend all.
Richard
Steven Lembark <lembark at wrkhors.com> wrote:
> I need to turn
>
> $a = "now is a good time for a beer";
>
> to
>
> "nowisagoodtimeforabeer";
Depends on whether you want to modify the original
variable or not. You can remove anything with a
regex on the original:
$phrase =~ s{ \s+ }{}gx;
will modify $phrase in place. You can also use a
regex on a copy or a join-and-split to make a new
copy of the variable:
( my $nospace = $phrase ) =~ s{ \s+ }{}gx;
or
my $nospace = join '', split '', $phrase;
will give you a separate variable without the spaces.
--
Steven Lembark 85-09 90th Street
Workhorse Computing Woodhaven, NY 11421
lembark at wrkhors.com +1 888 359 3508
_______________________________________________
Chicago-talk mailing list
Chicago-talk at pm.org
http://mail.pm.org/mailman/listinfo/chicago-talk
A people that values its privileges above its principles soon loses both.
-Dwight D. Eisenhower.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/chicago-talk/attachments/20060331/880a5c1a/attachment.html
More information about the Chicago-talk
mailing list