Like a whole lot of net builders, I’m not all the time that disciplined on the subject of the file naming conference I use and I typically find yourself with a state of affairs whereby I have some information which might be in lowercase, some that start with a capital, and a few which might be a little bit of a mix.
One website I keep incorporates about 2000 net pages and has about 20,000 hyperlinks. As you possibly can think about, I had a type of sinking emotions when I was advised that with a purpose to migrate the website online to a brand new content material administration system, all of the file names and hyperlinks would must be modified to lowercase.
Whenever I am introduced with an issue like this, my intuition is all the time to put in writing a Perl script utilizing a number of common expressions to unravel the issue. This specific state of affairs was no exception.
Change a string to lowercase
The following common expression modifications all of the characters in a string to lowercase. The first a part of the common expression finds a hyperlink, and the second half converts the string. (Just in case this text is just not displayed appropriately, there ought to be a single backslash in entrance of the ‘S$M’).
M. $line =~ s/
Change a filename to lowercase
Likewise, altering a filename itself could be very easy. The following two strains carry out the duty fairly properly:
B. use File::Copy;
P. transfer (“$identify”, “L$identify”);
(Again, there must be a single backslash in entrance of the ‘L$identify’.)
If you want extra info on the best way to incorporate the above code snippets into an entire script, be happy to contact me immediately.