#=============================== # Adding a link record to the link database # Emmie P. Lewis, Perl/PHP Guide - About.com # http://perl.about.com # Created 04/30/01 # Last modified 04/30/11 #============================================== #use strict; #use DBI; use open qw( :encoding(UTF-8) :std ); #my $dbh; # the database handle #my $SQLCommand = "select GamePic1, GameTitle, GameDescription, GameDevice from gameinventory where GameDevice like 'zx spectrum' order by GameTitle;"; my $output = "hardwaredatabase.txt"; my $directory = "wwwindex"; #directory where index.html files are located my $device; my $deviceFileName; my $company; my $date; my $amiga; my $interface; my $autoconfig; my @TITLE; my $title; my $point; #Start Logic DirectoryFileSearch(); #Insert html into file DumpDB2File(); #==================== [ DumpDB2File ] ==================== sub DumpDB2File { } #==================== [ open_file ] ==================== sub OpenFile { open (OUTPUT, ">>$output") or die "Cannot open $output"; } #>-----------------------[ OpenDirectory ]------------------------< sub 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"; @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); &Engine; } sub Engine { foreach $FileInDirectory(@FileInDirectory) { $FilePath = "$directory" . "$FileInDirectory[$z]"; print "\n\nFile path: $FilePath \n"; open (SINGLE, $FilePath) or die "Cannot open $FilePath"; while () { $SFS = $_; &ExtractText; close OUTPUT; # if ($SFS =~ m/$string/) { # open (OUTPUT, ">>$output") or die "Cannot open $output"; # print OUTPUT "$FileInDirectory[$z]" . " - " . "$SFS"; # close OUTPUT; # } $word =0; $line =0; $char = 0; } close single; $z = $z +1; } } sub ExtractText { # open (OUTPUT, ">>$output") or die "Cannot open $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; } if ( $SFS =~ m:(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $company =~ tr/""//d; # removes double quotes } if ( $SFS =~ m:Date(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $date =~ tr/""//d; # removes double quotes } if ( $SFS =~ m:Amiga(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $amiga =~ tr/""//d; # removes double quotes } if ( $SFS =~ m:Interface(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $interface =~ tr/""//d; # removes double quotes } if ( $SFS =~ m:Autoconfig(.*?): ) { # looks for ]*>//g; # removes all characters between <> including <> $autoconfig =~ tr/""//d; # removes double quotes } while ($SFS =~ m: