if( $ENV{'SHELL'} =~ m:/bash$: ) { printf 'export ENVAR=%s\n', $value; ... } elsif ( $ENV{'SHELL'} =~ m:/csh$: ) ...