Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: The simplest perl Multi Line matching.

by dannyd (Sexton)
on Feb 08, 2011 at 08:54 UTC ( [id://886905]=note: print w/replies, xml ) Need Help??


in reply to Re: The simplest perl Multi Line matching.
in thread The simplest perl Multi Line matching.

Ok Thanks, that was very cunning, I just thought about that after reading your post.

I'm going through the links you sent.

Ive modified it to this, seems to work fine, please tell me if you have anything else to say about the code.

#!/usr/bin/perl my $newstr = ''; open (FH, "test.txt") || die "Could not open file.\n"; while(<FH>) { $newstr = $newstr.$_; print "!!\n" if ($newstr =~ /^-+\nPerl Progress\n-+\n\s\ndannyd\@c +li>\s$/m); } close (FH);

Thanks a lot by the way, in my opinion this got solved super fast!!

Replies are listed 'Best First'.
Re^3: The simplest perl Multi Line matching.
by CountZero (Bishop) on Feb 08, 2011 at 22:06 UTC
    my $newstr = '';
    Altough it is not "wrong" there is no reason at all to initialize a lexical variable to the empty string (or zero) as the my takes care of creating a brand new "empty" variable with the value of undef, empty string or zero (depending on how you look at it).

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found