in reply to Re^4: Constructing a hash - why isn't my regex matching anything
in thread Constructing a hash - why isn't my regex matching anything

why is $key and $match not matching anything?

Because there is nothing to match. An empty line, all whitespace line, is empty :) It has no dots. It has no dashes, semicolons, slashes. Your regex won't match. :D

what change should I do in regex to match them?

Allow for the possibility of failure,ie test for success, just like this guy shows

  • Comment on Re^5: Constructing a hash - why isn't my regex matching anything

Replies are listed 'Best First'.
Re^6: Constructing a hash - why isn't my regex matching anything
by perl_mystery (Beadle) on Dec 19, 2010 at 09:23 UTC

    For the input line shown below,the regex is still no matching,I couldnt find anything wrong?Need your input

    INPUT LINE:\root\edit\perl\scripts\scripths\sec\inc\script_auth_pap.h- +113115;perforcePLF.txt;//programfiles/documents/data/lookup/script_au +th_pap.h - label_scriptHS_source.01.16.00 : 5 if (my ($key, $value) = $line =~ /\.\\(.+?)-\d+;.+?;(.+?)\s-\s/) { }
      Well, use re 'debug'; and YAPE::Regex::Explain and try to figure out why :)

      My guess, trial and error involves a lot of error *ZING* :D

      Seriously, this (unspecified format, formatted) input is looking more and more like CSV where the separator is a semi-colon, THUS, I would use Text::CSV//Text::xSV and be finished (hopefully).

      PS, FWIW, I'm fatigued, no more posts from me :)

      I don't see a dot followed by a backslash in that string.