The stupid question is the question not asked | |
PerlMonks |
Re: Perl Script performance issueby Cristoforo (Curate) |
on Dec 15, 2015 at 15:12 UTC ( [id://1150386]=note: print w/replies, xml ) | Need Help?? |
A comment on your lines that use split, split(/$hash_ref->{DELIMITER}/. If the delimiter is pipe, |, then your split is split /|/, .... That will not work as you want because the split pattern, '|', in this case says to split on 'nothing OR nothing'. (Equivalent to split //, ...
To correct this, you should use the \Q escape sequence. That tells perl to treat the pipe as a regular character and not mean OR in the regular expression. I saved a file of what are called the 'dirty dozen' of metacharacters. The pipe is one of the dirty dozen. They are: \ | ( ) [ { ^ $ * + ? . They all need escaping if they are to be treated as a 'regular' character in a regular expression (not as a metacharacter). So, your split should look like (There also is the quotemeta built in function).
In Section
Seekers of Perl Wisdom
|
|