stripslashes in perl

In Perl, how can I perform the same action that stripslashes does in php?
blackwolfsystemsAsked:
Who is Participating?
 
smiskCommented:
Shouldn't be too hard.  According to the php docs you just remove backslashes from \", \', and \\.

sub stripslashes() {

    $_ = shift();
    s/\\'/'/;
    s/\\"/"/;
    s/\\\\/\\/;

    return $_;

}
0
 
blackwolfsystemsAuthor Commented:
Thanks I kind of guessed it would end up like that.

But that doesn't quite work, you have to do:
s/\\'/'/g;
s/\\"/"/g;
s/\\\\/\\/g;
instead as otherwise it only changes the first occurance.

Thanks for the help
0
 
smiskCommented:
Thanks.  I must have missed the global option...
0
 
ozoCommented:
s/\\([\\'"])/$1/g
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.