Perl HTML TokeParser problem.

This script remove all HTML tags using HTML::TokeParser for perl. How do I save the output to disk?

This is the main dilemma that I am having. .. print write_1 ($t[1]);

Other then that this script works.

Code:
#!/usr/local/bin/perl
#  use strict;
   use warnings;
   use HTML::TokeParser;
########################
########################

my $parser = HTML::TokeParser->new('test.html') or die "fail - $!";

my $file1 = "_1.txt";

my $t = $t;      # strict issue
# ...............................
# ...............................
while($t = $parser->get_token)
{
  next  if(($t->[0] eq 'S'));

  if($t->[0] eq 'T')
  {
    print $t->[1];
  }
  else
  {
### print $t->[-1];
  }
}
#      close (new);
# .........................
# .........................
open (write_1, "> $file1");

print write_1 $t->[1];

      close (write_1);

exit(21);
 
Code:
open (write_1, "> $file1");     <---  <---  <---

while(my $t = $parser->get_token)
{
  next  if(($t->[0] eq 'E'));

  if($t->[0] eq 'T')
  {
  print write_1 $t->[1];         <---  <---  <---
  }
  else
  {
### print $t->[-1];
  }
}
# ....................
      close (write_1);
    exit ($parser);
exit(1);

SOLVE!
 
Back
Top