hi,
can anybody explain me the below code. i am new to perl
==========================================
$o_dups{$1} = 1 if /^\w+\t.{19}\t([^,]+),/;
==========================================
regards,
priyanka
hi,
can anybody explain me the below code. i am new to perl
==========================================
$o_dups{$1} = 1 if /^\w+\t.{19}\t([^,]+),/;
==========================================
regards,
priyanka
It creates hash element in %o_dups, with the key being extracted from 3rd field in TAB delimited line present in $_. The extracted part is from the start of that field to the first comma.
$o_dups{$1} = 1 if /^\w+\t.{19}\t([^,]+),/;
man perlre for more info on regexes but a quick breakdown follows
$o_dups{$1}=1 # set the value in the o_dups hash for the match capture ($1) to true
if /^\w+\t.{19}\t([^,]+),/;#if the regex matches
The regex itself breaks down as:
/^ # beinning of line
\w+# one or more "word" characters, (ie. alphanumeric + "_")
\t # a litteral tab
.{19} # any 19 characters
\t # a literal tab again
([^,]+) # A series of non "," chars in brackets so capture this as the first capture ($1 above)
,#followed by a comma
/ #End match