Loading ...
Sorry, an error occurred while loading the content.

Search in File

Expand Messages
  • ROB Technology
    Hello. How do I open a file and search for certain keywords in it?
    Message 1 of 2 , Mar 3 11:30 AM
    • 0 Attachment
      Hello. How do I open a file and search for certain keywords in it?
    • Jonathan E. Paton
      ... How do I open a file and search for certain ... Hi, open FILE, file or die $!; while (FILE) { /word/ && print Found word n ; } close FILE or warn $!;
      Message 2 of 2 , Mar 3 11:39 AM
      • 0 Attachment
        --- ROB Technology <rob@...> wrote: > Hello.
        How do I open a file and search for certain
        > keywords in it?
        >

        Hi,

        open FILE, "file" or die $!;
        while (FILE) {
        /word/ && print "Found 'word'\n";
        }
        close FILE or warn $!;

        Documentation at:

        perldoc -f open
        perldoc -f close
        perldoc -f die
        perldoc -f warn
        perldoc perlre # Regular Expressions
        perldoc perlop # Perl Operations (for &&)

        There is obviously more ways to achieve this.

        Jonathan Paton

        __________________________________________________
        Do You Yahoo!?
        Everything you'll ever need on one web page
        from News and Sport to Email and Music Charts
        http://uk.my.yahoo.com
      Your message has been successfully submitted and would be delivered to recipients shortly.