in reply to Re: Perl Script
in thread Perl Script

use IO::File; print "\n Comparing data:\n" ; my $outfile = "/project/ls1socdft/user/pooja/test_plan_checker/dfta/pe +rl/parse_xls/script/result.log"; open (OUTFILE, ">/project/ls1socdft/user/pooja/test_plan_checker/dfta/ +perl/parse_xls/script/result.log" ) or die "Cannot open $outfile for +writing \n"; print OUTFILE "Content of TPC file:.\n"; open(FILE, "<//project/ls1socdft_nobackup/rev2.0/user/Shah-B53654/dft/ +dfta/tpc/get_pat_info/output_0/report/report_all_wgl.pm") or die "Can +not open "; my @array = <FILE>; my @final_array; my @tp_array; my @handles; my $i=0; my $j=0; my %main_file ( foreach $_ (@array){ if($_ =~ /^$/ || $_=~ /return/ || $_=~ /RETURN/|| $_=~ /1;/) { } else{ $final_array[$i]=$_; print OUTFILE "$_"; } $i++; } foreach $_(@final_array){ $_=~ s/require//; $_=~s/[';]//g ; $tp_array[$j]=$_; print OUTFILE "$tp_array[$i] \n"; $j++; #my @new_array = @tp_array; my $fh = 0 ; foreach (@tp_array) { print "tp array : $_\n\n";} } # foreach (@tp_array) { # print "Checking file: $_\n"; # open my $fh, '<',$tp_array or die "$!\n"; #can we try smthng else??i mean ny othr idea? #} close(FILE);

Replies are listed 'Best First'.
Re^3: Perl Script
by Anonymous Monk on Apr 17, 2015 at 09:18 UTC
    Ok, some syntax errors , but which part of that is "calling files"?
      As u can see m using array concept so using it i am first opening the first file which has conent as above.Then substituting require and other things.Then give it to one array named tp_array.But now m not able to open it.As it has file name so it should open the file but it is not. So my this idea is not working so if possibl can u plss suggest any other idea.I have one idea of hash of hash.But not so sure.

        ...But now m not able to open it.As it has file name so it should open the file but it is not. ...

        So what is the error message that you get?

        Your filename probably has extra characters you haven't accounted for, you can figure it out if you examine your data by Data::Dump::dd()umpering to visualize your data (lesson courtesy of Basic debugging checklist and brian's Guide to Solving Any Perl Problem )

        This is how I'd start writing that, whatever it is

        #!/usr/bin/perl -- ## whateveritis.pl ## 2015-04-17-02:31:50 ## ## ## ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END " -otr -opr -ce +-nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while " -otr + -opr -ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while for " +-otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use Path::Tiny qw/ path /; Main( @ARGV ); exit( 0 ); sub Main { my $outfile = "/project/ls1socdft/user/pooja/test_plan_checker/dft +a/perl/parse_xls/script/result.log"; my $infile = "/project/ls1socdft_nobackup/rev2.0/user/Shah-B53654 +/dft/dfta/tpc/get_pat_info/output_0/report/report_all_wgl.pm"; my @final_array = SelectFinalFromInfile( $infile, $outfile ); SomethingElse( @final_array ); } ## end sub Main sub SelectFinalFromInfile { my( $infile, $outfile ) = @_; my $infh = path( $infile )->openr_raw; my $outfh = path( $outfile )->openrw_raw; my @final; while( <$infh> ) { next if m/^$/ or m/return/i or m/1;/; push @final, $_; print $outfh $_; } close $infh; close $outfh; return @final; } ## end sub SelectFinalFromInfile __END__
      Reply to 5th : Thankxx for your help.But while running m getting error: Undefined subroutine &main::path called at grep line 20. But we have defined it right?So i am not understanding reason of this error.
A reply falls below the community's threshold of quality. You may see it by logging in.