use strict; use warnings; my $DeviceFileName=""; my $device=""; my $company=""; my $autoconfig=""; my $interface=""; my $amiga=""; my $date=""; my $title=""; my $point=""; my $format=""; my $SFS=""; my $FileInDirectory=0; my $z=0; my @dump; my $directory="test"; ########################### ### DirectoryFileSearch ### ########################### if (substr($directory, -1,1) ne "\\") { $directory = "$directory" . "\\"; } # Instead of using open, opendir takes all files with in a # directory and places them inside an array: @FileInDirectory opendir(DIR, $directory) or die "Cannot open $directory"; my @FileInDirectory; @FileInDirectory = readdir DIR; close(DIR); # removes '.' and '..' from the array. For file systems without # these objects, comment out the following line. splice(@FileInDirectory,0,2); print @FileInDirectory; ##################################################### ### Reads files one file at a time into the array ### ### Each line is processed ne at a time. ### ##################################################### foreach $FileInDirectory(@FileInDirectory) { my $FilePath=""; $FilePath = "$directory" . "$FileInDirectory[$z]"; print "\n\nFile path: $FilePath \n"; push (@dump, "\n\n"); open (SINGLE, $FilePath) or die "Cannot open '$FilePath'"; while () { $SFS = $_; ########################################################## ## Process each each line. Parse required information ## ## and place into scalars used to create new HTML file. ## ########################################################## ########################################################## ## Captures device name and creates filename for output ## ########################################################## if ( $SFS =~ m:(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $device =~ tr/""//d; # removes double quotes print $device; $DeviceFileName = $device; $DeviceFileName =~ s/[^a-zA-Z0-9]//g; #removes all spaces & special characters print $DeviceFileName; } ########################### ## Captures company name ## ########################### if ( $SFS =~ m:(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $company =~ tr/""//d; # removes double quotes } ################### ## Captures Date ## ################### if ( $SFS =~ m:Date(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $date =~ tr/""//d; # removes double quotes } ########################### ## Captures amiga models ## ########################### if ( $SFS =~ m:Amiga(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $amiga =~ tr/""//d; # removes double quotes } ######################## ## Captures interface ## ######################## if ( $SFS =~ m:Interface(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $interface =~ tr/""//d; # removes double quotes } ######################### ## Captures autoconfig ## ######################### if ( $SFS =~ m:Autoconfig(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $autoconfig =~ tr/""//d; # removes double quotes } my $word =0; my $line =0; my $char = 0; ##################################################### ## HTML main script informaiton with some scalars. ## ## Date, company and other info in $HTML2 ## ##################################################### my $HTML1=' '. $device .' :: RetroGameAndComputer.com
Image
image
image
image


'; ############################################## ## All date header information starts here. ## ## List information is part of $HTML3. ## ############################################## my $HTML2 ='

HOME>> Peripherals >> Amiga >> Storage >> '. $device .'

Amiga Storage Peripherals


'. $device .'

> Company: '. $company .'
> Date: '. $date .'
> Amiga: '. $amiga .'
> Interface: '. $interface .'
> Autoconfig ID: '. $autoconfig .'



'; if ($SFS =~ m:
    (.*?):g) { $title = $1; $title = $title . "\n"; $title =~ s/<[^>]*>//g; # removes all characters between <> including <> $title =~ s/\b(\w)/\u$1/g; chomp $title; $format = "
      ".$title."\n"; $title = $format; print $title; push (@dump, $title); # print OUTPUT $title; } if ( $SFS =~ m:
    • (.*?)$:g ) { # looks for ]*>//g; # removes all characters between <> including <> $point =~ s/\b(\w)/\u$1/g; # Capitalises first word $format = "
    • ".$point."\n"; $point = $format; chomp $point; push (@dump, $point); # print OUTPUT $point; print $point; } open OUTPUT, ">$DeviceFileName.php" or die "Cannot open $DeviceFileName"; print OUTPUT $HTML1.$HTML2; print OUTPUT @dump; print OUTPUT "
    "; close OUTPUT; } close SINGLE; $z = $z +1; }