in reply to Re: Differentiating STDIN from arguments when using -n ?
in thread Differentiating STDIN from arguments when using -n ?
Thanks a lot. Indeed, with the BEGIN block, it now works.
In case someone is curious, I needed it in a shell script for a convoluted situation: to be able to un-mount a disk cleanly, I needed a smart sort on the mounted partitions of the disk.
# $dest was set to "sdb" through a shell argument mounted_disks=$(mount | perl -nae 'BEGIN{$d=shift}; push @m, $F[2] if +m{/dev/$d}; END{print join(" ", sort {length($b)<=>length($a)} @m)}' +$dest) umount -l $mounted_disks
Thanks to Perl and the Perl Monks, it works.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Differentiating STDIN from arguments when using -n ?
by jwkrahn (Abbot) on Sep 15, 2007 at 19:50 UTC | |
by rduke15 (Beadle) on Sep 16, 2007 at 07:57 UTC |