in reply to Comparing an array with a regex array of strings?
But is also possible to parametrize your oneliner with a BEGIN block that pop @ARGV to get two parameters and leave in it the file to feed to perl -lan. A custom delimiter for autosplit is specified with F", ".perl -lanF", " -e "print join(',',map{$1if/(?:[Name|Age|Gender] = )(.+ +)/}@F) if shift @F eq 'Person1'" persons.txt Lydia,20,F
All theese jems and much more are shown in perlrunperl -lanF", " -e "BEGIN{map{$_=pop @ARGV}$rx,$who}print join(',',map{ +$1 if /(?:[$rx] = )(.+)/}@F) if shift @F eq $who" persons.txt Person1 + "Name|Age|Gender" Lydia,20,F
|
|---|