[Chicago-talk] scalar manipulation

tiger peng tigerpeng2001 at yahoo.com
Fri Mar 31 15:12:37 PST 2006


Hi Perlists,

I don't think it is good to mess up the "good time for
beer" when it is Friday )-:

I am wandering if Perl can turn beer to champagne,
wine, brandy, or even vodka.

Bottoms up! 
Have a great weendend,

Ge

--- Richard Reina <richard at rushlogistics.com> wrote:

> 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.>
_______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk



More information about the Chicago-talk mailing list