Perl System values to variables

In perl you can easily assign the system (“some commands”) values to variables using the  Capture::Tiny Module.

Step 1: Download the Capture::Tiny Module from cpan.

http://search.cpan.org/~dagolden/Capture-Tiny-0.20/lib/Capture/Tiny.pm

Step 2: Extract the downloaded file and go into that and run

perl Makefile.PL

make 

make run

make install 

commands to install.

Step 3:  Example program.

use strict;
use warnings;
BEGIN {required Capture::Tiny; }
my $out = Capture::Tiny::Capture {system ("commands");};
print "$out";

 

 

Thanks for reading this post…!!

please leave a command to improve the site……..!!!

Leave a Reply