Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old August 9th, 2000, 04:06 AM
markki markki is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 3 markki User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hi..
how can I do this:
$inVar = "this is a string with both " and ' in it which will probably confuses the perl engine";

I could have added slashes by hand.. but the above string is 2000 lines long in my program..
I tried using quotemeta but it didn't work either...
no.. I don't want to store it in a file.. and then do it..
I want to be able to do this within the same file...

how can it be done?

Reply With Quote
  #2  
Old August 9th, 2000, 06:23 AM
christucker2 christucker2 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 81 christucker2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Use:
$inVar = qq/this is a string with both " and ' in it which will probably confuses the perl engine/;
If you have / characters occuring in your string, use some other delimiter (e.g ~ or !) -- basically, just pick some non-whitespace, non-alphanumeric character that doesn't occur in your string. If there is no such character, then you'll have to escape any characters that match your delimiter (i.e. if you use " as a delimiter you must replace all occurences of " in the string with ", or if you use / you'd have to replace it with /).

One note is that if you're not interpolating variables in that string, you should use single quotes or the q// operator, as that doesn't attempt to do any variable interpolation and so runs a lot faster. If you don't entirely understand what I'm talking about, run:
perldoc perlop
and go to the section entitled:
Quote and Quote-like Operators

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > perl var issue


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway