|go ahead... be a heretic|
typo? variable misteriously becoming undefby scain (Curate)
|on Nov 14, 2002 at 19:54 UTC ( #212990=perlquestion: print w/replies, xml )||Need Help??|
scain has asked for the wisdom of the Perl Monks concerning the following question:
Hello Fellow Monks,
I return to coding after several months off and it seems like I have forgotten everything I ever knew. As a warmup project, I wanted to make a simple parser that would take free-form address data and generate V-card formatted data, with the help of user input. This was supposed to be an easy, one off script, that I have now been working on for a few hours.
Here is how it is suppposed to work: Read through a file one line at a time and present its contents at STDOUT. The user then selects an action, either to split the line on commas, thus breaking up a city and state for later categorization, or the user selects what category the item belongs in. After the user selects a category, the array that holds the data (possibly from a previous split) is shifted, and then it goes through the loop again. Seems straight forward enough. (As a side note: yes I really do want to do it this way, because it really is free-form: some addresses are typical, three or four lines, some are all mushed together in one line, comma delimited.)
But, when a file has this as its contents Medina, OH, and Medina is properly categorized as a city, and the shift is done, initially, $la holds "OH", but when it gets to the bottom of the loop, it is mysteriously undef. I don't see how or why, but I suspect that it is my rusty skills causing me to miss something. Please take a look at the code below and let me know what I am missing.
Back to Seekers of Perl Wisdom