in reply to map function - print to file problem

Somewhat unrelated to your question, but this if needs an else. You use $year later, and don't otherwise reset it:

if ($file_in_question =~ /^(\d{4})/){ $year = $1; }

As for your actual question, does this work?

print OUT for map{ s[(^\d+\s+)[\d\.]+\s+][$1]; "$year\t$_"; } sort { # ... etc.

addendum: I would follow BrowserUk's advice in Re^3: Regex problem and replace the map pipeline with a series of steps. You aren't comfortable with this code the way it is.

Replies are listed 'Best First'.
Re^2: map function - print to file problem
by Win (Novice) on Oct 19, 2005 at 12:25 UTC
    Your answer for the 'actual question' works. Thankyou for that. To address your first point I have done the following:
    if ($file_in_question =~ /^(\d{4})/){ $year = $1; } else { next; }
    Also I would like to say that BrowerUK's explanation offered in the post you refer to, I believe, is very well written. I would encourage anyone here to read it through.