Derek B. Smith am Dienstag, 12. Dezember 2006 23:19:
> I have a string like so:
>
> /home/dbsmith/passwd.oftappp1.hpux and I need to parse
> out oftappp1 and hpux.
>
> I have tried to use substr and and regexp with =~.
> Here is what I have tried, but need some help cause I
> am getting frustrated.
>
> NOTE: strings after passwd are variable in length,
> could be 3-10 characters long.
>
> use strict;
> use warnings;
> my $string = qw(/home/dbsmith/passwd.dubhpr01.sun);
> #my ($host_name) = $string =~ /\.\w+\.\w+/g;
[snipped]

my ($offtap1, $hpux)='/home/dbsmith/passwd.dubhpr01.sun'=~/\.(\w+)\.(\w+)\Z/;

More general help for all sorts of regex tasks is provided by perldoc perlre.

Dani

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