mrityunjaynath has asked for the wisdom of the Perl Monks concerning the following question:
this code makes me enter to directory of my choice and fro m config text read a value and then copies subdirectory and use the values read from config in new specified file in new created directroy . each time i run i get new directroy created but not the values in specified file. each time warning comes as use of uninitialized value $readline in string ne at newperlfile2.pl line 67,<CFILE> line3 use of uninitialized value $cSubVersId in concatenation (.) or string at newperlfile2.pl line 72 also the values read from config file is not present in the file in newly created directory...please help
#! C:/perl/bin/perl.exe use strict; use warnings; use File::Copy; use File::Basename; use Cwd; my $fullpath = cwd(); my $value = 0; opendir(my $pathindex, $fullpath ) or die "Couldn't read index : $!\n" +; while (my $currentfile = readdir($pathindex)) { print "current directory project $value\t"; print "$currentfile","\n"; $value++; } my $file = basename($fullpath); my $dir = dirname($fullpath); print "enter the project name with forward slash\n"; my $projectdir = <STDIN>; chop($projectdir); my $projectdirpath = "/"."$projectdir"; my $workingdirectory = ($fullpath.$projectdirpath); if(chdir($workingdirectory."/trunk")) { my $newpath = cwd(); } my $newpath = cwd(); my @searchfiles = ("rtl", "vhdl"); my $source_dirrtl; opendir(my $index, $newpath ) or die "Couldn't read index : $!\n"; while (my $file = readdir($index)) { print "$file","\n"; if ($file eq "rtl" ) { if(chdir($newpath."/rtl")) { my $currentworkingdir = cwd(); print "path = $currentworkingdir \n " ; $source_dirrtl = $currentworkingdir; } last; } elsif ($file eq "vhdl") { if(chdir($newpath."/vhdl")) { my $currentworkingdir = cwd(); print "path = $currentworkingdir \n " ; $source_dirrtl = $currentworkingdir; } last; } } my @words; my $readline; my $cChipId; my $cSubVersId; if(open (CFILE,"config.txt" ) || die $! ) { $readline = <CFILE>; while ($readline ne "") { @words = split(/\b[0-9][0-9][0-9][0-9]\b/,$readline); $readline = <CFILE>; } $cChipId = $words[0]; $cSubVersId = $words[1]; print "$cChipId \n"; print "$cSubVersId \n"; } #print("enter the chip id and subversion id \n"); #my $cChipId = <STDIN>; #my $cSubVersId = <STDIN>; #chop( $cChipId); #chop( $cSubVersId); my $source_dirsim = ("$newpath"."/sim"); my $source_dirsynth = ("$newpath"."/synth"); my $target_dirrtl1 = ("$newpath"."/rtl2"); my $target_dirsim1 = ("$newpath"."/sim2"); my $target_dirsynth1 = ("$newpath"."/synth2"); mkdir($target_dirrtl1,0777); mkdir($target_dirsim1,0777); mkdir($target_dirsynth1,0777); opendir(my $DIRRTL1, $source_dirrtl) || die "can't opendir $source_dir +rtl: $!"; opendir(my $DIRSIM1,$source_dirsim) || die "can't opendir $source_dirs +im: $!"; opendir(my $DIRSYNTH1,$source_dirsynth) || die "can't opendir $source_ +dirsynth: $!"; my @filesrtl1 = readdir($DIRRTL1); foreach my $t (@filesrtl1) { if(-f "$source_dirrtl/$t") { copy "$source_dirrtl/$t","$target_dirrtl1/$t"; } } my @filessim1 = readdir($DIRSIM1); foreach my $t (@filessim1) { if(-f "$source_dirsim/$t") { copy "$source_dirsim/$t","$target_dirsim1/$t"; } } my @filessynth1 = readdir($DIRSYNTH1); foreach my $t (@filessynth1) { if(-f "$source_dirsynth/$t") { copy "$source_dirsynth/$t","$target_dirsynth1/$t"; } } chdir("$target_dirrtl1"); my $m4file = "$projectdir".".m4"; print "$m4file"; if(open(MYFILE,">>$m4file")) { print MYFILE ("define(`m4_cChipId',`16#$cChipId#,16')\n"); print MYFILE ("define(`m4_cSubVersId',`16#$cSubVersId#,16')\n"); print MYFILE ("define(`m4_$projectdir',`1')\n"); my $output1 = `test.bat`; }
|
|---|