If you're trying to generate a data structure to be loaded and used later, you might want to use Storable, which is designed for storing and loading data structures:
perl -MStorable -le 'store { x => qr/x/ }, "/tmp/x"; $x = retrieve "/tmp/x"; print $x->{x}'