in reply to Searchin' through values
If you treat the arg as a regex pattern, "[P/R]" actually means "P", "/" or "R". You simply want "[PR]".
"." means any character
"[QRG]" will match one of those three characters.
And if you want to format you specified:
my $pat = ''; for ($ARGV[0]) { /\G ([A-EG-WYZ]+) /xgc && do { $pat .= $1; redo }; /\G X /xgc && do { $pat .= '.'; redo }; /\G F /xgc && do { $pat .= '[QRG]'; redo }; /\G \[ ([A-Z]) \/ ([A-Z]) \] /xgc && do { $pat .= "[$1$2]"; redo }; /\G \z /xgc && last; my $pos = pos(); my $next = substr($_, $pos, 1); die("Unrecognized character \"$next\" at pos $pos\n"); }
Update: Added missing /xgc.
In Section
Seekers of Perl Wisdom