develooper Front page | perl.perl5.porters | Postings from April 2000

Creating OO Interface to Shell.pm

From:
Casey R. Tweten
Date:
April 26, 2000 21:29
Subject:
Creating OO Interface to Shell.pm
Message ID:
Pine.OSF.4.10.10004262344000.11861-100000@home.kiski.net
I have added an OO interface to Shell.pm because, well, I wanted to :-)

I thought I would share this idea with the p5p since you are the listed
maintainers of Shell.pm.

I haven't busted old code (as far as I have tested) since the standard
interface exists in full force.

I think (perhaps it's just me) that:

my $sh = new Shell;
$sh->command();

is just so much more nice and neat and orderly and namespace conserving
than the standard method of useing Shell.pm.

I have attempted to update the 'documentation' so have a look.

Any other thoughts?

NAME
    Shell - run shell commands transparently within perl

SYNOPSIS
     use Shell;
     print perl( '-e', 'print "Just another Perl Hacker\n"' );

     use Shell;
     sub cat;
     print cat '< /etc/passwd';

     use Shell;
     my $sh = new Shell;
     print $sh->grep( qw{ wheel /etc/group } );

DESCRIPTION
  `SHELL'S MANY FACES

    Shell can be used in an OO manner or in the standard `AUTOLOAD'ED way,
    see above.

  ORIGINAL

      Date: Thu, 22 Sep 94 16:18:16 -0700
      Message-Id: <9409222318.AA17072@scalpel.netlabs.com>
      To: perl5-porters@isu.edu
      From: Larry Wall <lwall@scalpel.netlabs.com>
      Subject: a new module I just wrote

    Here's one that'll whack your mind a little out.

        #!/usr/bin/perl

        use Shell;

        $foo = echo("howdy", "<funny>", "world");
        print $foo;

        $passwd = cat("</etc/passwd");
        print $passwd;

        sub ps;
        print ps -ww;

        cp("/etc/passwd", "/tmp/passwd");

    That's maybe too gonzo. It actually exports an AUTOLOAD to the current
    package (and uncovered a bug in Beta 3, by the way). Maybe the usual
    usage should be

        use Shell qw(echo cat ps cp);

    Larry

AUTHOR
    Original: Larry Wall,

    OO Interface, use strict and general clean-up: Casey Tweten
    `crt@highvision.net'


-- 
print 'Casey R. Tweten';
my $sig = { mail => 'crt@kiski.net', 
            site => 'http://home.kiski.net/~crt' };
print "\n" . '.'x(length($sig->{site})) . "\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys %{$sig}







nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About