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;
my ($host) = substr ($string,21);
my ($OS) = substr ($string,-3);


The OS variable outputs 'sun' but obviously will not
work for hpux or linux.

And the host variable outputs 'dubhpr01.sun' when all
I need is 'dubhpr01' 

thank you
derek

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