-2

I am struggling with posting Perl data using LWP.

Here is my code

$req = POST $url, [
    SESSID => $sessid,
    csrf => $csrf,
    domainid => '1234567',
    type => 'A',
    default => '0',
    record-type => 'A',
    a-record%5B%5D => '12.12.12.12',
     aaaa-record => '',
     cname-record => ''
];

The code is obviously failing at a-record%5B%5D. How do I make this Perl compliant?

I already tried 'a-record%5B%5D' ; a-record\%5B\%5D ; a-record[] ; a-record\[\]; a-record\%5B\%5D

From my understanding, the field name of the form is indeed <input id="a0" class="left" type="text" value="11.11.11.11" name="a-record[]">

Alois Mahdal
  • 10,763
  • 7
  • 51
  • 69
sb0373
  • 11
  • 2
  • Good one Miguel. I just tried it but the form is still not accepted by the destination. Please let me point out (as I haven't done so before) that 'a-record%5B%5D' and 'a-record[]' do not throw errors on the perl side but the form does not seem to be accepted. So I am not sure if modifying it like that changes the actual name? – sb0373 Apr 01 '13 at 13:41
  • 1
    @sb0373 You are not using `use strict; use warnings;` are you? Because there are many errors in your assignment above. For example, `aaaa-record` is not a valid key name as a bareword, you need to quote it. http://stackoverflow.com/questions/8023959/why-use-strict-and-warnings – TLP Apr 01 '13 at 15:08

1 Answers1

2

You can't use anything but ordinary letters, underscore and digits on the left hand side, if you aren't quoting:

$req = POST $url, [
    SESSID           => $sessid,
    csrf             => $csrf,
    domainid         => '1234567',
    type             => 'A',
    default          => '0',
    'record-type'    => 'A',
    'a-record%5B%5D' => '12.12.12.12',
    'aaaa-record'    => '',
    'cname-record'   => ''
];

Now that was the syntax issues in the code.

Also, take a look at perlsyn for hints on how to format perl code.

mzedeler
  • 4,177
  • 4
  • 28
  • 41
  • Hello mzedeler, Thank you for your reply. It only threw a syntax error on the a-record line. Have a look at the actual form field name. So quoting with single quotes is a permitted way for the left hand side? Then my problem with the not-accepted POST from server side seems to be elsewhere. – sb0373 Apr 01 '13 at 14:04
  • If you wanted to post a field named ``a-record[]``, just replace ``a-record%5B%5D`` with ``a-record[]``. – mzedeler Apr 01 '13 at 14:07
  • 1
    I usually resort to http://www.wireshark.org/ when I can't figure out if the requests being sent are correct (compare with something you know is working). Its like shooting birds with GAU-8 cannons, but it works. – mzedeler Apr 01 '13 at 14:10
  • Hmm, good suggestion! Unfortunately there is SSL in between. I used Firefox + Tamper data to see a working request. Let me see if I can figure a way around SSL to see what perl is actually doing. – sb0373 Apr 01 '13 at 14:14
  • Dear mzedeler, I tried adding the single quotes around the objects that you mentioned. This made the request work. Is the reason, that perl did not throw an error message on the "-" because it is treating it as an arithmic operation? So if I would have put the left hand side name as 5-2, it is treated like 3? Overall, this is a place where I definetely did not look for the error. Thanks a lot! – sb0373 Apr 01 '13 at 14:36