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

regex newbie question #2

Expand Messages
  • mdowsz
    Ok more mysteries here. I wrote a simple perl program this morning so that i can set a regular expression and then run its against a input file. but im having
    Message 1 of 1 , Nov 3, 2003
    • 0 Attachment
      Ok more mysteries here.

      I wrote a simple perl program this morning so that i can set a regular
      expression and then run its against a input file. but im having one
      small error

      heres the code
      *******

      #! /usr/bin/perl
      use strict;
      use warnings;

      print "enter your expression: \n";
      chomp (my $regex = <STDIN>);

      while (<>) {
      chomp;
      if (/$regex/) {
      print "Matched: |$`<$&>$'|\n";
      }
      else {
      print "did not match: $_ with the expression: /$regex/\n";
      }
      }

      **********

      this seems to work great for every type of expression that ive given
      it except for matching words with the "\<" and "\>" metacharacters.
      can anyone out there explain why these characters are not working, or
      let me in on how to tweak the code to work?

      thanks alot.
    Your message has been successfully submitted and would be delivered to recipients shortly.