473,789 Members | 2,773 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making URLS/E-Mails Into Links

Hello,

I'm outputting data from a flat-file into the browser, and I'd like to
output the URLs and E-Mails in link form.

The code now is simply this:
while (<FILE>) {
print "$_";
print "<br>";
}

How would I enhance this to make links out of e-mail addresses and URLs?
I'd appreciate any help.

Thanks!
Corey Martin
Jul 19 '05 #1
3 1746
JC
How 'bout this inside your while() loop?

if(m/\@/) {
print "<a href='mailto:$_ '>$_</a>";
}
elsif(m/http/) {
print "<a href='$_'>$_</a>";
}

-jc
Corey Martin wrote:
Hello,

I'm outputting data from a flat-file into the browser, and I'd like to
output the URLs and E-Mails in link form.

The code now is simply this:
while (<FILE>) {
print "$_";
print "<br>";
}

How would I enhance this to make links out of e-mail addresses and URLs?
I'd appreciate any help.

Thanks!
Corey Martin


Jul 19 '05 #2
JC
One more thing to consider doing is chopping each line of the file.
-jc
How 'bout this inside your while() loop?

if(m/\@/) {
print "<a href='mailto:$_ '>$_</a>";
}
elsif(m/http/) {
print "<a href='$_'>$_</a>";
}

-jc


Jul 19 '05 #3
Thanks!

"JC" <jw*********@ve rizon.net> wrote in message
news:f2******** *******@nwrdny0 3.gnilink.net.. .
One more thing to consider doing is chopping each line of the file.
-jc
How 'bout this inside your while() loop?

if(m/\@/) {
print "<a href='mailto:$_ '>$_</a>";
}
elsif(m/http/) {
print "<a href='$_'>$_</a>";
}

-jc

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3426
by: phpkid | last post by:
Howdy I've been given conflicting answers about search engines picking up urls like: http://mysite.com/index.php?var1=1&var2=2&var3=3 Do search engines pick up these urls? I've been considering converting a site of mine to PHP-Nuke, but if the individual modules aren't picked up in search engines I'm not going to do it. Thanks phpKid
26
12597
by: Howard Brazee | last post by:
I would like to click on a URL of a html document that will open several URLs at once for me. Does someone have an example of a html document that will do this?
7
8319
by: AES | last post by:
Encountered a URL containing a comma the other day -- the first time I've ever noticed that, so far as I can recall. It worked fine, however, and I gather commas are legal in URLs. Out of curiosity, did a quick scan of an ASCII file of the 542 URLs in my personal bookmark file and discovered exactly 3 that contained commas (two with a single comma, one with three commas) -- so I guess they're pretty rarely used, even if legal. Seems...
10
1946
by: david | last post by:
Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign a column of URLs to this hyperlink column in programming way (ie., dynamically assignment). However, I can not find a way to continue doing it. Do you have ideas about it? Thanks.
2
1356
by: laredotornado | last post by:
Hello, I want to take a block of text and add html tags to make hyperlinks where hyperlink strings exist. So, if I have a variable $a = "This is http://www.yahoo.com" I would like to run that through a function such that the value of $a is
4
4603
by: rzimerman | last post by:
I'm hoping to write a program that will read any number of urls from stdin (1 per line), download them, and process them. So far my script (below) works well for small numbers of urls. However, it does not scale to more than 200 urls or so, because it issues HTTP requests for all of the urls simultaneously, and terminates after 25 seconds. Ideally, I'd like this script to download at most 50 pages in parallel, and to time out if and only...
10
4939
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're called, an example of what I have in mind is index.php?page=). However, I can not figure out how to do this. I will eventually want to use SEF urls, but for now I'll be content just to have the dynamic urls. If anyone can tell me how to do this, I'd...
9
5101
by: Salve =?iso-8859-1?Q?H=E5kedal?= | last post by:
What is the best regular expression for finding urls in plain text files? (By urls I mean http://www.something.com, but also www.something.com, or salve@somewhere.com) Salve
3
3875
by: WebCM | last post by:
How to apply nice URL-s into CMS? 1. Should we use nice urls for every page? 2. Do we need to put a FULL path into <a href="">? 3. What is faster and better? a) 10 rules in .htaccess which redirect you to normal URLs with GET parameters
4
4871
by: Guy Macon | last post by:
As a personal learning experience with limited practical use, I have been doing some experiments with using .htaccess to redirect mis-typed URLs to a preferred canonical form. I have set up a test page at http://www.guymacon.org/test.html ] to show the results of my testing. Most of the URLs redirect as I want them to do, but the three URLS (with "//" instead of "/") in bold do not redirect. I have searched the web and have not...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3703
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.