Bill Akins wrote: > > Hello all, Hello,
> I have a var, $DOC_NAME, holding a file name. I need to get the first > part of the variable into another variable. Some examples are > A98-12345, SO-02-789, P-99-029833 and GQE-37-2199. > > Examples: > A98-12345, I need A98 > SO-02-789, I need SO-02 > P-99-029833 I need P-99 > GQE-37-2199 I need GQE-37 > > I know if it were always the first X that I needed I could do this: > $SUBDIR = (substr ($DOC_NAME, 0, X)); > Really, I need everything until I get 2 digits in the new var. Anyone > want to take a stab at this? $ perl -le' for my $DOC_NAME ( qw/A98-12345 SO-02-789 P-99-029833 GQE-37-2199/ ) { my ($SUBDIR) = $DOC_NAME =~ /(.*)-/; print $SUBDIR; } ' A98 SO-02 P-99 GQE-37 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]