"John W. Krahn" wrote: > > "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 !! > > [snip]
Sorry, I forgot to change to the directory being pushed. :-) This should work a lot better. { use Cwd; my @stack = cwd; sub dirs () { print "@stack\n"; } sub pushd ($) { unless ( chdir $_[0] ) { warn "Error: $!"; return; } unshift @stack, cwd; dirs; } sub popd () { @stack > 1 and shift @stack; chdir $stack[0]; dirs; } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]