I have a huge XML file to parse. I was thinking that instead of parsing the whole file, I could ask the user to input a few options and then parse only that portion of the file. I was basically planning to do this
Enter option to be parsed
1. Fiction
2. History
3. Religion
10. Non fiction
So once the user enters the number 2, Book 2 will get selected and bunch of other options will be displayed as follows
Selected Book 2. Options are as follow
1. World History
2. American History
3. Oriental History
10. Indian History
Each option is nested differently with different levels. The plan is to use a switch statement on the returned $_ to display options for the next level. How do I navigate to a different part of the program and display options according to the genre selected. Thanks!
use strict;
use warnings;
use Switch;
my $level1;
print "Select options: \n 1 Fiction \n 2 History \n 3 Religion \n";
my $no = getIP('Enter a digit : ', /^\d/);
switch ($no) {
case 1 { $level1 = ?? }
case 2 { $level1 = ?? }
case 3 { $level1 = ?? }
else { $level1= ?? }
}
print $level1;
sub getIP {
print $_[0];
do {
$_ = <STDIN>; chomp;
} while ($_[1] && $_ !~ $_[1]);
return $_;
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.