Previous

Next


03. What Does a Regular Expression Look Like?

Here's some Perl code with a regular expression in it I used just the other day:

  #!/usr/bin/perl
  
  undef $/;
  
  require 5;
  use File::Find;
  use File::Copy;
  
  find(\&createList, "@ARGV[0]");
  
  ##############################################
  
  sub createList {
    $email = "";
    open(FILE, $_);
      $data = <FILE>;
    close(FILE);
    if ($data =~ m/User_email\s*=\s*([^\s]*)/) {
      $email = $1;
      if ($email =~ m/\w*\@\w*/) {
        print "$email\n";
      }
    }
  }
      

By the end of tonight, we'll be able to understand what all that horrible garbage means!


Previous

Next

Andrew Hill

For LinuxSA Meeting, 21 November 2000