On Sun, 24 Oct 2004, Bernard Kenik wrote: > The part that puzzled me was [^/] .. so I experimented a little. I asked > myself how I would extract the path portion.
Wasn't the requirement to *throw away* the path portion, not save it? > The final answer I came up with was: ( my $path = $file ) =~ s#(.*/).*#$1#; > This extract all characters up to and including the last slash since this is a > greedy regex. Wouldn't that save the path, but not the filename? Isn't that the opposite of what the guy was asking for? > Therefore I concluded that "[^/]" would not be needed. > > ( my $name = $file ) =~ s#.*/(.......).*$#$1#; does the same thing as ( my > $name = $file ) =~ s#.*/(.......)[^/]*$#$1#; Maybe so, but when I was testing it on the command line, the variant you show was matching the first slash and the first 7 characters after it, which isn't what the guy (seemed to be) asking for. That said, I'm still not sure I had it right. He said he wanted the first seven characters, which is what I was trying to write, but it looks like he wanted the part of the filename before the underscore: $no_path_file = "NewProcess_date_22-oct-2004.log"; ( my $prefix = $no_path_file ) =~ s/_.*//; print $prefix; print $prefix; -- prints "NewProcess", which seems to be what he really wanted. But he *still* never described the goal clearly, so that's as close as I care to bother getting :-) > This is not meant as a criticism but simply to show that someone was > watching and learning. We're all learning, hopefully -- I know I am... :-) -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>