Guest User

rename.pl

a guest
Oct 30th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. printf("this is a test\n");
  2.  
  3. # http://www.tutorialspoint.com/perl/perl_files.htm
  4.  
  5. #rename("one", "two"); I tested a basic rename would work and it did.
  6.  
  7. # This chunk creates a long file name. The concatenated string is
  8. # a short hand form, to save typing. The $b string variable, holds
  9. # a less than ten character string, so you can find out exactly how
  10. # many characters the file system will take. The "open" command tries
  11. # to create a file, and if the create operation fails, the program
  12. # exits.
  13.  
  14. $a = "0123456789";
  15.  
  16. $b = $a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a.$a ;
  17. $b = $b . "0.txt" ;
  18.  
  19. open(OUT, ">>$b") || die("Cannot create file");
  20. close(OUT);
  21.  
  22. # On my Win2K virtualpc test OS, I could get a total 259 character
  23. # path/filename. Same on Win10 (F:\259... Length of full file path is 259)
  24.  
  25. # This prints out the filename. I'm working relative to the
  26. # current working directory, so I glue the working directory name
  27. # to the filename I'm using.
  28.  
  29. use Cwd;
  30.  
  31. $c = getcwd ;
  32.  
  33. printf("%s/%s\n", $c , $b );
  34.  
  35. $c = $c . "/" . $b ;
  36.  
  37. printf("Length of full file path is %d\n", length $c );
  38.  
  39. # When the file can no longer be erased, I uncomment this
  40. # line and it renames the long filename, back to a ten character
  41. # file name, for easy deleting in Explorer. If I run the script
  42. # as is, the file name ends up as "0123456789". Place the # in
  43. # front of this line, to see the 259 character filename in the folder.
  44.  
  45. #rename( $b , $a );
  46.  
  47. exit(0);
Add Comment
Please, Sign In to add comment