use strict; use warnings; my $str = 'smth'; my $var = q!/\Q"'[]{}()/ or ! . $str; print "$var\n";