At 01:22 PM 7/28/2003, you wrote: >> Hi there, >> >> What perl function can i use to extract a >> sub-string from a string. >> >> > >$string = 'myfile.txt'; > >$string =~ m/^(\w+)\.txt$/; > >print $1;
When I saw this question I immediately thought my $string = "myfile.txt"; my $substring = substr($string, 0, 6); print $substring; OR my $string = "myfile.txt"; my @stringwords = split(/\./, $string); print $stringwords[0]; ... Can you address why you'd want to use RegEx instead of one of the above choices? I know there are lots and lots of different ways to do things in Perl; I'm just trying to get a handle on why sometimes it's better to do things one way than another way. ... the answer "because that's how I usually do it and it's habitual" is completely legit. :-> Thanks, Tara -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]