Hi Xavier Noria, Vidal(GURU), Christopher, SOLCM(GURU)
Many Thanks for you help 

I will go thru it and let you know spare me some time

rgds
Venkat

-----Original Message-----
From: Xavier Noria [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 9 August 2005 3:56 PM
To: Perl Beginners List
Cc: Vidal, Christopher, SOLCM; Vema Venkata
Subject: Re: revert to me asap


On Aug 9, 2005, at 6:20, Vema Venkata wrote:


> sub get_work_station_id {
>     # return W0010A40C06D0 from vbop-0x4E580000:W0010A40C06D0:windows
>     my $id = shift;
>     return $1 if $id =~ /:([^:]+):/;
>     return;
> }
>

[snip]


> Can you help me how to get with prefixed letter respectively
>

Change the body of the subroutine with:

     my $id = shift;
     my ($machine, $prefix) = $id =~ /:(([^:])[^:]*):/;
     return $machine, $prefix;

and use it like this:

     my ($machine, $prefix) = get_work_station_id($id);
     if (defined $machine && defined $prefix) {
         # process them
     }

The regexp above is not very readable, maybe this would be enough:

     my ($machine, $prefix) = $id =~ /:((.).*?):/;

or this

     my ($machine, $prefix) = $id =~ /:((\w)\w*):/;

-- fxn



--
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