If you can clean-up your data so the HTML tags disappear, then the following will work:
use Modern::Perl; use Data::Dump qw/dump/; my @books; { local $/ = "\n\n"; while (<DATA>) { my $book = Book::parse($_); push @books, $book if $book->{Title}; } } say dump( \@books ); package Book; sub parse { return {map { my ( $key, $value ) = split /:\s*/ } split /\n/, shi +ft}; } package main; __DATA__ Title: Perl and Cgi for the World Wide Web 2ND Edition Author: Castro, Elizabeth ISBN: 0201735687 ISBN13: 9780201735680 Binding: TRADE PAPER Class: USED Section: Computer Languages-Perl Price: 3.95 Location: 17 Item: 4 Condition: Standard Availability: 1 to 3 days Notes: Pub Date: 20100429 Title: Perl and Cgi for the World Wide Web 2ND Edition Author: Castro, Elizabeth ISBN: 0201735687 ISBN13: 9780201735680 Binding: TRADE PAPER Class: USED Section: General-General Price: 13.00 Location: 65 Item: 2 Condition: Standard Availability: 1 to 3 days Notes: Free ship: no Title: Perl and Cgi for the World Wide Web 2ND Edition Author: Castro, Elizabeth ISBN: 0201735687 ISBN13: 9780201735680 Binding: TRADE PAPER Class: USED Section: Computer Languages-Perl Price: 8.95 Location: 1 Item: 7 Condition: Standard Availability: 1 to 3 days Notes: Pub Date: 20100423

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

In reply to Re: Perl Module to parse text file by CountZero
in thread Perl Module to parse text file by Gary Yang

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.