Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

match extentions

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Joined
Feb 6, 2002
Messages
1,851
Location
IL
HI,

A simple one.

I want to match only files that have extentions ".vps" , ".ps" , ".sep" only.
Have failed doing so with the code:

next if ($myfile != /\.ps|\.sep|\.vps/);

Will appreciate advise.
Thanks


Long live king Moshiach !
 
Use [tt][blue]!~[/blue][/tt] not [tt][red]!=[/red][/tt] as the matching operator.



--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Probably a good idea to use the $ anchor and the i modifier to avoid accidental false positives and upper case file extensions
Code:
next if ($myfile !~ /(\.ps|\.sep|\.vps)$/i);


Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::PerlDesignPatterns)[/small]
 
I was about to say that ;)
but a little improvement, nonetheless, is to move the '.' outside of the option grouping.
Code:
next if ($myfile !~ /\.(ps|sep|vps)$/i );
At least, it reads cleaner (to me).
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top