devxlogo

Create Hyperlinks in Perl Using a Regular Expression

Create Hyperlinks in Perl Using a Regular Expression

When outputting HTML, it’s often handy to be able to turn any URL, such as http://www.whatever.com, into a hyperlink, such as http://www.whatever.com.

You can do this with a regular expression in Perl:

 open (FILE, "myfile.txt");while () {	if (/http:/) {		s{(http:[^s]*)} {$1}gs;	}	print;} 

Any string in myfile.txt which contains http: will be turned into a hyperlink.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist