I replied directly too - sorry. Why not use a module to help out? I
think it's easier to read - but then again I'm no perl expert...
use File::Basename;
$fullname = "/usr/local/pics/sample.tiff"; #for example
($file,$dir,$_) = fileparse($fullname, qr/\..*/);
if (/\.(tif|tiff|jpg|jpeg)$/) {
print "This is an image file.\n";
};
-----Original Message-----
From: Paul Ohashi [mailto:[EMAIL PROTECTED]
Sent: Monday, December 06, 2004 4:24 PM
To: [EMAIL PROTECTED]
Subject: FW: Trouble with compound regular expression matching
Hmmm.. I'm new to this list and I just replied to the message and it
seems to have gone directly to Jeffrey, sorry 'bout that...
I did need to add the case-insensitivity to the regex:
/^.*\.[tj][pi][gfe].*$/i
That's better, I think.
-Paul
-----Original Message-----
From: Paul Ohashi
Sent: Monday, December 06, 2004 4:19 PM
To: 'Jeffrey Paul Burger'
Subject: RE: Trouble with compound regular expression matching
This one worked for me:
/^.*\.[tj][pi][gfe].*$/
Hope this helps
- Paul
-----Original Message-----
From: Jeffrey Paul Burger [mailto:[EMAIL PROTECTED]
Sent: Monday, December 06, 2004 4:06 PM
To: [EMAIL PROTECTED]
Subject: Trouble with compound regular expression matching
I tried everything I could think of to get this to work before pleading
for
help!
I need to check if a file is either a TIFF or JPEG graphics file.
(Case-insensitive variations of qualifying suffixes would be .tif,
.tiff,
.jpg and .jpeg.) So far I have three difference versions of what seem to
be
a valid line of code to test a single pattern. ($file_name holds the
name of
the file. Also, for logic reasons, I'm testing that it's NOT one of
these
types):
if ($file_name !~ /tif$/i) {}
if ($file_name !~ m/tif\b/i) {}
if ($file_name !~ m/.*.tif/i) {}
But I can't for the life of me figure out how to structure a working
version
of a more complex variation on any of the these that test all four cases
(or
even a second one, for that matter). From my reading, I would expect the
following to work, but it doesn't:
if ($file_name !~ /tif$/i | /jpg$/i) {}
Any help would be greatly appreciated.
Thanks!
Jeffrey Paul Burger
2675 W. Hwy. 89A - PMB 455
Sedona, AZ 86336
928-203-0170
"There are only two ways to live your life.
One is as though nothing is a miracle.
The other is as if everything is."
--Albert Einstein
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>