Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

It's Not Clear What You're Doing - Re: pattern matching

by metadoktor (Hermit)
on Mar 29, 2002 at 02:43 UTC ( [id://155185]=note: print w/replies, xml ) Need Help??


in reply to unitialized value error in pattern matching script

I think that your code has some really serious problems if you posted it without errors. I'm not sure what you're attempting with $_myfile[$i]? Perhaps you meant $_[$i] or $myfile[$i]? Also the regex you attempted does not have a trailing / (forward slash). Also the 'filename' variable you posted should be '$filename'.

Something like the following should work assuming that @myfile has been defined to be an array and contains the required filenames.

for (@myfile) { if (/$filename/) { print "Found pattern.\n"; } }
Now another problem is that you seem to want to extract some substrings from the matched string by your use of parens in the regex yet it is unclear what you're trying to do here since you already know that the pattern is 'Hare.java' or is it?

metadoktor

"The doktor is in."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://155185]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2024-04-18 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found