develooper Front page | perl.beginners | Postings from December 2002

Perl and arrays

Thread Previous | Thread Next
Johnstone, Colin
December 20, 2002 01:25
Perl and arrays
Message ID:
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,,,";
$arrayStuff[1] = "armi.php,,,";
$arrayStuff[2] = "bank.htm,,,";
$arrayStuff[3] = "bate.htm,,,";

my $fileName = "/web/schooled/www/skin.php";
my $outFilePath = "/web/schooled/www/hscdata2/";

if( ! -e $fileName){
 print "Nothing to Work with!<br>";

  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 "$"; ?>/;
      $line =~ s/<!-- content here -->/$pageContent/;
      $output .= $line;

    open(OUT, ">$outFilePath$outFileName");
    print OUT ($output);

    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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About