Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert HTML (m etc.) to string

Status
Not open for further replies.

zackiv31

Programmer
May 25, 2006
148
US
I want to convert this string to it's equivalent as regular text. I'm not familiar with type conversion in Perl but I'm sure you guys know it off the top of your head. Hint, it's an e-mail address.

Code:
<a href="mailto:&#98;&#111;&#115;&#116;&#111;&#110;&#115;&#99;&#111;&#117;&#115;
&#101;&#114;&#115;&#64;&#109;&#115;&#110;&#46;&#99;&#111;&#109;?subject=$600%
20Wake%20up%20to%20the%20Ocean">&#98;&#111;&#115;&#116;&#111;&#110;&#115;&
#99;&#111;&#117;&#115;&#101;&#114;&#115;&#64;&#109;&#115;&#110;&#46;&#99;
&#111;&#109;</a>
 
Use HTML::Entities.

If it's just a once off though, you could just open it in a browser and then copy-paste the displayed result.
 
Or a regex to do the same:

Code:
[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]$data[/blue] = [url=http://perldoc.perl.org/functions/do.html][black][b]do[/b][/black][/url] [red]{[/red][url=http://perldoc.perl.org/functions/local.html][black][b]local[/b][/black][/url] [blue]$/[/blue][red];[/red] <DATA>[red]}[/red][red];[/red]

[blue]$data[/blue] =~ [red]s/[/red][purple]&#([purple][b]\d[/b][/purple]+);[/purple][red]/[/red][purple]chr [blue]$1[/blue][/purple][red]/[/red][red]eg[/red][red];[/red]

[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [blue]$data[/blue][red];[/red]

[teal]__DATA__[/teal]
[teal]<a href="mailto:&#98;&#111;&#115;&#116;&#111;&#110;&#115;&#99;&#111;&#117;&#115;&#101;&#114;&#115;&#64;&#109;&#115;&#110;&#46;&#99;&#111;&#109;?subject=$600%20Wake%20up%20to%20the%20Ocean">&#98;&#111;&#115;&#116;&#111;&#110;&#115;&#99;&#111;&#117;&#115;&#101;&#114;&#115;&#64;&#109;&#115;&#110;&#46;&#99;&#111;&#109;</a>[/teal]

- Miller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top