Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling backslash translation

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
IL
HI,

I have a code:

my $Controller =<<"EOH";
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\fff\Controler]
"SfidaLimoges"="SLCtrl"
"selectedDLL"="SLCtrl"
"DebugLevel"=dword:ffffffff
"DebugLevelMask"="BASE=0x01, PA=0x02, LL=0x04, DF=0x08, PDF=0x10, RES=0x20, CTRL=0x40"
"NtfyArrGr"="41"

EOH

Is there a way to get the above text into a variable whem the "\" is not interpreted but taken literaly ?
(Otherwise I have to convert all these to double backslashes...)
thanks


Long live king Moshiach !
 
my $var = q~blah\blah\blah\blah~;
or you can just use single quotes
my $var = 'blah\blah\blah\blah';


The ~'s in the first example can be anything you want (two ~'s, !'s, or anything really).




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Thanks,but this does not seem to work for multiple text lines:

my $Controller = '
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\fff\Controler]
"SfidaLimoges"="SLCtrl"
"selectedDLL"="SLCtrl"
"DebugLevel"=dword:ffffffff
"DebugLevelMask"="BASE=0x01, PA=0x02, LL=0x04, DF=0x08, PDF=0x10, RES=0x20, CTRL=0x40"
"NtfyArrGr"="41"
'

actualy gives error :

syntax error at D:\DOcuments\myscripts\tracesManager.pl line 281, near "open "
(Might be a runaway multi-line '' string starting on line 271)
Execution of D:\DOcuments\myscripts\tracesManager.pl aborted due to compilation errors.

Long live king Moshiach !
 
this
Code:
my $data = '
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\fff\Controler]
"SfidaLimoges"="SLCtrl"
"selectedDLL"="SLCtrl"
"DebugLevel"=dword:ffffffff
"DebugLevelMask"="BASE=0x01, PA=0x02, LL=0x04, DF=0x08, PDF=0x10, RES=0x20, CTRL=0x40"
"NtfyArrGr"="41"
';

print "$data\n";
works just fine


I noticed you do not have a ending semicolon in the line you pasted.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Just specify the quote context (single-quotish here).
>my $Controller =<<"EOH";
[tt]my $Controller =<<[highlight]'[/highlight]EOH[highlight]'[/highlight];[/tt]
 
I think though that the whole <<EOF style is depreciated. I could be wrong but since you have q and qq I don't know why anyone would do it that way.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top