Hi monks,
I have discovered a strange bug. I need to do a secure HTTP transaction (HTTPS) with the LWP::UserAgent. This is the code (https://www.guy.com is just an example):
#!/usr/bin/perl use strict; use LWP::UserAgent; { ##The Perl Module that does the work my $ua = new LWP::UserAgent(); ##The URL my $url = "https://www.guy.com/"; ##Creating the request my $req = new HTTP::Request ('GET',$url); ##Getting the HTML page my $res = $ua->request($req); ##Printing the HTML page print $res->content."\n"; }
When I run this from the command line (./demo_https) it works (doesn't fetch anything, but doesn't crash). However, when I run it using the "perl command" (perl demo_https), I get that most hated of all errors: "Segmentation fault". I also get this error when using a private Perl path, and not /usr/bin/perl.
I have to admit that I work on a few different servers, and I only get this error on one of them, so a lot of you guys might not be able to reconstruct the bug. Also, I am using a relatively old version of LWP::UserAgent (because its what the customers have).
Has anyone seen this type of error before, and has any idea what I can do about it?
Thanks,
Guy (mrguy123)

Update: In answer to some of the (very useful) replies, using newer and better tools (like WWW::Mechanize) would be the ideal suggestion, but unfortunately this also has to work for customers that don't have these tools.

In reply to HTTPS transactions with LWP::UserAgent by mrguy123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.