in reply to parsing data in a file

Take a look at split - the first argument is actually a regular expression.

Looking at your data, split(":", $input) should probably be split(/: /, $input) (i.e. a colon followed by a space).

-- Ken

Replies are listed 'Best First'.
Re^2: parsing data in a file
by CountZero (Bishop) on Nov 02, 2010 at 15:36 UTC
    And as sometimes TAB characters hide themselves as whitespace, I usually write such regexen as /:\s+/

    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

      Good point, CountZero. And a requirement in more complex REs that you've spaced out for readability: / : \s+ /x (a bit over-the-top for that example but it shows the intent :-)

      -- Ken