http://qs321.pair.com?node_id=413760

Theo has asked for the wisdom of the Perl Monks concerning the following question:

I have some alumni data from which I need to extract useful info. To that end I'm trying to go from the native (pseudo)XML file to a key/value hash.
Before stripping out the excess XML tags the @info array has the full record of one person, a sample of which is in Listing 1. Listing 2 is printed by the code segment shown and the error message is below that.
I've preloaded %data hash just to be sure I can see if there are any changes in the hash.
I'd like to know what the error means, but the real question is how to transform an array into a hash.
The nature of this data is that the keys will all be unique.
(code being tested on a Win98 PC using Active State version 5.005_03)

########### Code Segment ############## my %data = (one => 1, two => 2, three => 3); : # XML stripped off here : print @info; # Prints Listing 2 print %data; # bottom of listing 2 %data = @info =~ /(\w+)\s*(\w+)/g; # Line that gives error print %data; # Prints nothing ####################################### ### Listing 1 ### <Position> Stdnt</Position> <GradYear> 1987</GradYear> <WebPage> http://</WebPage> <E-mail> SomeAddr@abc.com</E-mail> <Comments> Needs highschool yearbooks</Comments> ### Listing 2 ### Position Stdnt GradYear 1987 WebPage http:// Email SomeAddr@abc.com Comments Needs highschool yearbooks three3two2one1 ### Error message ### Applying pattern match to @array will act on scalar(@array) at e.pl li +ne 29

Due to the embedded spaces in some of the data, a better approach might be to strip the XML and create the hash in the same step, but not till I can get through this problem.

Update: Thank you Zaxo, saintmike and ysth. I'm still recovering from the first bout of flu I've had in 20 years and not thinking clearly. I'll put this to use in a few days. Again, thanks!

-Theo-      (so many nodes and so little time ... )