perl_mystery has asked for the wisdom of the Perl Monks concerning the following question:

Expandplf_updates.txt:- /****************************ORPHANED FILES*************************** +/ //source/modem/hdr/cp/rel/07.01.00.13.20/inc/hdr.c#2 //source/modem/hdr/cp/rel/07.01.00.13.20/inc/hdrscmgmmcdp.h#2 /*************************** FILES IN VU's***************************/ /******************************* PLF's******************************/ my $expand_line = <Expandplf_updates.txt>; open my $FH, '<', "$expand_line" or die "could not open $expand_plf - +$!"; while (<$FH>) { chomp; print "IN\n"; next unless ( m:(\/\/.+?)#(\d+)$: );//why is the above input not m +atching this line. print "\nMATCH DATA:$1 $2";//doesnt print this

Replies are listed 'Best First'.
Re: Regex not matching
by ikegami (Patriarch) on Jan 29, 2011 at 04:28 UTC
    Why do you beat your wife? Which is to say it does match. Perhaps your actual data has some kind of hidden character between the number and the end of the line (spaces? CR?)

       "Why do you beat your wife?"

      I realize this is used figuratively but I think we can all agree there is a better way to express a point than to use a violent image against women.

      A text search shows it's been used before on the site so you're not the first to include it in a post.

      Even without malice or literal meaning behind it the phrase is offensive. Please, to anyone who has used it before or would use it in the future, consider another way to illustrate your point.

        Isn't it rather a reference to traditional quote (see e.g. Loaded_question) rather than the violent image?

      that's what I also dont get it,am just racking my brain from morning,is there a way I can attach a text doc?

        No.

        If you have od, you could dump your file using

        od -c file

        Or you could use Perl.

        perl -ple's/\\/\\\\/g; s/([^\x21-\x7E])/sprintf(qq{\\x{%X}}, ord($1))/ +eg;' file

        (Switch «'» for «"» for the Windows shell.)

        I dont think I can attach a text doc,but I modified the input to exactly what I have?can you spot a difference which I cant?