in reply to Create a TXT record for DKIM using Net::DNS

Assuming you want the output to singly escape the semi-colons, thusly:

v=DKIM1\; k=rsa\; t=y\;p=MIGfMA0GCSqGSIb3DQAFG....

you don't need to interpolate anything other than the escape (slash). Try using single quotes in the assignments

my $a = ';';
my $b = "\\" . ';';

"A petty consistency..." would suggest single-quoting a single slash, too, but run with ActiveState (w32), strict and warnings, that fails.

Can't find string terminator "'" anywhere before EOF at 742623.pl line 8.

If you escape the slash (eg: <c>my $b = '\\' . ';';, Perl will not complain.

Replies are listed 'Best First'.
Re^2: Create a TXT record for DKIM using Net::DNS
by almut (Canon) on Feb 10, 2009 at 02:09 UTC

    '\' doesn't work because there has to be some way to escape a single quote in a single-quoted literal, which is done - as usual - using a backslash.

    BTW, I wouldn't know why using single quotes here should make a difference with respect to what the OP wants to achieve....

    (As to the OP's problem, my suspicion is that Net::DNS is doing some escaping on its own — though I haven't verified it.)

      I assume too, that Net::DNS is making "some" escaping itself, although http://www.net-dns.org/docs/Net/DNS/RR/TXT.html states: For some applications of the TXT RR the semicolon is relevant, you will need to escape it on input. If i don't do escaping on $txtdata, i get a FORMERR back from bind.