Derek B. Smith wrote: > 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);
Assigning a list to a scalar makes no sense. > #my ($host_name) = $string =~ /\.\w+\.\w+/g; > my ($host) = substr ($string,21); > my ($OS) = substr ($string,-3); $ perl -le' my $string = q(/home/dbsmith/passwd.dubhpr01.sun); my ( $host, $OS ) = ( split /\./, $string )[ -2, -1 ]; print for $host, $OS; ' dubhpr01 sun John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>