Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Don't re-read file for each new pattern...

by cgmd (Beadle)
on May 31, 2007 at 21:45 UTC ( [id://618591]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Don't re-read file for each new pattern...
in thread Don't re-read file for each new pattern...

I'm pointing it out: it's not $strings, but @strings

Thank you for identifying that error, I wasn't thinking while typing, and my typing, at its best, is, admittedly, horrendous!

I do understand some of the basics of a loop nested within another loop, but my point was not meant to be that issue. I was reasoning that the design of the script, so as to avoid re-reading the original text file, should be such that, once the original file has been read (and its content stored in @strings), the script should continue running, awaiting further user input, with additional "patterns". Had it been written, for example, with a foreach loop, and terminated after each successful full pass through the elements of @strings, a user would then be obligated to re-run the script (and, hence, re-read the text file) to attempt another pattern.

I'm not familiar with the Llama book, but if this is its final exercise I must presume you've gone through all of it and please don't take it as a personal offense, but I find it a bit surprising that you're still doing all this confusion...

Regarding the "Llama book", it is actually "Learning Perl" by Randal L. Schwartz, et al, and published by O'Reilly Media, Inc. I have been trying to learn Perl, using this book for just 2 months, now, and I don't profess to know all of the information, therein. Do you, by chance, have a different text you would recommend for the purpose of learning Perl basics? If so, I would be willing to try it also.

Thanks, again, for your above comments!

  • Comment on Re^4: Don't re-read file for each new pattern...

Replies are listed 'Best First'.
Re^5: Don't re-read file for each new pattern...
by blazar (Canon) on May 31, 2007 at 22:27 UTC
    Had it been written, for example, with a foreach loop, and terminated after each successful full pass through the elements of @strings, a user would then be obligated to re-run the script (and, hence, re-read the text file) to attempt another pattern.

    Yes, this is almost a tautology: if it terminates after processing @strings once, then it will terminate and you would have to run the whole script once again. The point is that it caches file info into @strings and processes the latter each time for each supplied pattern.

    Regarding the "Llama book", it is actually "Learning Perl" by Randal L. Schwartz, et al, and published by O'Reilly Media, Inc. I have been trying to learn Perl, using this book for just 2 months, now, and I don't profess to know all of the information, therein. Do you, by chance, have a different text you would recommend for the purpose of learning Perl basics? If so, I would be willing to try it also.

    I know what the "Llama book" is, but I mean: I don't have it handy and I only had it a few times in my all life in my hands. I don't have any good recommendation because basically most of what I know stems from a week's reading of the first few chapters of a very old Llama (Perl 4 times I suspect) and then from clpmisc.

      The point is that it caches file info into @strings and processes the latter each time for each supplied pattern.

      That states it well!

      Thank you, again, for your help.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-04-19 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found