CVSROOT: cvslog.pl - protect escapes from split

Przemyslaw Iskra sparky at pld-linux.org
Wed Oct 1 01:32:03 CEST 2008


On Tue, Sep 30, 2008 at 07:43:22PM +0200, qboosh wrote:
> Author: qboosh                       Date: Tue Sep 30 17:43:22 2008 GMT
> Module: CVSROOT                       Tag: HEAD
> ---- Log message:
> - protect escapes from split

> +  my $cmdargs = ($ARGV[0] or '');
> +  # little trick to support escapes which are not separators ("\ " or "\,");
> +  # we can use " ,, " sequence as it would be invalid in args
> +  $cmdargs =~ s/([^\\])[ ,]/$1 ,, /g;
> +  @input = split (/ ,, /, $cmdargs);

try this one:

  @input = split /(?<=[^\\])[ ,]/, $cmdargs;

or even:

  @input = split /[^\\]\K[ ,]/, $cmdargs;



Both (?<=pattern) and pattern\K are look-behind assertions, regex
requires the pattern to exist, but does not return it.


-- 
 ____  Sparky{PI] -- Przemyslaw _  ___  _  _  ........... LANG...Pl..Ca..Es..En
/____) ___  ___  _ _ || Iskra  |  | _ \| |  | : WWW........ppcrcd.pld-linux.org
\____\| -_)'___| ||^'||//\\// <   |  _/| |  | : JID......sparky<at>jabberes.org
(____/||   (_-_|_||  ||\\ ||   |_ |_|  |_| _| : Mail....sparky<at>pld-linux.org


More information about the pld-devel-en mailing list