473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to change a url to hyperlink?

Hi,

Thanks for reading this. I have searched all over the web but found no solution. How would one change a url to a hyperlink and email the hyperlink...I parsed through an html file to get this

Expand|Select|Wrap|Line Numbers
  1. </table><br><div><a class="red_link" href="http://dabcd123456:80/results/report.jsp?a=HGUYU&amp;b=HGUYU&amp;c=%2Fc%2B%2Btest%2F&amp;id=%3Ademd140149%3A1193283688721.html%2BDefault%2Bsmith%3A">TCM report &gt;&gt;&gt;</a></div><br><table width="95%" border="1" bordercolor="#999999" cellpadding="0" cellspacing="0">
  2.  
and I parse and got the url out:
"http://dabcd123456:80/results/report.jsp?a=HGUYU&amp;b=HGUYU&amp;c=%2Fc%2B%2Btes t%2F&amp;id=%3Ademd140149%3A1193283688721.html%2BD efault%2Bsmith%3A">

How can I change the url into a hyperlink and send that link in an email to someone?

Thanks,
Monkey
Oct 25 '07 #1
6 5418
numberwhun
3,509 Expert Mod 2GB
What have you tried thus far? Can you please share your code with us?

Regards,

Jeff
Oct 25 '07 #2
Hi,

I tried a bunch of stuff, but they don't work, so I deleted them already..this is the last thing I tried ##my $content = get $url; that doesn't work either. I also tried the string replacement, but that's too cumbersome and if the url changes it would be no good! $text =~ s[($RE{URI}{HTTP})] doesn't work
This is what I have so far that works in extracting the URL

Expand|Select|Wrap|Line Numbers
  1.  my($File) = @_;
  2.   open(STDIN, $File) || die("Could not open file!");
  3.   while(<STDIN>){
  4.      my($data)=$_;
  5.      ##print "$data \n";
  6.      if ($data =~ m/(http.*).+report/i ){
  7.         ##print "$1 \n"
  8.      }   
  9.  }
  10. close(STDIN);
  11.  
Please help!

Thanks,
Monkey
Oct 25 '07 #3
numberwhun
3,509 Expert Mod 2GB
Monkey,

In your original post and in the last post, I had to place the necessary code tags in your post. Please be sure, per the document in the link, to add them to all future code posting.

Regards,

Moderator
Oct 25 '07 #4
eWish
971 Expert 512MB
Would you please post some sample data from the file you are using? If you are getting a match into $1 and it contains only the url then you can do something like this.
Expand|Select|Wrap|Line Numbers
  1. my($File) = @_;
  2.   open(STDIN, $File) || die("Could not open file!");
  3.        while(my $data = <STDIN>){
  4.             if ($data =~ m/(http.*).+report/i ){
  5.                 my $link  = qq{<a href="$1">Click Me</a>};
  6.                   &send_email($link);  #Send $link as an arugement to a sub that will then include the $link in the body of the message.
  7.              }   
  8.          }
  9. close(STDIN);
  10.  
  11. sub send_email {
  12.  
  13.     my ($email_link) = @_;
  14.  
  15.     my $message_type = 'text/html';
  16.     my $from_email = 'From@someemail.com';
  17.     my $to_email = 'To@someemail.com';
  18.     my $subject = 'Requested Link';    
  19.     my $message = qq{Hello here is your link $email_link};
  20.  
  21.     #You can use any email module you wish.  Example given with Mime::Lite;
  22.     use Mime::Lite;
  23.  
  24.     my $msg = MIME::Lite->new(
  25.         From    => $from_email,
  26.         To        => $to_email,                
  27.         Subject => $subject,
  28.         Type    => $message_type,
  29.         Data    => $message
  30.     );
  31.  
  32.     $msg->send() || die "Couldn't send message:";
  33. }
Oct 26 '07 #5
Hi eWish,

Thank you for your response, this is what I need. Thanks so much. You save me hours =)

Monkey
Oct 29 '07 #6
eWish
971 Expert 512MB
Glad to hear it helped. :)
Oct 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gareth Clayton | last post by:
I have imported a title list from excel to an access database table and would like to know how to change the imported URL which is long and ugly into html hyperlink code with the title name as...
1
by: Robbo | last post by:
Hello, I created a datagrid with a few hyperlink columns.. How do i change the color of the hyperlink itself? BLUE is a bit bad on my datagrid color scheme. Thanks, Rob
0
by: Ryan Harvey | last post by:
Hi all, I have written a web user control that contains a repeater control. the ItemTemplate for this control is basically 6 Hyperlinks in a row, that are dynamically allocated one of 7 gif...
2
by: Imran Aziz | last post by:
Hello All, I want to change the size of my hyper lnks in a repeater control dynamially using the onItemBound event, as under, but cannot seem to understand how to alter the properties to do...
6
by: eswanson | last post by:
In jscript, I would like to be able to set the href attribute of the anchor element. I have a aspnet:hyperlink button on the page, but I would like to be able to set the href attribute of this...
1
by: Vear | last post by:
I have a gridview inside a content placeholder that has the first column as a hyperlink. I changed it from a Hyperlinkfield to a Template field so I could name the hyperlink control. I can't figure...
3
by: jarrett.roberts | last post by:
I am relatively new with C# and ASP.NET. I created an application using WinForms in which I have several hyperlinks. I want their position on the webpage to be determined (dynamically) based on...
0
by: =?Utf-8?B?Um9nZXI=?= | last post by:
In my app I would like to change the color of the hyperlink from blue to purple when a user clicks the hyperlink in a RichTextBox. The DetectUrls property is set to True and I handle the...
1
by: simonyong | last post by:
Hi, I have a hyperlinkbutton in my datagrid Initially, I set the text of the hyperlink button as "show" once user click it, i want it to change into "view more detail" I tried to change...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...

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.