de2425 has asked for the wisdom of the Perl Monks concerning the following question:
I am having an issue using split to count instances of a pattern. I was told that I could use the code below to do it but the only output that I'm getting is "-1-1-1-1-1-1-1-1-1-1". I know it's something simple that I'm doing wrong but I just can't see it. If anyone has a suggestion, I would greatly appreciate it.
open (IN, "c:/work/XML_Count/14.xml") || die "Cannot open 14.xml"; while (<IN>){ chomp; my @t=split(/mapping id="/,$_); print $#tt; } close IN;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Count Using Split
by Bloodnok (Vicar) on Sep 17, 2008 at 17:28 UTC | |
by de2425 (Sexton) on Sep 17, 2008 at 19:22 UTC | |
by toolic (Bishop) on Sep 18, 2008 at 00:20 UTC | |
|
Re: Count Using Split
by kyle (Abbot) on Sep 17, 2008 at 17:34 UTC | |
by de2425 (Sexton) on Sep 17, 2008 at 19:23 UTC | |
|
Re: Count Using Split
by jwkrahn (Abbot) on Sep 17, 2008 at 17:36 UTC | |
by jethro (Monsignor) on Sep 17, 2008 at 17:58 UTC | |
by jwkrahn (Abbot) on Sep 17, 2008 at 18:23 UTC | |
by ikegami (Patriarch) on Sep 17, 2008 at 19:07 UTC |