Posted By

page_lab on 07/11/12


Tagged

grep perl bbedit


Versions (?)

Replace number sequentially with grep


 / Published in: Perl
 

  1. #caso 1
  2. #================
  3.  
  4.  
  5. #!/usr/bin/perl -w
  6. $ii = 0;
  7. while(<>) {
  8. my $increment = $_;
  9. $increment =~ s/(href=\"\#n|\">|id=\"n)\d/$1.$ii++/e;
  10. print $increment;
  11. }
  12.  
  13. #caso 2
  14. #================
  15.  
  16.  
  17.  
  18. #!/usr/bin/perl -w
  19. $ii = 0;
  20. while(<>) {
  21. my $increment = $_;
  22. $increment =~ s/(<a class=\"note\" epub:type=\"noteref\" href=\"\#n\d+\">)\d/$1.$ii++/e;
  23. print $increment;
  24. }
  25.  
  26. #caso 3
  27. #================
  28.  
  29.  
  30. #!/usr/bin/perl -w
  31. $ii = 0;
  32. while(<>) {
  33. my $increment = $_;
  34. $increment =~ s/( id=\"n)\d/$1.$ii++/e;
  35. print $increment;
  36. }

Report this snippet  

You need to login to post a comment.