rsriram has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have several arrays in my script and if I want to execute my script using one array, on the command prompt, I will be executing the script with $ARGV[1] as the array name. I want to check if the tags (enclosed in < and >) are not outside what is mentioned in the array. I have a subroutine to check this as below.
sub validate_tag { my $arr1=$ARGV[1]; while($_ =~ /<(.+?)>/g) { $found=0; for my $x (0..$#arr1) { if($arr1[$x] eq $1){$found++} } if($found < 1){print "Invalid tag $1 found"} } }
$#arr1 is not returning the correct count of elements in the array. Could anyone help me on this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading a array
by davorg (Chancellor) on Aug 08, 2008 at 12:02 UTC | |
by Bloodnok (Vicar) on Aug 08, 2008 at 13:27 UTC | |
|
Re: Reading a array
by cdarke (Prior) on Aug 08, 2008 at 13:54 UTC | |
|
Re: Reading a array
by jethro (Monsignor) on Aug 08, 2008 at 12:56 UTC | |
|
Re: Reading a array
by swampyankee (Parson) on Aug 08, 2008 at 13:48 UTC | |
by jethro (Monsignor) on Aug 08, 2008 at 14:10 UTC | |
by swampyankee (Parson) on Aug 08, 2008 at 15:21 UTC | |
by jethro (Monsignor) on Aug 08, 2008 at 16:30 UTC |