Results 1 to 1 of 1
  1. #1
    Join Date
    Nov 2013
    Posts
    1

    Unanswered: Storing the compilation error of perl program in a file

    Hi,
    I compile my code and i got some error. I want to store the error message in a file. For example right now i am getting following error:

    Code:
      
    D:\Zulfi\PERL MAIN FOLDER>perl filecompileoutput.pl 
    D:/Zulfi/dir1Can't locate object method "Bobaaaaaaaaaaaaaa" via package "Bobaaaa 
    aaaaaaaaaa" (perhaps you forgot to load "Bobaaaaaaaaaaaaaa"?) at D:/Zulfi/dir1/d 
    ata1.pl line 1.
    I want to store the error message:

    D:/Zulfi/dir1Can't locate object method "Bobaaaaaaaaaaaaaa" via package "Bobaaaa
    aaaaaaaaaa" (perhaps you forgot to load "Bobaaaaaaaaaaaaaa"?) at D:/Zulfi/dir1/d
    ata1.pl line 1.
    in a file.

    My code is and other information is listed below:
    Code:
    	
    D:\Zulfi\PERL MAIN FOLDER>type filecompileoutput.pl 
    #!C:/Perl64/bin/perl.exe 
    my $dirstr = 'D:/Zulfi/dir1'; 
    print $dirstr; 
     
    $fileName = $dirstr . "/data1.pl"; 
     
    mkdir $dirstr unless -d $existingdir; # Check if dir exists. If not create it. 
     
     
    open (MYFILE, ">$fileName"); 
    print MYFILE "Bobaaaaaaaaaaaaaa\n"; 
    print MYFILE "Bobaaaaaaaaaaaaaa\n"; 
    print MYFILE "Bobaaaaaaaaaaaaaa\n"; 
     close (MYFILE); 
     
    open (MYFILE, ">TestFile") || die "\n   Could not create write file.\n\n"; 
    print MYFILE `perl $fileName`; 
     
     
    close (MYFILE); 
     
     
    D:\Zulfi\PERL MAIN FOLDER>dir TestFile 
     Volume in drive D has no label. 
     Volume Serial Number is 8E4F-05BE 
     
     Directory of D:\Zulfi\PERL MAIN FOLDER 
     
    11/11/2013  08:35 PM                 0 TestFile 
                   1 File(s)              0 bytes 
                   0 Dir(s)  524,333,301,760 bytes free 
     
    D:\Zulfi\PERL MAIN FOLDER>cd .. 
     
    D:\Zulfi>cd dir1 
     
    D:\Zulfi\dir1>type data1.pl 
    Bobaaaaaaaaaaaaaa 
    Bobaaaaaaaaaaaaaa 
    Bobaaaaaaaaaaaaaa 
     
    D:\Zulfi\dir1>
    It shows that it has created the TestFile but its size is zero. This is my problem "How to store data in TestFile which is to store error messages generated during compiling a program using perl?"

    Kindly guide me.

    Zulfi.
    Last edited by zak100; 11-11-13 at 12:04.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •