Subversion Repositories wimsdev

Rev

Rev 9094 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #!/usr/bin/perl
  2. use strict "vars";
  3. use strict "subs";
  4. use warnings;
  5. use Text::Balanced qw (extract_bracketed extract_tagged);
  6. my $tag='test';
  7. my $file='test';
  8. my $out='.';
  9. while ($_ = shift (@ARGV))
  10. {
  11.   last if (!/^--/);
  12.   if (/^--file=(.*)$/) { $file = $1; }
  13.   elsif (/^--tag=(.*)$/) { $tag = $1; }
  14.   elsif (/^--out=(.*)$/) { $out = $1; }
  15.   else {
  16.     print STDERR "unknown option: $_\n" if (!/^--help$/);
  17.     #usage(); # includes --help !
  18.   }
  19. } ;
  20.  
  21. my $text; my $test=0;
  22. open(IN, "$file.html") ;
  23. while (<IN>){
  24.   next if !(/\<test\>/) && $test==0 ;
  25.   $test=1; $text .= $_;
  26.  
  27. }
  28. close IN;
  29. my @u=extract_tagged ($text ,"<$tag>","</$tag>");
  30. out("$out/$file",$u[0]);
  31.  
  32. sub out { my ($bloc, $text) = @_ ;
  33.   open  (OUT, ">$bloc") || warn "peut pas créer $bloc";
  34.   print OUT $text ; close OUT ;
  35. }
  36.  
  37.