Brandon McCaig <bamcc...@gmail.com> writes:

> On Thu, Feb 3, 2011 at 10:47 AM, Harry Putnam <rea...@newsguy.com> wrote:
>> I used this in my crude little starter program as one part of a
>> foreach loop:
>>
>>  if ( !/^.*\.[bjgtp][gimnps][gfadp]$/) {
>>    print "<$_> is not a properly named image file .. skipping\n";
>>    next;
>>  }
>>
>> Just so I'd have output so as to trace any problematic files if there
>> seemed a need.  The regex appears to encompass all the types I want to
>> deal with, but is no doubt horribly written.
>>
>> Its intended to allow:
>>
>> jpg, tif, bmp, gif, tga, png, psd And to reject anything else and just
>> skip it.  I think that's all, but may be leaving out some less common
>> types.  I'd sooner only deal with types listed there.
>
>     unless($filename =~ m(.+\.(bmp|gif|jpg|png|psd|tga|tif)$))
>     {
>         print STDERR "The filename {$filename} has an unsupported
> extension. Skipping...";
>         next;
>     }

Thanks for the suggestion.

May I ask how that formulation servers the purpose better?  Is it
processed more easily or quicker in that formulation as against the
one I posted?

Or does mine leave too many possibilities for poor results?


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to