[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: netpbm vs. pbmplus



On Thu, 25 Jan 1996 Dirk.Eddelbuettel@qed.econ.queensu.ca wrote:

>   Craig> Which lines are the directories?  What algorithm do you use to
>   Craig> identify them?
> 
> Nothing that a little perl couldn't do:
> ---------------------------------------------------------------------------
> #!/usr/bin/perl --	# hey Emacs, this is -*-Perl-*-
> # 
> foreach	$i (0 .. $#ARGV) {
>     $package = `dpkg -L $ARGV[$i]` || die ("Can't call dpkg, quitting");
>     @files = split(/\n/,$package);
>     for $file (@files) {
> 	print "$file\n" unless -d $file;
>     }
> } 
> ---------------------------------------------------------------------------

perfect, thank you.

An elegant solution to the question.

(isn't perl wonderful :-)

a variation which prints out the names of only the executables is:


---cut here---
#!/usr/bin/perl --    # hey Emacs, this is -*-Perl-*-
# 
foreach   $i (0 .. $#ARGV) {
    $package = `dpkg -L $ARGV[$i]` || die ("Can't call dpkg, quitting");
    @files = split(/\n/,$package);
    for $file (@files) {
    print "$file\n" if -x $file && ! -d $file;
    }
} 
---cut here---


Craig

--
  cas@muffin.pronet.com                                cas@muffin.apana.org.au
   *       Unix Consulting:  Installation, Configuration, & Support.        *
   * --- Also, contact me if you need your Dos/Win/OS2 LAN connected to --- *
   * --- the Internet.                                                  --- *



Reply to: