--- "D. Bolliger" <[EMAIL PROTECTED]> wrote: > 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 >
Ah...yes I was thinking of using $1 and $2...cant beleive I forgot. Thanks though! And Lawrence thank you for the tip: "If you're dealing with variable length strings, separated by some kind of character, then regexp is the tool you want, not substr." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>