pattern match
Anonymous Monk
created: 2006-01-29 21:09:36
Hi , I am new to perl and have to write some code for Monday deadline. Could you please help with how to match pattern which looks like this DATA1DATA2DATA3DATA4DATA5DATA6DATA6DATA7 Now the columns of DATA values keep changing. So thats the reason I am having a hard time to come up with a pattern that matches the above. But the only thing thats common is the begining of the syntac ie
Re: pattern match
created: 2006-01-29 21:31:02
So where exactly are you getting stuck with this?
What have you tried so far?

This seems like almost the same question that was asked here. Did you also ask that question?
If the replies didn't help, then please say so rather than starting a complete new thread.

Re: pattern match
created: 2006-01-29 21:34:14

[mod://XML::twig] is probably your best bet for doing this sort of stuff with XML or XHTML.

If you have trouble getting going with XML::twig tell us in a little more detail just what you want to be able to do. My guess is that you actually want to extract some of that data, but you don't actually say that. The following may get you started:

use strict;
use warnings;
use XML::Twig;

my $t= XML::Twig->new (twig_roots => {'Data' => \&extract});
$t->parse (do {local $/; ()});


sub extract 
{
my ($t, $data) = @_;
$data->print;
print "\n";
}

__DATA__

DATA1
DATA2
DATA3
DATA4
DATA5
DATA6
DATA6
DATA7

Prints:

DATA1
DATA2
DATA3
DATA4
DATA5
DATA6
DATA6
DATA7

DWIM is Perl's answer to Gödel

perlmonks.org content © perlmonks.org and Anonymous Monk, GrandFather, McDarren

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03