Have you thought about using hashes? Wouldn't it be a little easier to manage? I once was very confused by them, and I still am depending on how complex the data is, but I know enough to get what I need done... done. I'll leave this here for you to examine :)
use strict; use warnings; use Data::Dumper; # $Data::Dumper::Terse = 1; my %library; #this is where we store title, author, date my $i = 1; #iterator for hash key name while (<DATA>) { my ( $title, $author, $date ) = split /\|/, $_; # the '|' just sep +erates records chomp($date); #because date has newline read from my example push @{ $library{ $i++ } }, $title, $author, $date; #put it in the + hash of arrays '%library' } foreach my $key ( sort { $a <=> $b } keys %library ) { #sort isnt nece +ssary but i put it there to give you an example print "Book #$key\n"; print "Title: @{$library{$key}}[0]\n"; print "Author: @{$library{$key}}[1]\n"; print "Date: @{$library{$key}}[2]\n\n"; } # use Data::Dumper to quickly verify data; # print Dumper %library; __DATA__ Beginning Perl|Simon Cozens|May 25, 2000 Modern Perl|Chromatic|2012 Impatient Perl|Greg London|Feb 7, 2004 Extreme Perl|Robert Nagler|2004 Embedding Perl in HTML with Mason|Dave Rolsky, Ken Williams|Oct 2002
If you want to try out this code, click the download link below and copy/paste.
Have fun learning!

In reply to Re: Iterate multiple arrays with added text by james28909
in thread Iterate multiple arrays with added text by Bman70

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.