Front page | perl.beginners |
Postings from December 2002
Perl and arrays
Thread Previous
|
Thread Next
From:
Johnstone, Colin
Date:
December 20, 2002 01:25
Subject:
Perl and arrays
Message ID:
1CE69FABC71E184C8991EBD0B31A9EE25ED9DE@fpfexch1.central.det.win
Gidday all,
I want to create an array and then remove elemnets one at a time and split on the comma.
I've tried this with no success..
#!/usr/bin/perl -w
print "Content-Type: text/html\n\n";
my @arrayStuff;
$arrayStuff[0] = "albu.htm,3.4.1.5.1,albu_menu.inc,albu.inc";
$arrayStuff[1] = "armi.php,3.4.1.5.2,armi_menu.inc,armi.inc";
$arrayStuff[2] = "bank.htm,3.4.1.5.3,bank_menu.inc,bank.inc";
$arrayStuff[3] = "bate.htm,3.4.1.5.4,bate_menu.inc,bate.inc";
my $fileName = "/web/schooled/www/skin.php";
my $outFilePath = "/web/schooled/www/hscdata2/";
if( ! -e $fileName){
print "Nothing to Work with!<br>";
}
else{
while( @arrayStuff ){
$element = shift( @arrayStuff )
@data = split( /\t/, $element);
my $outFileName = $data[0];
my $strPageId = $data[1];
my $pageMenu = $data[2];
my $pageContent = $data[3];
my $output = "";
open(IN, "<$fileName") or die("Cannot open: $!");
while( my $line = <IN>){
$line =~ s/<!-- pageId here -->/$strPageId/;
$line =~ s/<!-- menu here -->/<? include "$pageMenu.inc"; ?>/;
$line =~ s/<!-- content here -->/$pageContent/;
$output .= $line;
}
close(IN);
open(OUT, ">$outFilePath$outFileName");
print OUT ($output);
close(OUT);
print "Generating output file $outFileName<br/>";
}
The output I get is:-
Generating output file
Generating output file
Generating output file
Generating output file
Im used to working with PHP.
Any help appreciated, Thank You
Colin Johnstone
Thread Previous
|
Thread Next