#!/usr/bin/perl -w use strict; my $regexp = qr/^x/i; # a regexp # stringify it my $hash = { $regexp => 1 }; # keys are stringified my $string = (keys %$hash)[0]; # a string print "$string (ref: ", ref $string,")\n"; # and I prove it! # the string is: '(?i-xsm:^x)' # regex-ify it if( $string=~m{^\(\?([xism]*)-([xism]*):(.*)\)$}) # match the interesting bits { my $nregexp= qr/(?$1:$3)/; # rebuild it print "$nregexp (ref: ", ref $nregexp,")\n"; # a regexp again! # it stringifies as '(?-xism:(?i:^x))' }