#use strict; use constant SCRIPT_NAME => "patch_mapping.pl"; use constant SCRIPT_VERSION => "1.0.1"; #use Log4TA #Log_Info("USAGE: " . SCRIPT_NAME . , []"); #Log_SetOutDir("."); #Log_SetOutFile("log_patch_mapping.log"); my $ScrDIR = $ARGV[0]; my $FrameName = $ARGV[1]; my $out_dir = $ARGV[2]; my $frame; my $emptyFrame; my @added_frames; my $Count = 0; my $line; my @array; #-----Open source file------------------ my $FrameReport = $ScrDIR."\\test.txt"; #Source document: Frame report list my $fhR; open ($fhR, $FrameReport) or die "Unable to open the file $FrameReport\n"; #---------------------------------------- #-----add signal to mapping file-------- my $fhWrite = $out_dir."\\mapping".".txt";# Created document: mapping INCA Signal name - Internal signal name open ($out_dir, '>>', $fhWrite) or die "Unable to open the file $fhWrite\n"; #---------------------------------------- # check for valid input parameter if(! defined $FrameReport or ! -f $FrameReport) { Log_Error("No frame report file given!"); die; } if(!defined $FrameName) { Log_Error("No frame name given!"); die; } else { #$FrameName =~ s/^frame=//i; #@added_frames = split("[\,\;]",$FrameName); @added_frames = split(/,/,$FrameName); } if(defined $out_dir) { if(! -d $out_dir) { mkdir $out_dir; } } else { $out_dir = "."; } #my $read_state; #local $/ = q||; while ($line = <$fhR>) #As long as the file fhR contains data, we read the data { $Count++; foreach $frame(@added_frames) { if($line=~ /$frame/ .. $line =~ /^$/) { print"my frame: $frame\n"; print"my line: $Count\n"; if($line =~ /::::0x/ and $line =~ /\_FA,/ and $line =~ /\(/) { if($line =~ /FREI/ or $line =~ /ID2\)/) #ignore lines with "FREI" or "(ID2)" {} else { ( $_, $line) = split(/\(/,$line); #selects string after the opened bracket ( $_, $line) = split(/\)/,$line); #from the selected string, selects the one before the closed bracket @array = split(/, /,$line); print $out_dir $_, ";", "$array[1]\n"; #$countPar = $countPar +1; #count the number of mapping to } } } } #print"my total lines: $Count\n"; }