Making URLS/E-Mails Into Links

Discussion in 'Perl' started by Corey Martin, Apr 5, 2004.

  1. Corey Martin

    Corey Martin Guest

    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
     
    Corey Martin, Apr 5, 2004
    #1
    1. Advertising

  2. Corey Martin

    JC Guest

    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
    >
    >
     
    JC, Apr 6, 2004
    #2
    1. Advertising

  3. Corey Martin

    JC Guest

    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
     
    JC, Apr 6, 2004
    #3
  4. Corey Martin

    Corey Martin Guest

    Thanks!

    "JC" <> wrote in message
    news:f2ncc.513$...
    > 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

    >
     
    Corey Martin, Apr 6, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kaidi
    Replies:
    5
    Views:
    512
    Andrew Thompson
    Jan 4, 2004
  2. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    781
    Sriram Srivatsan
    Aug 12, 2008
  3. Adam Monsen

    JDBC URLs ...not really URLs?

    Adam Monsen, Feb 6, 2009, in forum: Java
    Replies:
    11
    Views:
    6,394
    Adam Monsen
    Feb 8, 2009
  4. Steve T.

    dynamic URLS convert to static URLS for search engines

    Steve T., Mar 1, 2004, in forum: ASP .Net Web Services
    Replies:
    7
    Views:
    325
    Steve T.
    Mar 4, 2004
  5. Garrett Smith
    Replies:
    14
    Views:
    343
    David Mark
    May 26, 2009
Loading...

Share This Page