LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-09-2010, 11:54 PM   #1
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
shell script help with HTML formatting (??)


I have a script that presents download link, but it shows download links in one line.How do I get it to show each link in its own line?

my $message_text =
join "\n",
map "<a href=\"$_->{download_link}\">$_->{download_link}</a>" ,

Any help, thanks
 
Old 01-10-2010, 04:43 AM   #2
stefansbv
LQ Newbie
 
Registered: May 2009
Distribution: Slackware
Posts: 17
Blog Entries: 1

Rep: Reputation: 9
It looks like a Perl script and you must post more of it to get help.
 
Old 01-10-2010, 06:18 AM   #3
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Original Poster
Rep: Reputation: 42
thats basically the jist of it...

# Send upload notifications to watching users.
my $message_text =
join "\n",
map "<a href=\"$_->{download_link}\">$_->{download_link}</a>" ,
@arr;

}


but that prints the download links in one line.

http://www.esese.com/323442 http://www.eseese.com/rrer4er4e

I need it to be in two lines.

http://www.esese.com/323442
http://www.esese.com/323442
 
Old 01-10-2010, 08:11 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Replace the "\n" with "<br>", html mostly ignores whitespace.
 
Old 01-10-2010, 08:37 AM   #5
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Original Poster
Rep: Reputation: 42
thank but it didnt work
# Send upload notifications to watching users.
my $message_text =
join "<br>",
 
Old 01-10-2010, 10:46 AM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081

Works for me:
Code:
#!/usr/bin/env perl -W
use strict;

my $link1 = {download_link => "aa"};
my $link2 = {download_link => "bb"};
my @arr = ( $link1, $link2 );
my $message_text =
join "<br>",
    (map ("<a href=\"$_->{download_link}\">$_->{download_link}</a>" ,
          @arr));

print($message_text . "\n");
The output is
Code:
<a href="aa">aa</a><br><a href="bb">bb</a>
which is two lines when viewed in Firefox.
 
Old 01-10-2010, 06:31 PM   #7
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Original Poster
Rep: Reputation: 42
my $message_text =
join "\n",
map "<a href=\"$_->{download_link}\">$_->{download_link}</a>" ,
@arr;

}

ist the code, you have 2 separate download links
my $link1 = {download_link => "aa"};
my $link2 = {download_link => "bb"};
and you join them, I only have one line
 
Old 01-10-2010, 08:27 PM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Then how does @arr get its value in your code? I don't know perl very well, what I posted was the only thing I could get to run without errors.
 
Old 01-12-2010, 08:04 AM   #9
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Original Poster
Rep: Reputation: 42
dont really know, cant program perl
 
Old 01-12-2010, 10:09 AM   #10
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by cbtshare View Post
my $message_text =
join "\n",
map "<a href=\"$_->{download_link}\">$_->{download_link}</a>" ,
@arr;

}

ist the code, you have 2 separate download links
my $link1 = {download_link => "aa"};
my $link2 = {download_link => "bb"};
and you join them, I only have one line
You need to show the rest of the code, so we can figure out what the value of @arr is. Or maybe a perl expert will be able to deduce it from what you've posted...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML Table Formatting Inbhir Pheofharain Programming 17 07-20-2009 03:02 PM
Formatting result file using Shell script athreyavc Programming 3 09-22-2008 05:57 AM
shell script with curl: HTML "post" giving me a headache Kropotkin Programming 4 05-06-2008 08:51 PM
Linux Shell Script to GET an HTML page repeatedly with an Interval vxc69 Programming 5 05-08-2007 09:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration