"Shishir K. Singh" wrote:
> >
> > I was just wondering if there is anything similar
> > in perl for unix commands pushd / popd  ??
> 
> > pushd and popd are built-in shell commands, they aren't really "Unix"
> >commands.  What exactly are you trying to do?
> 
> >perldoc -f push
> >perldoc -f pop
> >perldoc -f shift
> >perldoc -f unshift
> >perldoc -f splice
> 
> I have this awfully old shell script that used lots of pushd
> and popd and I need to convert it to perl. I will have to
> settle with push and pop and cwd for the time being. Thanks
> anyways !!


Here is a very simple implementation (no error checking.)  Stick it at
the top of your program so that the prototypes will work.

{
use Cwd;
my @stack = cwd;

sub dirs () {
    print "@stack\n";
    }
sub pushd ($) {
    unshift @stack, shift;
    dirs;
    }
sub popd () {
    @stack > 1 and shift @stack;
    dirs;
    }
}



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to