On 07/03/2010 02:07 AM, Jozsi Avadkan wrote:
input: http://pastebin.com/raw.php?i=MqPXZwc3
output: http://pastebin.com/raw.php?i=8QCkp4yv
it will be a long day.. :D
could someone please help with it?
i have to make a "one liner" that get's the input, and gives the mentioned output.
Why a 'one liner'? That sounds an awful lot like homework...But I'll give you the benefit of the doubt. You can turn this Perl script into a one liner easily. Or you can just save it as a script and use it like:
./convert-to-html.pl < input_data.txt
#!/usr/bin/perl
use strict; use warnings;
my (%section_info, @section_list); while(<STDIN>) { s/^\s+//s; s/\s+$//; next unless ($_ ne ''); s/&/&/gs; s/</</gs; s/>/>/gs; s/"/"/gs; my ($dir,$file) = m#(^[^/]+)/(.+)$#; $file =~ s/.html$//i; push(@{$section_info{$dir}}, "<a href="$_">$file</a>"); push(@section_list, $dir); } foreach my $section (@section_list) { print "<br><font size=4>$section</font><br>\n"; print join(" |\n", @{$section_info{$section}}); print "\n<br>\n"; }