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

Re(2): simple regex (again)

by graq (Curate)
on Oct 23, 2001 at 15:18 UTC ( #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...



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 :)


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

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

      I'll keep trying..



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://120748]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2018-01-20 01:19 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (226 votes). Check out past polls.