On Monday 03 December 2007 18:00, [EMAIL PROTECTED] wrote: > > John W.Krahn <[EMAIL PROTECTED]> writes: > > > >> I thought it might be because File::Find cds to the target dir > >> then names like src dir or ./src ./dir fail. Just guessing > > > > OK, that's my mistake, as I said I didn't test it ... oops. :-) > > I guess you knew this from your smilie but to confirm ... that was > not a complaint...I really appreciate getting a look at well done > code. I've wallowed around with my own pathetic code for years really > without really paying attention to how it should be done. I'm a home > user who likes to script up stuff at times. Fortunately no one else > suffers from poor coding. (Except usenet.. and mailing lists.. hehe) > > I do have another related question about this whole thing. > Originally (not in the code I posted) > I wanted to make the script so it could either copy the files or just > report on the findings (file name and content of regex that hit). > > I used a getopts to make the decision and when copying wasn't > selected I thougt it would be smart to break out of the while loop > inside a find() either when the regex hit, or when the first blank > line showed up, which ever came first. > > Some of the directories I'm working with are pretty big. The biggest > one is over 400,000 posts. So reading only up to the regex hit would > represent quite a lot of lines saved. > > The regex are only aimed at headers. Most often From: or Subject:. > > I was reading lines with a while loop inside find() so used a `last' > to break out of it. Perl gives a warning for that so I thought maybe > it wasn't such a good idea... but finally resorted to sticking with > the last and quieting the warnings with `no warnings' locally.
Perl will not warn when using 'last' (or 'next' or 'redo') inside a while loop so either you used it outside the loop or you used it with the while statement modifier. > So two questions: > > 1) With the scale of data I'm talking about would breaking out after > finding the regex be of much benefit. (when not copying) Probably yes. > 2) What is the best way to break out of a while loop early, inside a > find()? If you need to process stuff after the loop ends use 'last' to exit the loop. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/