Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Backticks 1.0.9

    Download button

    No screenshots available
    Downloads: 74  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Anthony Kilna | More programs
    Perl Artistic License / FREE
    September 22nd, 2012, 16:55 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Backticks description

    Use `backticks` like objects

    Backticks is a Perl module that turns backticks into full objects which you can query in interesting ways.

     use Backticks;

     my $results = `ls -a /`; # Assign a Backticks object to $results

     print $results->stdout; # Get the command's STDOUT
     print $results->stderr; # Get the command's STDERR
     print $results->success; # Will be true when the command exited clean
     print $results; # Get the command's STDOUT... the object
     # stringifies to the command's output so you
     # can use it most places you use normal
     # backticks


    You can have failed commands automatically die your perl script

     $Backticks::autodie = 1;
     `perl -e 'print STDERR "OUCH!\n"; exit 1'`;


    Which dies with the following message:

     Error executing `perl -e 'print STDERR "OUCH!\n"; exit 1'`:
     Failed with non-zero exit code 1
     Error output:
     OUCH!


    You can automatically chomp output:

     $Backticks::chomped = 1;
     my $chomped = `perl -e 'print "Hello!\n"'`;


    You can even access parameters instantly in object mode by calling methods immediately after the backticks!

     say `echo foo`->stdout; # Shows 'foo'
     say `perl -e 'print STDERR "Hello world!"'`->stderr; # Shows 'Hello world'
     say `perl -e 'exit 1'`->exitcode; # Shows '1'


    You can also use the classical perl object-oriented interface instead of using the backticks to create objects, the following command is the same as the first one above:

     my $results = Backticks->run("ls -la /");

    Alternately, you can create a command and run it later:

     my $command = Backticks->new("ls -la /");
     # ... do some stuff
     $command->run();


    Creating commands as an object affords you the opportunity to override Backticks package settings, by passing them as hash-style params:

     $Backticks::chomped = 0;
     my $chomped_out = Backticks->run(
     'echo "Hello there!"',
     'chomped' => 1,
     );



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    backticks objects | Perl module | Perl | backticks | objects

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM