in reply to Re^3: Matching part of a line and saving it into a variable
in thread Matching part of a line and saving it into a variable

Double quotes are not magic in a regex, so you do not have to escape them.

If you want to skip the first line of your loop, why not simply do a <FILE> just before the loop? That reads the first line and discards it.

You do not need a chomp inside the loop. Your regex extracts the fields well before it reaches the end of the string.

Always use a three argument open. What do you think will happen when someone maliciously enters >myfile.txt as the filename argument? Indeed, bye bye file contents!

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

Replies are listed 'Best First'.
Re^5: Matching part of a line and saving it into a variable
by fidesachates (Monk) on Mar 14, 2011 at 22:25 UTC
    Good points. 3/4 of them were due to me copying the OP's code with barely a glance.