fork download
  1. #!/usr/bin/perl
  2.  
  3. $file = 'chapter1.txt';
  4. my ($chapnumber) = ($file =~/chapter(\d+).txt/);
  5.  
  6. while (<>)
  7. {
  8. ~s/\[(\d+)]/<a href="c${chapnumber}f$1.html">[$1]<\/a>/g;
  9. print $_;
  10. }
Success #stdin #stdout 0s 4596KB
stdin
abc [1] aba [5]
stdout
abc <a href="c1f1.html">[1]</a> aba <a href="c1f5.html">[5]</a>