fellow monks,

I've noticed an issue running a script on different platforms. The following script, with perl 5.8.8 built for i386-freebsd-64int, runs without issue.

use strict; use XML::Simple qw(:strict); use LWP::UserAgent; use Data::Dumper; use POSIX qw(strftime); getNVD(); sub getNVD { my $ua = LWP::UserAgent->new; $ua->agent( "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/200 +70309 Firefox/2.0.0.3" ); my $req = HTTP::Request->new( GET => 'http://nvd.nist.gov/download/nvdcve-recent.xml' ); $req->content_type('application/x-www-form-urlencoded'); my $res = $ua->request($req); my $fetch; if ( $res->is_success ) { $fetch = $res->content; } else { print $res->status_line; } my $today = strftime( "%Y-%m-%d", localtime ); my $yesterday = strftime( "%Y-%m-%d", localtime( time - 86400 ) ); my $xml = new XML::Simple; my $data = $xml->XMLin( "$fetch", KeyAttr => { cve => 'entry' }, ForceArray => [ 'cve', 'ref' ] ); my $e; foreach $e ( @{ $data->{entry} } ) { if ( $e->{severity} =~ /High/ && $e->{modified} =~ /($today|$yesterday)/ ) { print $e->{name}; } } #print Data::Dumper->Dump([\$data]); }
However the same code, when run on perl 5.8.8 built for MSWin32-x86-multi-thread, produces the following error:
Use of uninitialized value in pattern match (m//) at test.pl line 45.
There appears to be an issue with the following section:
if ( $e->{severity} =~ /High/ && $e->{modified} =~ /($today|$yesterday)/ ) {
Removing the references to $e->{severity} and $e->{modified} produce the same result. I should also note that the data across each platform when using Data::Dumper appears to be identical. Any thoughts on what may be causing this error?

cheers.


In reply to possible cross platform issue by semio

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.