[Chicago-talk] scalar question
richard at rushlogistics.com
Tue Feb 1 15:26:56 PST 2011
Thank you everyone for all the great replies. This is what I ended up using.
---- Chicago.pm chatter <chicago-talk at pm.org> wrote:
> my $fl1 = '3321-1.pdf';
> my $root1;
> ($root1 = $fl1) =~ s/-.*//; # s/// only effects $root1 here
> - Brian
> On 2011-01-31 15:40, Richard Reina wrote:
> > I know I should no this, but I don't and was wondering if someone could enlighten me. I have some scalars that represent filenames and look like this
> > my $fl1=3321-1.pdf
> > my $fl2=3321-2.pdf
> > my $fl3=3432-1.pdf
> > I can get everything before the "-" like this:
> > $fl2=~s/\-.*//; # get the root of the filename
> > but how can I do it without changing the contents of the original scalar? I'd like to put the result directly in a new scalar.
> > $root_name= $f12=~s/\-.*//; # get the root of the filename
> > Thanks.
> Brian Katzung, Kappa Computer Solutions, LLC
> Leveraging UNIX, GNU/Linux, open source, and custom
> software solutions for business and beyond
> Phone: 877.367.8837 x1 http://www.kappacs.com
> Chicago-talk mailing list
> Chicago-talk at pm.org
Rush Logistics, Inc.
Watch our 3 minute movie:
More information about the Chicago-talk