use strict; use warnings; use Test::More tests => 5; my %ENV = ( # Overrides the global for this test playground => 'myplay', HOME => 'myhome', le1 => 'fix_for_file1' ); my @expected = ( q(set playground="myhome/playground")."\n", q(set file1=myplay'/fifix_for_file1')."\n", q(set file2=myplay'/file2$')."\n", q(set file3=myplay'/f$i$l$e$3$')."\n", q(set file4=myplay'/fi\$le4')."\n", ); # look # behind |------ $1 ------| my $with_braces = qr/ (?) { s!$with_braces !$ENV{$2}//$1!xge; s!$without_braces!$ENV{$2}//$1!xge; is( $_ , shift @expected, $_ ); } __DATA__ set playground="${HOME}/playground" set file1=${playground}'/fi$le1' set file2=${playground}'/file2$' set file3=${playground}'/f$i$l$e$3$' set file4=${playground}'/fi\$le4' #### 1..5 ok 1 - set playground="myhome/playground" # ok 2 - set file1=myplay'/fifix_for_file1' # ok 3 - set file2=myplay'/file2$' # ok 4 - set file3=myplay'/f$i$l$e$3$' # ok 5 - set file4=myplay'/fi\$le4' #