Sample RPF file
.\embark.c-046870;circuitPLF.flf;//server/tools/xp/files/plf/src/embark.c - # : 13
.\idle.cpp-051200;circuitPLF.flf;//server/tools/xp/files/plf/src/idle.cpp - # : 14
.\load.c-059070;circuitPLF.flf;//server/tools/xp/files/plf/src/load.c - # : 17
####
#!/usr/bin/perl -w
use strict;
use warnings;
use Data::Dumper;
use Cwd;
#$root_dir = getcwd;
my %Hash_filenames=();
my %Hash_filematches=();
my $plf;
opendir(DIR, "$start_dir");
my @plf_files = grep(/\.plf$/,readdir(DIR));
# @files =
#$start_dir = "C\:\\Program Files";
#my @plf_files = glob("$start_dir\/*.plf");
print "PLF FILES\n";
print "@plf_files\n";
#open my $match, '<',"$start_dir\\$plf_files[0]" or die "could not open file' $!";
foreach my $plf (@plf_files) {
chomp($plf);
open my $match, '<',"$start_dir\\$plf" or die "could not open '$plf' $!";
my @file_lines = <$match>;
$Hash_filenames{$plf}=\@file_lines;
}
closedir(DIR);
my $file = ;
open my $DATA, '<', $file or die "could not open '$file' $!";
my( %seen_file, %seen_vu);
while (my $line = <$DATA>){
(my $file_name) = $line =~ /
\\ #Match a backslash.
( #Capture the following match in $1.
[^\\]+? #Match anything not a backslash,
) #one or more times, non greedy.
; #Match a semicolon
/xmsg;
if ( ($file_name) and ( !$seen_file{$file_name}++ ) ) {
chomp($file_name);
#print "FILENAME $file_name\n";
foreach my $filename(keys %Hash_filenames) {
@{ $Hash_filematches{ $filename } } = grep( (/\/\Q$file_name\E#/i && !/\.plf/), @{ $Hash_filenames{ $filename } });------>this grep seems to be failing,
}#for loop end
}#if file_name end
close $DATA;
print "PRINTING MATCHED HASHES\n";
for my $key (keys %Hash_filematches) {
my $value = $Hash_filematches{$key};
if (scalar @$value) { # check that the arrayref isn't empty
print "KEY: $key\n";
print "VALUES: ", join(", ", @$value), "\n\n";
}
}
close $hash;
####
#my $start_dir;
#my $file_name = "load.c";
opendir(DIR, "$start_dir");
@plf_files = grep(/\.plf$/,readdir(DIR));
#@plf_files = glob($start_dir . '\\' . '*.plf');
print "PLF FILES\n";
print "@plf_files\n";
closedir(DIR);
foreach my $plf (@plf_files) {
chomp($plf);
open my $match, '<',"$start_dir\\$plf" or die "could not open '$plf' $!";
my @file_lines = <$match>;
$Hash_filenames{$plf}=\@file_lines;
}
open my $hash, '>', "hash.txt";
print $hash Dumper( \%Hash_filenames );
if ($file_name) {
foreach my $filename(keys %Hash_filenames) {
@{ $Hash_filematches{ $filename } } = grep( /\/\Q$file_name\E#/i, @{ $Hash_filenames{ $filename } });
}------> this grep passes
}
#print Dumper( \%Hash_filematches );
print "PRINTING MATCHED HASHES\n";
for my $key (keys %Hash_filematches) {
my $value = $Hash_filematches{$key};
if (scalar @$value) { # check that the arrayref isn't empty
print "KEY: $key\n";
print "VALUES: ", join(", ", @$value), "\n\n";
}
}