Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.60 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. # Cause my parents brought me up that way...
  4. use strict;
  5.  
  6. # Put the filename that was passed as runtime into a variable.
  7. my $filein = shift;
  8.  
  9. # Open the file and read the contents in as a string.
  10. my $file_contents = open_s($filein);
  11.  
  12. # Do a search & replace regex on the contents of the file.
  13. $file_contents =~ s{<([^>]*?)>}{>$1<}gi;
  14. # Another regex to change them back.
  15. $file_contents =~ s{>([^>]*?)<}{<$1>}gi;
  16.  
  17. # Change the name of the file by running a search & replace regex on it's name.
  18. $filein =~ s{\.html}{_new\.html};
  19.  
  20. # Save the file.
  21. save_s($filein, $file_contents);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement