Add a New Comment Rich Markup
It is probably harder to implement named capture groups: --match -(?<foo>..)/(?<bar>...) -a file1 --match -(?<baz>.),(?<quux>.) -a file2 echo {foo} {baz}
Notation could be: {n.m} where n is the input source and m is the capture group. --match -(..)/(...) -a file1 --match -(.),(.) -a file2 echo {2.2} {1.1} With '--header 0': --match -(..)/(...) -a file1 --match -(.),(.) -a file2 echo {file2.2} {file1.1}
Each --match is linked to a file. This can visually be expressed by using -a instead of :::: : --match ...1 -a file1 --match ...2 -a file2 To support ::::+ in -a we introduce --a+ which is -a but acts like ::::+ Can we do this in Perl's parsing of options? or would it be OK if the filename is magic: +file means treat it as ::::+ If you have 3 files and you want to match file1 and file3 but not file2: --match ...1 -a file1 --match '' -a file2 --match ...2 -a file2 To refer to a previous match use +n: --match '' -a file1 --match ...2 -a file2 --match +2 -a file3 # Same regexp as second --match Lines that do not match the regexp should not be run, but reported with a warning: If you know there is a single line, it should not die. But you also want to know if a line does not match.
It is not only useful for tables: $ parallel --match '(.*)\.(.*)' mv {} {1}.csv ::: *.txt Single --match is for all input sources. Multiple --match is for each input source. It should work similar to colsep except {} is unchanged.
See https://github.com/aaronriekenberg/rust-parallel/wiki/Manual#regular-expression This can be done using multiple some repeating {=1 /(...),(...),(...)/; $_=$1 =} {=1 /(...),(...),(...)/; $_=$2 =} {=1 /(...),(...),(...)/; $_=$3 =} but it would be nicer to simply give the regexp to match, so $ARG[2] = $2 after matching. Maybe part of --colsep? Maybe --colmatch? --colmatch '(.*),((.*),(.*))' echo {1} {2} {3} {4} --colmatch '(?<foo>.*),(?<barbaz>(?<bar>.*),(?<baz>.*))' echo {foo} {barbaz} {bar} {baz} Small issue: {foo} is normally converted into {1}, how can we use $+{foo} as {foo}? Can we simply replace into the template: #!/usr/bin/perl $t = '{foo} {barbaz}'; @a = ("a,b,c", "o,,car"); for(@a) { /(.*),((.*),(.*))/ or die; print "$1 - $2 - $3 - $4\n"; /(?<foo>.*),(?<barbaz>(?<bar>.*),(?<baz>.*))/ or die; %a = %+; print "$+{foo} - $+{barbaz} - $+{bar} - $+{baz}\n"; $re ||= '\{('. join('|',keys %+).')\}'; $tt = $t; $tt =~ s/$re/$a{$1}/ego; print $tt,"\n"; }
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach Files: Comment:
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Only logged-in users can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Copyright © 2024 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Page source code
Powered by Savane 3.13-02a9.Corresponding source code