Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Don't ask to ask, just ask
 
PerlMonks  

Re: Two files from one.

by buckaduck (Chaplain)
on May 22, 2002 at 12:38 UTC ( [id://168509]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Two files from one.

(Untested) If the questions in the input are separated by blank lines:
# Read input a paragraph at a time # and put carriage returns on output lines local $/ = "\n\n"; local $\ = "\n"; # Read input, one question at a time while (<>) { chomp; # Grab the question number my $number = /^(\d+\.)/; # Split the question into lines my @question = split /\n/; # The answer is the last line my $answer = pop @question; # Send the results to different output streams print OUT1 join("\n", @question); print OUT2 "$number $answer"; }

buckaduck

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://168509]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.