Howdy gents,

I used to be able to code fluently, but after a year in the military (so far) and recently only being able to code on windows machines, I'm left confused about many things like when I first started. Don't think that languages aren't perishible knowledge.

Anyhow, here's my code, it just grabs a image every few seconds and -tries- to write it to disk. The problem is that it doesn't write the image correctly. I compared the files and the differences are sooo tiny (one or two bytes difference) it looks like the file gets corrupted. No idea.

Any help, appreciated much! Again this is on win xp with uhh Activestate ActivePerl 5.8.0.

require HTTP::Request; require HTTP::Response; require LWP::UserAgent; while( 1 ) { $ua = LWP::UserAgent->new; $request = HTTP::Request->new( GET => "$url" ); $response = $ua->request( $request ); if ( $response->is_success ) { ( $sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst ) = localtime( time ); my $content_dump = ( ($year += 1900) . ".$mon.$hour.$min.$sec.jpg" + ); open( PICDUMP, ">$outputbase/$content_dump" ) || die( "Couldn't open $outputbase/$content_dump ($!)" ); print( PICDUMP $response->content ) || die( "Couldn't print to file ($!)" ); print( STDOUT "Wrote $content_dump\n" ); close( PICDUMP ); sleep 4; } else { print $response->error_as_HTML; } }

In reply to grabbing a image with HTTP module by Cat

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.