Skip navigation.
Home
Your source for Perl tips, howto's, faq and tutorials
( categories: )

Perl support similar pattern matching using wildcard operators like unix (and DOS) shells do; you have to enclose the pattern matching between "<>".

FILE PATTERN MATCHING OPERATORS

* match zero or more characters
? match any single character
{expr2,expr2,...exprN}   match expr1 OR expr2 OR ... exprN
[...] match any single character specified within the square brackets
[!...] match any single character except those specified within brackets



Note:
These wildcard operators are also used on regular expressions but the meaning is different when they are used in regular expressions (for example, "too?" matches "too" and "to" in a regular expression context, in a file pattern matching context it matches "tool" but doesn't match "too" or "to").

Examples:

#-- get all files ending in .pl
@list = <*.pl>;
 
#-- get all files ending in .c or .h
@list = <*.[ch]>;
 
#-- files ending in .rpm or .gz
@list = <*.{rpm,gz}>;
 
#-- files begining with a number
@list = <[0-9]*>;


how to work hashes with files

Hi ,

How can we work with hashes using files,how to read , how to match the pattren using files.
can any one explain me.

How to Match the contents(pattren)

Thanks for replay,
I have one more doubt regarding files,
i have a file containing full of data,and i want to match the particular data and i should display related data, how can i do it,help me.

VRaghu