Results 1 to 2 of 2

Thread: [RESOLVED] Capture Value from System Command in Perl

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    367

    Resolved [RESOLVED] Capture Value from System Command in Perl

    I'm new to the whole Perl, Unix, PHP thing, so bear with me, please.

    Using the below code i'm basically trying to find the size of the file and store that value into $sret. However, it doesn't seem to be working. What am I doing wrong?

    $sret = system("wc -c $path/GA_1_"."$fcnt.txt");
    Last edited by lilmark; Dec 11th, 2012 at 03:30 PM.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    367

    Re: Capture Value from System Command in Perl

    Found some online sources that said to use the backtick to get the return value, but I still couldn't get it to work. However, I cam across another solution.

    @arr = stat "$path/GA_1_"."$fcnt.txt";
    $n_bytes=$arr[7];
    print "n_bytes is $n_bytes";

    This returns the size of the file 1 byte into $n_bytes indicating to me that the file is blank.
    Now, I can run the next line of code that drops the file now that I know it is empty.

Posting Permissions

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



Click Here to Expand Forum to Full Width