split is one way<br><br>But if you prefer regex:<br>my $fl1=&quot;3321-1.pdf&quot;;<br>my ($pref,$suff,$ext) = ($fl1 =~ m/(\w+)-(\w+)\.(\w+)/);<br><br>-imran<br><br><div class="gmail_quote">On Mon, Jan 31, 2011 at 3:40 PM, Richard Reina <span dir="ltr">&lt;<a href="mailto:richard@rushlogistics.com">richard@rushlogistics.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I know I should no this, but I don&#39;t and was wondering if someone could enlighten me.  I have some scalars that represent filenames and look like this<br>

<br>
my $fl1=3321-1.pdf<br>
my $fl2=3321-2.pdf<br>
my $fl3=3432-1.pdf<br>
<br>
I can get everything before the &quot;-&quot; like this:<br>
$fl2=~s/\-.*//; # get the root of the filename<br>
<br>
but how can I do it without changing the contents of the original scalar? I&#39;d like to put the result directly in a new scalar.<br>
<br>
$root_name= $f12=~s/\-.*//; # get the root of the filename<br>
<br>
Thanks.<br>
--<br>
Richard Reina<br>
Rush Logistics, Inc.<br>
Watch our 3 minute movie:<br>
<a href="http://www.rushlogistics.com/movie" target="_blank">http://www.rushlogistics.com/movie</a><br>
<br>
_______________________________________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/chicago-talk" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a><br>
</blockquote></div><br>