Solved

stripslashes in perl

Posted on 2002-07-11
4
1,275 Views
Last Modified: 2008-01-09
In Perl, how can I perform the same action that stripslashes does in php?
0
Comment
Question by:blackwolfsystems
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
smisk earned 75 total points
Comment Utility
Shouldn't be too hard.  According to the php docs you just remove backslashes from \", \', and \\.

sub stripslashes() {

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

    return $_;

}
0
 

Author Comment

by:blackwolfsystems
Comment Utility
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
 
LVL 1

Expert Comment

by:smisk
Comment Utility
Thanks.  I must have missed the global option...
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
s/\\([\\'"])/$1/g
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now