in reply to Read from and write to file

Well one suggestion would be using split efficiently...there's no need to call it three times.
my ($command, $name, $address) = split(/\s/, $input_command);
does the same thing as those 3 lines. Also, another option to lowercasing everything is simply to use a case-insensitive regex option (/i).

As far as your specific question about scanning the file...I assume you'd do it the same way you're breaking down the input command...read line from file, split line, compare.

I would say use Tie::File for max efficiency to make the change on the fly.

Replies are listed 'Best First'.
Re^2: Read from and write to file
by Cenobite (Novice) on Apr 05, 2007 at 20:47 UTC
    Thanks very much for the suggestions, wojtyk.

    You're totally right about using split more efficiently. As for Tie::File, I'll be looking into that. I'm not too sure about using the \i option for regular expressions, as I want to ensure that the information entered gets saved as all lowercase, even if entered as e.g., "John" or "JOHN".

    Thanks again! :-)

      That is what the lc command is for

      TStanley
      --------
      War is an ugly thing, but not the ugliest of things. The decayed and degraded state of moral and patriotic feeling which thinks that “nothing is worth war” is much worse. The person who has nothing for which he is willing to fight, nothing which is more important than his own personal safety, is a miserable creature and has no chance of being free unless made and kept so by the exertions of better men than himself. -- John Stuart Mill
        Ahh, that's so useful!

        I've already learnt at least 3 new things just by posting. Thanks a ton! :-)