morning guys and gals,
I am haveing a problem, a friend helped me out with this script but i dont know how to add incrementing number for each movie in movie.list. this is what i have so far. any assistance would be great.
I have removed the GT and LT symbols so you can see what is going on in the array.
#! /usr/bin/perl -w
use strict;
my $src_list = 'movie.list';
open SRC, $src_list or die "Couldn't read $src_list: $!\n";
my @movies = sort <SRC>;
my $dst_list = 'dvd-list.html';
open(HTML, "> $dst_list") or die "Can't write to $dst_list: $!\n";
print HTML "
my basic html goes here";
for (@movies) {
# The order here needs to be fixed.
my ($title, $run_time, $mpaa_rating, $genre, $prod_company) = split ':', $_;
print HTML "tr";
# Make sure we get no undef vars.
print HTML "td $_ /td"
for map {$_ || ''} $title, $run_time, $mpaa_rating, $genre, $prod_company;
print HTML "/tr\n";
}
print HTML "/table
/html";
Is this what you are wanting to do?
#! /usr/bin/perl -w
use strict;
my $src_list = 'movie.list';
open SRC, $src_list or die "Couldn't read $src_list: $!\n";
my @movies = sort ;
my $dst_list = 'dvd-list.html';
open(HTML, "> $dst_list") or die "Can't write to $dst_list: $!\n";
print HTML "
my basic html goes here";
# Add variable to display "Current Record Number"
my $movieCount = 1;
for (@movies) {
# The order here needs to be fixed.
my ($title, $run_time, $mpaa_rating, $genre, $prod_company) = split ':', $_;
print HTML "tr";
# Make sure we get no undef vars.
print HTML "td $_ /td"
for map {$_ || ''} $movieCount $title, $run_time, $mpaa_rating, $genre, $prod_company;
print HTML "/tr\n";
# Increment $movieCount by one with each display
$movieCount++;
}
print HTML "/table
/html";
Notice that all I did was add the $movieCount variable declaration above the `for (@movies` line and added a post-fix increment to the $movieCount variable after the `for map` line so that after each loop and display, $movieCount will increment.
If not, please let me know.
i think that will work.
in the end on the webpage there should be a number next to the movie so i dont have to manualy count how manyy i have.
Ooooohhh.
Then try this:
#! /usr/bin/perl -w
use strict;
my $src_list = 'movie.list';
open SRC, $src_list or die "Couldn't read $src_list: $!\n";
my @movies = sort ;
my $dst_list = 'dvd-list.html';
open(HTML, "> $dst_list") or die "Can't write to $dst_list: $!\n";
print HTML "
my basic html goes here";
# Add variable to display "Current Record Number"
my $movieCount = 1;
for (@movies) {
# The order here needs to be fixed.
my ($title, $run_time, $mpaa_rating, $genre, $prod_company) = split ':', $_;
print HTML "tr";
# Make sure we get no undef vars.
print HTML "td $_ /td"
for map {$_ || ''} $movieCount $title, $run_time, $mpaa_rating, $genre, $prod_company;
print HTML "/tr\n";
# Increment $movieCount by one with each display
$movieCount++;
}
$movieCount--;
print HTML "(br)(b) There are $movieCount movies in the library.(/b)\n";
print HTML "/table
/html";
input:
leo:30
stt:25
tony:31
code:
open SFH,"<staff.txt" or die "Can not open file";
open HFH,">staff.html" or die "Can not open file";
print HFH "<HTML>\n";
while(<SFH>){
print HFH "<member",$.,">\n";
my ($name,$age)= split ":",$_;
$age=~ tr/\n//d;
print HFH "<name> ",$name," </name>\n";
print HFH "<age> ",$age, "</age>\n";
print HFH "</member",$.,">\n";
}
print HFH "</HTML>\n";
close(HFH);
close(SFH);
output:
<HTML>
<member1>
<name> leo </name>
<age> 30</age>
</member1>
<member2>
<name> stt </name>
<age> 25</age>
</member2>
<member3>
<name> tony </name>
<age> 31</age>
</member3>
</HTML>
are you for real? Another ancient thread dug up.
01-08-2002