I just wrote :
>
> qc// ? (Mnemonic : "Quote like in C")
Couldn't resist to implement this ;-) There are probably bugs (not
speaking about trigraphs) but this package makes available a qc//
operator that should do this.
package QC;
use strict;
use warnings;
use Exporter;
use Sub::Quotelike;
our @ISA = qw(Exporter);
our @EXPORT = qw(&qc);
sub qc (') {
my $str = shift;
$str =~ s/\\t/\t/g;
$str =~ s/\\n/\n/g;
$str =~ s/\\r/\r/g;
$str =~ s/\\f/\f/g;
$str =~ s/\\a/\a/g;
$str =~ s/\\e/\e/g;
$str =~ s/\\([0-7]{3})/chr oct $1/ge;
$str =~ s/\\x([0-9a-fA-F]{2})/chr hex $1/ge;
return $str;
}
sub import { QC->export_to_level(1,@_); goto &Sub::Quotelike::import; }
1;
__END__
Example :
$ perl -wMstrict -MQC -e 'print qc/$foo\n$bar\n/'
$foo
$bar
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/ / http://lyon.pm.org/