Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re(2): simple regex (again)

by graq (Curate)
on Oct 23, 2001 at 15:18 UTC ( [id://120748]=note: print w/replies, xml ) Need Help??


in reply to Re: simple regex (again)
in thread simple regex (again)

That's not the all of it, I have reformatted the original question (see below) - and I still am feeling unsure what it is the original post actually wants...
And there appears to be numerous other helpful suggestions to improve the code.

I would suggest that the original poster tried SEARCHING the site to look for some relevant answers, and avoid a lot more RTFM answers...

 

__REFORMATTED MESSAGE__

This works fine for outputing to file, however, still unable to assign to array without opening the output afterwards.
Would be good if I could set overall match to array at the same time as sending to output.

#!perl.exe my $filename="e:\test.out.txt"; my $output="e:\out.txt"; sub body { if (-r $filename) { open(FILE,"<$filename"); open(OUTPUT, "> $output"); while() { chomp; if (/Datasource:/) { print OUTPUT "\n", $_; } if (/Passed:/) { $section="passed"; next; } elsif (/Failed:/) { $section="failed"; print OUTPUT "\n",$_; next; } elsif (/Exception:/) { $section="except"; print OUTPUT "\n",$_; next; } if ($section ne "passed") { if (/(test\.)|(Summary:)/) { print OUTPUT "\n",$_; } } } close(FILE); close(OUTPUT); } else { print("cant read file ",$filename,"\n"); } }

-- Graq's Home Page

Replies are listed 'Best First'.
Re: Re(2): simple regex (again)
by davorg (Chancellor) on Oct 23, 2001 at 15:23 UTC

    Your reformatting has missed the fact that the AM actually had while (<FILE>). I've now added <code> tags to the original post which makes it clearer.

    But not necessarily very clear :)

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."

      Argh..yes.
      Not only was I that slow about it that someone else had added the code before me, but I went and got it wrong.
      DOH!

      I'll keep trying..

      Graq

      "Shhhhhhhhhhhhh!"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found