G'day Elwood1,
Welcome to the monastery.
You really should let Perl tell you what you've done wrong (or even questionably):
it's a lot quicker and far less effort than posting on a forum and waiting for someone to reply.
Here's some of the things you could have done with an indication of the feedback you would have got:
-
The warnings pragma would tell you about two problematic variables in your foreach loop.
-
The strict pragma would tell you about fifteen strict subs and two strict vars issues.
-
The autodie pragma would tell you about trying to write to a zero-length filename.
You could have also done this with a customised message as shown in the open documentation.
So, Perl would have reported all those issues if you'd added the following short code to the start of your script.
use strict;
use warnings;
use autodie;
Note that this is far less typing than what you wrote in this post and the feedback is immediate!
There's two other potential problems that I can see (that doesn't mean there isn't more).
Fixing the issues already highlighted may resolve these depending on how you rewrite your code; however, as the code currently stands:
-
open (FILEOUT, '>', $name); overwrites the file (given by $name) on each iteration of the foreach loop. Perhaps you want append mode (i.e. '>>' instead of '>') or you want to vary $name such that you're dealing with a different filename each time you go through the loop.
-
With @codes{@urls} = @status_codes;, you're assigning to keys with names like "ARRAY(0xffffffffffff)" (where ffffffffffff is some hexidecimal number).
I'm not entirely sure what you want here but "@codes{ map { $_->[3] } @urls } = @status_codes;" may be closer to the mark.
I concur with ww's comments.
A better question will get you better answers: guidelines for doing so are provided by "How do I post a question effectively?".
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.