Making URLS/E-Mails Into Links

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Corey Martin

    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


  • JC

    #2
    Re: Making URLS/E-Mails Into Links

    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:
    [color=blue]
    > 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
    >
    >[/color]

    Comment

    • JC

      #3
      Re: Making URLS/E-Mails Into Links

      One more thing to consider doing is chopping each line of the file.
      -jc
      [color=blue]
      > How 'bout this inside your while() loop?
      >
      > if(m/\@/) {
      > print "<a href='mailto:$_ '>$_</a>";
      > }
      > elsif(m/http/) {
      > print "<a href='$_'>$_</a>";
      > }
      >
      > -jc[/color]

      Comment

      • Corey Martin

        #4
        Re: Making URLS/E-Mails Into Links

        Thanks!

        "JC" <jwcorpening@ve rizon.net> wrote in message
        news:f2ncc.513$ 1y1.498@nwrdny0 3.gnilink.net.. .[color=blue]
        > One more thing to consider doing is chopping each line of the file.
        > -jc
        >[color=green]
        > > How 'bout this inside your while() loop?
        > >
        > > if(m/\@/) {
        > > print "<a href='mailto:$_ '>$_</a>";
        > > }
        > > elsif(m/http/) {
        > > print "<a href='$_'>$_</a>";
        > > }
        > >
        > > -jc[/color]
        >[/color]


        Comment

        Working...