Using Perl to Convert Hyperlinks and Filenames to Lowercase
Using Perl to Convert Hyperlinks and Filenames to Lowercase
Like a lot of web developers, I’m not always that disciplined when it comes to the file naming convention I use and I sometimes end up with a situation whereby I have some files that are in lowercase, some that begin with a capital, and some that are a bit of a mixture.
One web site I maintain contains about 2000 web pages and has about 20,000 hyperlinks. As you can imagine, I had one of those sinking feelings when I was told that in order to migrate the web site to a new content management system, all the file names and hyperlinks would need to be changed to lowercase.
Whenever I am presented with a problem like this, my instinct is always to write a Perl script using one or more regular expressions to solve the problem. This particular situation was no exception.
Change a string to lowercase
The following regular expression changes all the characters in a string to lowercase. The first part of the regular expression finds a hyperlink, and the second part converts the string. (Just in case this article is not displayed correctly, there should be a single backslash in front of the ‘L’).
1. $ line =~ s/<a target=”_new” rel=”nofollow” rel=”nofollow” onclick=”javascript:_gaq.push(['_trackPageview', '/outgoing/article_exit_link']);” href=”http://pertamax.cz.cc/browse.php?u=Oi8vZXppbmVhcnRpY2xlcy5jb20vKC4qPyk=&b=13″ _mce_rel=”nofollow” onclick=”javascript:_gaq.push(['_trackPageview', '/outgoing/article_exit_link']);” href=”http://pertamax.cz.cc/browse.php?u=Oi8vZXppbmVhcnRpY2xlcy5jb20vKC4qPyk=&b=13″> <b>Change a filename to lowercase</b> Likewise, changing a filename itself is very simple. The following two lines perform the task quite nicely: <xmp> 1. use File::Copy; 2. move (“$ name”, “L$ name”);
(Again, there should be a single backslash in front of the ‘L$ name’.)
If you need more information on how to incorporate the above code snippets into a complete script, feel free to contact me directly.
Now Pay Close Attention –
Using Video Testimonials to increase your websites sales and revenue is simpler than you’ve been told. Everyone with a website faces the same two problems:
[Problem #1] How To Build Credibility With Potential Customers
[Problem #2] How To Obtain Testimonials Which Have Been Proven To Improve Sales
Fast Video Testimonials has been solving these two problems for hundreds of satisfied customers. Fast Video Testimonials has been tried and tested and known to produce excellent results.
First: Click Here For Fast Video Testimonials
Fast Video Testimonials always supplies REAL VIDEO TESTIMONIALS created specifically for your website and business.
Second: Order Your Video Testimonials Package of 1, 5 or 10 original Video Testimonials for your website.
Your new Video Testimonials will arrive within 7 days and all Video Testimonials are done by REAL PEOPLE and are guaranteed to boost your sales by up to 30%. Buy Video Testimonials today and boost your businesses online presence overnight.
With an instant increase in sales by up to 30% Video Testimonials are the most effective way to improve your business. But to take advantage of this amazing tool, it is always a good idea to get a head start on your competition and Buy Video Testimonials. Visit http://www.FastVideoTestimonials.com Today!
Article from articlesbase.com
Incoming search terms:
- how to convert to lowercase using regular expression in perl
- javascript reg expression to convert string to lowercase
Related posts:
- How To Quickly Use Perl Scripts In Windows
- How to run a perl script in another perl script??
- Web Client Programming with Perl: Automating Tasks on the Web (A Nutshell handbook)
- I need help installing PF1, a point and figure charting application written in Perl. Can anyone help me ?
- need help with perl scripting?

Leave a Reply