in reply to Help with regular expression
Hello, I have a similar soluttion mentioned here by simply substitutin all brackets with a whitespace then split everything by whitespaces.
#!/usr/bin/perl -w use strict; $ARGV[0] = "www.perlmonks.org.txt"; open FH, $ARGV[0] or die "Can`t open it: $!\n"; my @parsed = grep { s/[()]/ /igsx } <FH>; close FH; foreach (@parsed) { print $_, "\n"; } #some testing outputs my @vars=(); foreach (@parsed) { push @vars, split(" ", $_); } foreach (@vars) { print $_, "\n"; }
It just parsed them with the corresponding vars, but you may need more and more parsing for youur desires.
Tree structure will be a good solution for that task.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Help with regular expression
by choroba (Cardinal) on Oct 11, 2012 at 08:19 UTC | |
by heatblazer (Scribe) on Oct 12, 2012 at 14:27 UTC |
In Section
Seekers of Perl Wisdom