Hey all,
I'm trying to teach myself proper Perl parsing methods, but running into issues. Especially on this one.
I am trying to parse content from a website that is stored in $contents. I am specifically looking for a series of 6 digits. I have an array filled with 6 digit elements (example 990146). What I want to do is is parse the $contents variable line by line, and pull out the lines that contain that 6 digit number.
What functions/methods/routines should/can I use to do this?
EDIT: this is what I have so far:
Its output is:
I am quite confused on what's going on with this. Any help is greatly appreciated.
I'm trying to teach myself proper Perl parsing methods, but running into issues. Especially on this one.
I am trying to parse content from a website that is stored in $contents. I am specifically looking for a series of 6 digits. I have an array filled with 6 digit elements (example 990146). What I want to do is is parse the $contents variable line by line, and pull out the lines that contain that 6 digit number.
What functions/methods/routines should/can I use to do this?
EDIT: this is what I have so far:
Code:
145 sub ContentParser($$)
146 {
147 my @ContentArray = "";
148 my $content = $_[0];
149 my $model = $_[1];
150 while(<$_[0]>)
151 {
152 chomp($_[0]);
153 if($_[0] =~ /($model)/)
154 {
155 print "Item model is: $model\tItem is: $_\n";
156 }
157 }
158 }
Its output is:
Code:
Item model is: 991779 Item is: <!DOCTYPE
Item model is: 991779 Item is: html
Item model is: 991779 Item is: PUBLIC
Item model is: 991779 Item is: -//W3C//DTD XHTML 1.0 Transitional//EN
Item model is: 991779 Item is: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
Item model is: 991779 Item is: <html
Item model is: 991779 Item is: xmlns=http://www.w3.org/1999/xhtml>
Item model is: 991779 Item is: <head
^C
I am quite confused on what's going on with this. Any help is greatly appreciated.