It looks very likely hippo's solution will solve your GLOB error but there are 2 further issues to be aware of. When you add use strict you may encounter the error

Can't use an undefined value as an ARRAY reference at ...

on this line.

my $size = @{$data->{User}};

This might occur on the last request when no more records are in the response. A fix would be

my $size = @{$data->{User} || []};

The other error with XML::Simple is more subtle and will only appear it there is one record in the response. In this case the error would be

Not an ARRAY reference at ...

The fix is to use ForceArray on the User element

my $xml = new XML::Simple(ForceArray => ['User']);

Example with strict

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use LWP::Protocol::https; use XML::Simple; use Time::Piece; my $ua = LWP::UserAgent->new(ssl_opts => { SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE, verify_hostname => 0, }); my $xml = new XML::Simple(ForceArray => ['User']); # Get Unity subscriber data from cucxnpub one page at a time # 2000 records to a page my $url = "https://cucxnpub/vmrest/users?rowsPerPage=2000"; my $userName = 'user'; my $passwd = 'password'; my $page = 1; my @userdata; while(1){ my $req = HTTP::Request->new(GET => $url."&pageNumber=$page"); $req->authorization_basic($userName,$passwd); $req->content_type('application/xml'); my $response = $ua->request($req); unless ( $response->is_success ){ die $response->status_line; } my $content = $response->decoded_content; my $data = $xml->XMLin($content); my $size = @{ $data->{User} || [] }; print "Page $page : $size\n"; # If we don't get at least one user end the loop last if ( $size == 0 ); # Build the userdata array, each entry contains "username,extension" for my $user ( @{$data->{User}} ){ push @userdata,"$user->{Alias},$user->{DtmfAccessId}"; } ++$page; } # Create a timestamp containing year, month, and day my $timestamp = localtime->ymd(''); # Dump the results of the unity query to a file my $dir = '/usr/scripts/unityLDAP/'; my $outfile = $dir."$timestamp-unity.csv"; open UNITY,'>',$outfile or die "Could not open $outfile : $!"; print UNITY "$_\n" for @userdata; close UNITY; printf "%d records written to %s\n",scalar @userdata,$outfile;
poj

In reply to Re: Script stopped working... by poj
in thread Script stopped working... by gentoobob

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.