ubergoonz wrote:
> Hi,

Hello,

> I have a certain variables of emplyee number which comes in the format of
> [a0000000]  or [u0000000] {whereby 0000000 is some serial numbers}.
> 
> I would like to remove the enclosed [ & ]  see if it is belong to class
> a or
> u , i can do it as follow
> 
> $var = /\[//; $var = /\]//;
> if ($var =~ '^a) {
>   print "$var is class A";
> } elsfi ($var =~ '^u) {
>   print '$var is class U";
> }
> $var = /a//; $var = /u//;
> 
> How can i remove the chars all in a single line? and write the code in a
> more perl manner ?

You could do something like:

my ( $class, $ser_no ) = $var =~ /\[([au])(\d+)]/;

print "$ser_no is class \u$class\n";




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