I drop enclosing quotes, single or double, with this subroutine:
# perl0005.lib
# Written: 1999-07-09 James Alarie
#
# unquote
sub unquote{
if (substr($_[0], 0, 1) eq "\"") { # begins with "
if (substr($_[0], -1) eq "\"") { # ...and ends with "
$_[0] = substr($_[0], 1, length($_[0]) - 2);
}
} else {
if (substr($_[0], 0, 1) eq "'") { # begins with '
if (substr($_[0], -1) eq "'") { # ...and ends with '
$_[0] = substr($_[0], 1, length($_[0]) - 2);
}
}
}
}
#***** Accessed correctly:
1;
A much shorter verson from Jeff Mott of jeffmott@twcny.rr.com:
sub unquote{
$_[0]=~s/^(["'])(.+)\1$/$2/;
}