dezboi has asked for the wisdom of the Perl Monks concerning the following question:
prod.pl<shelf> <product> <title>widget1</title> <cost>0.10</cost> <rating>B</rating> <color>red</color> <color>blue</color> <color>green</color> </product> <product> <title>widget2</title> <cost>0.25</cost> <rating>S</rating> <color>pink</color> <color>gray</color> <color>orange</color> </product> </shelf>
Outputuse XML::Simple; $file = XMLin('./prod.xml'); foreach $products (@{$file->{product}}) { print "Widget: " . $products->{title} ." \n"; print "Rating: " . $products->{rating} . "\n"; print " Cost: " . $products->{cost} . "\n"; print "Colors: " . $products->{color} . "\n\n"; }
Widget: widget1 Rating: B Cost: 0.10 Colors: ARRAY(0x19c5584) Widget: widget2 Rating: S Cost: 0.25 Colors: ARRAY(0x19c55f0)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl xml and array issue
by fisher (Priest) on Nov 18, 2010 at 15:36 UTC | |
by dezboi (Initiate) on Nov 18, 2010 at 15:40 UTC | |
by fisher (Priest) on Nov 18, 2010 at 15:53 UTC | |
|
Re: perl xml and array issue
by Anonymous Monk on Nov 18, 2010 at 15:33 UTC | |
|
Re: perl xml and array issue
by ikegami (Patriarch) on Nov 18, 2010 at 16:41 UTC | |
by dezboi (Initiate) on Nov 18, 2010 at 21:09 UTC | |
by ikegami (Patriarch) on Nov 18, 2010 at 21:59 UTC | |
by dezboi (Initiate) on Nov 18, 2010 at 22:14 UTC | |
by ikegami (Patriarch) on Nov 18, 2010 at 22:41 UTC | |
|
Re: perl xml and array issue
by fisher (Priest) on Nov 18, 2010 at 15:39 UTC | |
|
Re: perl xml and array issue
by locked_user sundialsvc4 (Abbot) on Nov 18, 2010 at 16:59 UTC | |
by ikegami (Patriarch) on Nov 18, 2010 at 22:06 UTC |