Perl Monk, Perl Meditation | |
PerlMonks |
Re: In my perl script one of the variable it is giving an extra dot.by choroba (Cardinal) |
on May 25, 2022 at 08:18 UTC ( [id://11144179]=note: print w/replies, xml ) | Need Help?? |
A dot has a special meaning in regexes, it matches any character except newline. To match a literal dot, you need to backslash it. Moreover, you probably don't want to remove a dot from somewhere further inside the string, only the starting one. You can add ^ to the regex, it only matches at the beginning of the string. The final g means "global", it will remove all the occurrences of the pattern. As we only want to remove a single occurrence, we don't need it.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Seekers of Perl Wisdom
|
|