Fellow Monks,

I'm toying with Puppet (a Ruby-based system administration app), and interfacing with it is seemingly done via a REST API. It allows file transfers, format YAML, which do work, but Perl's module chokes on anything larger than 32K while I'd want to move a 4MB JPEG. I do realise that even if it worked, it would be loaded entirely in RAM, but let's suppose that wasteful manner is not an issue. The error I get is "Complex regular subexpression recursion limit (32766) exceeded at YAML/Loader.pm line 519" - why would it even try to apply a regex to the data? The spec simply says everything up to \n should just be swallowed in a string. Smaller files, binary or not, do work - is this an expected limitation of the format?

Sample:
use LWP::UserAgent; use YAML; my $ua = LWP::UserAgent->new; my $ah = HTTP::Headers->new; $ah->header('Accept' => 'yaml'); //required by puppet my $req = HTTP::Request->new('GET', 'https://localhost:8140/production +/file_content/test/afile.jpg', $ah); my $res = $ua->request($req); if(!$res->is_success) { die "Something went wrong: $res->status_line" +} else { my @a = YAML::Load($res->content."\n"); //puppet seems to forget add +ing that trailing newline open(HM, '>hm.jpg'); binmode HM; print HM $a[0]->{content}; }
Update: the "complex regex" part seems to be quite an old bug: https://bugzilla.redhat.com/show_bug.cgi?id=192400
still doesn't explain why the string data should be parsed as such

In reply to Load large(ish) files with YAML? by rgcosma

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.