On Tuesday, Mar 18, 2003, at 15:46 US/Pacific, Peter Kappus wrote:
I also had no problem...[..]
"myfile.jpeg" =~ /(.*?)\.(.*)/; print $2;
gives me "jpeg"
Can we see the rest of your code? I think the problem may be in the value of $file_completename...
I think the OP may have a problem with what is really in that $file_completename that was not planned for.
To test this I put together:
sub split_me {
my ($file_completename, $extension) = @_;
$file_completename =~ /(.*?)\.([^\.]*)$/;
if ($2 && $2 eq $extension )
{
print "we match $extension for $file_completename\n";
}
else
{
print "FAIL to match $extension for $file_completename";
print " - " . $2 if ( $2 ) ;
print "\n";
}
} # end of split_me
split_me("bob.txt" , "txt");
split_me("bob.html" , "txt");
split_me("bob.txt.html" , "txt");
split_me("bob.txt.html.txt" , "txt");
split_me("/some/path.here/bob.txt" , "txt");the first two cases work as expected and the next three will help show a part of the problem
we match txt for bob.txt
FAIL to match txt for bob.html - html
FAIL to match txt for bob.txt.html - txt.html
FAIL to match txt for bob.txt.html.txt - txt.html.txt
FAIL to match txt for /some/path.here/bob.txt - here/bob.txtif one changes the RegEx to say
$file_completename =~ /(.*?)\.([^\.]*)$/;
then the output looks like:
we match txt for bob.txt
FAIL to match txt for bob.html - html
FAIL to match txt for bob.txt.html - html
we match txt for bob.txt.html.txt
we match txt for /some/path.here/bob.txtthe regex looks at ONLY the last stuff after a '.'
note also that if we had
split_me("bob" , "txt");
that this would fail, and without the test to see that $2 existed we would get a warning about attempting to compare it to $extension.
HTH.
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
