SPUG: RE: Simple program - gone wrong

Parr, Ryan Ryan.Parr at wwireless.com
Mon Jul 8 23:58:49 CDT 2002


If all you want are HTML files files from the parent directory just do this:

open(RDIR,">output.txt") or die "Couldn't open output.txt for writing: $!";
my $count = 0;
foreach (<../*.htm?>) {
	printf RDIR "% 5d | %s\n",++$count,$_;
}

If you just want any file:

open(RDIR,">output.txt") or die "Couldn't open output.txt for writing: $!";
my $count = 0;
foreach (<../*>) {
	printf RDIR "% 5d | %s\n",++$count,$_;
}

But perhaps what would be better is to do:

find .. -maxdepth 1 -type f -name "*.htm?" > output.txt 

from the command line, but I may not be catching the full of your dilemma.

-- Ryan Parr

"I hate quotations." -- Ralph Waldo Emerson


-----Original Message-----
From: Sweethomes [mailto:sweetsue at sweethomes.com] 
Sent: Monday, July 08, 2002 11:45 AM
To: spug-list at pm.org
Subject: RE: SPUG: RE: Simple program - gone wrong


Ok, this almost works.  The numbering doesn't seem right.  What it's doing
is listing all files as it should but the first set is all marked with "0",
then it repeats the file listing each with "1" in front of it.  This repeats
to "100" at which point it stops.  I need it to number each file like so:

1 | index.html
2 | black_line.gif
3 | counter.php
4 | counter.txt
5 | formmail.php
6 | logo.gif
7 | favicon.ico
8 | help.html
9 | main.html

etc.  From here I can figure out how to filter out the .txt and the .gif
etal leaving the .html files only.

Thanks - you guys are great!

Susanne

-----Original Message-----
From: owner-spug-list at pm.org [mailto:owner-spug-list at pm.org]On Behalf Of
Chris Wilkes
Sent: Monday, July 08, 2002 11:02 AM
To: spug-list at pm.org
Subject: Re: SPUG: RE: Simple program - gone wrong


On Mon, Jul 08, 2002 at 10:47:38AM -0700, Chris Wilkes wrote:
>   for my $num (0..100) {
>     foreach (@files) {
>       print RDIR, "$num | $_\n";
>     }
>   }

Arg there shouldn't be a comma in there.  Should just be:
	print RDIR "$num | $_\n";

Chris

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list