Amit Virmani wrote:
> 
> Problem:
> I have a field $cusip that has to change from ABC123-XX-7 (9 characters with '-') to 
> ABC123XX (first 8 characters only without '-')
> 
> I have following lines of code:
> :
> :
> $cusip =~ s/\-//g;
> $cusip =~/.${8}$/$1/g;
> :
> :
> 
> Is there a shorter way to transform this.

No, not really.  You can do it in one line though:

$cusip = join '', ( $cusip =~ /[^-]/g )[ 0 .. 7 ];


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to