open( SH, "| /bin/sh" ); ... sub execute { my ($com, $columns) = @_; # substitute the value from the appropriate column for \0, \1, etc. $com =~ s/\\(\d+)\;?/$columns->[$1]/g; print SH "$com\n"; }