Re: How does opendir/readdir process files

2015-01-15 Thread Brandon McCaig
On Thu, Jan 15, 2015 at 05:27:03PM -0500, Harry Putnam wrote: > Now I really have to ask what that even means. > > When Brandan said that to me... other than the RTFM it sailed > right over my head... so what does tl;dr mean? http://www.urbandictionary.com/define.php?term=tl%3Bdr Regards, --

Re: How does opendir/readdir process files

2015-01-15 Thread Shawn H Corey
On Thu, 15 Jan 2015 17:27:03 -0500 Harry Putnam wrote: > When Brandan said that to me... other than the RTFM it sailed right > over my head... so what does tl;dr mean? tl;dr == too long; didn't read -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail: beginners-unsubs

Re: How does opendir/readdir process files

2015-01-15 Thread Harry Putnam
John SJ Anderson writes: > On Tue, Jan 13, 2015 at 7:40 PM, Brandon McCaig wrote: >> Harry: >> >> (Expect typographical errors in such a long post...) >> >> tl;dr? RTFM. > Please don't tell people that. It's not helpful, it's not a helpful > attitude, and it's really not welcome here. > > The

Re: How does opendir/readdir process files

2015-01-14 Thread John SJ Anderson
On Tue, Jan 13, 2015 at 7:40 PM, Brandon McCaig wrote: > Harry: > > (Expect typographical errors in such a long post...) > > tl;dr? RTFM. Please don't tell people that. It's not helpful, it's not a helpful attitude, and it's really not welcome here. The rest of your post may be excellent, but I

Re: How does opendir/readdir process files

2015-01-14 Thread Shawn H Corey
grep { ! /^\./ && -f "$dir/$_" } readdir($dh); $a and $b are ARRAY references. The `stat` is the second element, at index 1. You could also sort by name when the mtimes are the same: sort { $a->[1] <=> $b->[1] || lc( $a->[0] )

Re: How does opendir/readdir process files

2015-01-13 Thread Brandon McCaig
On Tue, Jan 13, 2015 at 10:40:46PM -0500, Brandon McCaig wrote: > to spend some quality time with The Revelant Manuals (TFM). I cite this as proof that I am TFT (too fucking tired). I'm not going to confess how proud I was of this word play before I realized that it was completely nonsensical. -t

Re: How does opendir/readdir process files

2015-01-13 Thread Brandon McCaig
files = map { $_->[0] } > >sort { $a cmp $b } > >map {[$_, (stat("$dir/$_"))[9] ] } > > grep { ! /^\./ && -f "$dir/$_" } readdir($dh); > > my @files = map { $_->[0] } # What happene

Re: How does opendir/readdir process files

2015-01-13 Thread Charles DeRykus
> ... > I think the normal and original behavior is no reference. I think > they added the reference in 5.14 too. Perhaps the documentation > just fails to mention that support for arrays was added in 5.14 > along with references? Hopefully I got that right this time. :) > Ah, RTFM would've helped

Re: How does opendir/readdir process files

2015-01-13 Thread Brandon McCaig
Charles: On Fri, Jan 09, 2015 at 11:02:28AM -0800, Charles DeRykus wrote: > Definitely needs a 'use 5.014' if you want to dabble. You appear to be correct. Hmmm, I didn't figure that from the documentation. Either I read it wrong or it's not documented well. > Apparently undocumented that you

Re: How does opendir/readdir process files

2015-01-09 Thread Harry Putnam
map {[$_, (stat("$dir/$_"))[9] ] } >grep { ! /^\./ && -f "$dir/$_" } readdir($dh); my @files = map { $_->[0] } # What happened there? sort { $a cmp $b } # I now this sorts stuff, but not sure how or # what kind

Re: How does opendir/readdir process files

2015-01-09 Thread Charles DeRykus
On Fri, Jan 9, 2015 at 10:31 AM, Brandon McCaig wrote: > Charles: > > On Fri, Jan 9, 2015 at 12:46 PM, Charles DeRykus wrote: >> On Fri, Jan 9, 2015 at 3:39 AM, Dermot wrote: >>> I think John has answered your immediate question. >>> >>> ... >>> for (0..$#files) { >>> print "$_) $files[$_]\n

Re: How does opendir/readdir process files

2015-01-09 Thread Brandon McCaig
Charles: On Fri, Jan 9, 2015 at 12:46 PM, Charles DeRykus wrote: > On Fri, Jan 9, 2015 at 3:39 AM, Dermot wrote: >> I think John has answered your immediate question. >> >> ... >> for (0..$#files) { >> print "$_) $files[$_]\n"; >> } >> > > Alternatively (at least since 5.14) : > > > say "$k)

Re: How does opendir/readdir process files

2015-01-09 Thread Charles DeRykus
On Fri, Jan 9, 2015 at 3:39 AM, Dermot wrote: > I think John has answered your immediate question. > > ... > for (0..$#files) { > print "$_) $files[$_]\n"; > } > Alternatively (at least since 5.14) : say "$k) $v" while ($k,$v) = each @files; -- Charles DeRykus -- To unsubscribe, e-mail:

Re: How does opendir/readdir process files

2015-01-09 Thread Dermot
I think John has answered your immediate question. If you want to get the files back in a particular order you should include a sort between and grep readdir. An example might be my @files = sort { $a cmp $b } grep { ! /^\./ && -f "$dir/$_" } readdir($dh

Re: How does opendir/readdir process files

2015-01-08 Thread John SJ Anderson
On Thu, Jan 8, 2015 at 5:52 PM, Harry Putnam wrote: > Opening a directory and readdir with a grep in there to find specific > filenames, how does that process collect the files? See http://www.perlmonks.org/?node_id=533744 tl;dr: it depends on your OS. > I mean will the generated @ar

How does opendir/readdir process files

2015-01-08 Thread Harry Putnam
Opening a directory and readdir with a grep in there to find specific filenames, how does that process collect the files? I mean will the generated @ar of files be oldest first or someother reliable order? Using an example paraphrased from perldoc -f readdir: (I changed the regex) opendir(my

Re: Can you please Help perl readdir multiple folders and files with pre same name

2009-12-18 Thread Robert Wohlfarth
bookingspath") or die "cant open $bookingspath: $!\n"; > > while(defined(my $folder = readdir(DIR))) { > if ($folder eq '.') { next ; } > if ($folder eq '..') { next ; } > opendir(DIR_PHONE, "$bookingspath/$folder&quo

Re: Can you please Help perl readdir multiple folders and files with pre same name

2009-12-18 Thread Shlomi Fish
ath") or die "cant open $bookingspath: $!\n"; > > while(defined(my $folder = readdir(DIR))) { > if ($folder eq '.') { next ; } > if ($folder eq '..') { next ; } > > opendir(DIR_PHONE, "$bookingspath/$folder") or die &qu

Re: Can you please Help perl readdir multiple folders and files with pre same name

2009-12-18 Thread Simphiwe Mkhize
Here is my solution thank you for help .. &my_read_dms_booking_folders('c:/bookings') ; sub my_read_dms_booking_folders{ my ($bookingspath) = @_ ; opendir(DIR, "$bookingspath") or die "cant open $bookingspath: $!\n"; while(defined(my $folder =

Re: Can you please Help perl readdir multiple folders and files with pre same name

2009-12-17 Thread Shlomi Fish
_dir; You probably want: <<<<<< print $p_dir, "\n"; L>>>>> here instead. > opendir(DIR, "$p_dir") or die "cant open directory: $!\n"; > Use lexical dir-handles. Kudos for the or die. > while(defined($folder = readdir(D

Can you please Help perl readdir multiple folders and files with pre same name

2009-12-17 Thread Simphiwe Mkhize
{ #-- $p_dir="D:/43895" ; print $p_dir; opendir(DIR, "$p_dir") or die "cant open directory: $!\n"; while(defined($folder = readdir(DIR))) { if (length $folder > 5) { print $folder; } if

RE: readdir() question

2009-05-28 Thread Ajay Kumar
Sent: Monday, May 25, 2009 4:30 AM To: beginners@perl.org Subject: Re: readdir() question On Mon May 25 2009 @ 4:34, sanket vaidya wrote: > Hi all, > > > > Kindly look at the code below: > > > > use warnings; > > use strict; > > opendir(DIR, "D:\

Re: readdir() question

2009-05-25 Thread Telemachus
On Mon May 25 2009 @ 4:34, sanket vaidya wrote: > Hi all, > > > > Kindly look at the code below: > > > > use warnings; > > use strict; > > opendir(DIR, "D:\\test") || die "can't opendir: $!"

readdir() question

2009-05-25 Thread sanket vaidya
Hi all, Kindly look at the code below: use warnings; use strict; opendir(DIR, "D:\\test") || die "can't opendir: $!"; my @dots = readdir(DIR); print map{"$_.\n"}...@dots; .. ... Test1 Test2 Test3 Where Test1, Test2, Test3 are files wi

RE: about readdir call

2008-06-05 Thread Rajnikant
Subject: RE: about readdir call Rajnikant <[EMAIL PROTECTED]> asked: > I'm reading one directory using readdir call. but I'm getting > different output from that I got by running ls -l command on same > directory manually. Following is the snippet I'm using: &

RE: about readdir call

2008-06-05 Thread Thomas Bätzler
Rajnikant <[EMAIL PROTECTED]> asked: > I'm reading one directory using readdir call. but I'm getting > different output from that I got by running ls -l command on > same directory manually. Following is the snippet I'm using: > #!/usr/bin/perl -w $dir

about readdir call

2008-06-05 Thread Rajnikant
Hello everyone, I'm reading one directory using readdir call. but I'm getting different output from that I got by running ls -l command on same directory manually. Following is the snippet I'm using: #!/usr/bin/perl -w $dirname = "/test_dir"; opendir ( DIR, $dirname )

Re: Was `readdir [...]' Comments on JK's script

2007-12-04 Thread reader
John W.Krahn <[EMAIL PROTECTED]> writes: [...] >> I was reading lines with a while loop inside find() so used a `last' >> to break out of it. Perl gives a warning for that so I thought maybe >> it wasn't such a good idea... but finally resorted to sticking with >> the last and quieting the warni

Re: Was `readdir [...]' Comments on JK's script

2007-12-04 Thread John W . Krahn
On Monday 03 December 2007 18:00, [EMAIL PROTECTED] wrote: > > John W.Krahn <[EMAIL PROTECTED]> writes: > > > >> I thought it might be because File::Find cds to the target dir > >> then names like src dir or ./src ./dir fail. Just guessing > > > > OK, that's my mistake, as I said I didn't test it

Re: Was `readdir [...]' Comments on JK's script

2007-12-03 Thread reader
John W.Krahn <[EMAIL PROTECTED]> writes: >> I thought it might be because File::Find cds to the target dir then >> names like src dir or ./src ./dir fail. Just guessing > > OK, that's my mistake, as I said I didn't test it ... oops. :-) I guess you knew this from your smilie but to confirm ...

Re: Was `readdir [...]' Comments on JK's script

2007-12-03 Thread John W . Krahn
On Monday 03 December 2007 15:19, [EMAIL PROTECTED] wrote: > John W.Krahn <[EMAIL PROTECTED]> writes: > > On Monday 03 December 2007 10:34, [EMAIL PROTECTED] wrote: > >> John W.Krahn <[EMAIL PROTECTED]> writes: > >> > If you want to incorporate the grep into the perl program then > >> > this may wo

Re: Was `readdir [...]' Comments on JK's script

2007-12-03 Thread reader
John W.Krahn <[EMAIL PROTECTED]> writes: > On Monday 03 December 2007 10:34, [EMAIL PROTECTED] wrote: >> >> John W.Krahn <[EMAIL PROTECTED]> writes: >> > >> > If you want to incorporate the grep into the perl program then this >> > may work (UNTESTED): >> >> It works with 1 change and one caveat,

Re: Was `readdir [...]' Comments on JK's script

2007-12-03 Thread John W . Krahn
t to zero because this section > ## will eventually throw this error: > ## Use of uninitialized value in numeric lt (<) at ./Krahn.pl line 20 > ## if it isn't OK, change that line to: my ( $Num, $OldCnt ) = 0; > $Num = 0; > > ## ] > > { opendir my $dh, $TrgDir o

Was `readdir [...]' Comments on JK's script

2007-12-03 Thread reader
eventually throw this error: ## Use of uninitialized value in numeric lt (<) at ./Krahn.pl line 20 ## if it isn't $Num = 0; ## ] { opendir my $dh, $TrgDir or die "Cannot open '$TrgDir' $!"; while ( my $file = readdir $dh ) { next unless -f &

Re: readdir formulated badly? gives wrong count

2007-12-03 Thread reader
Rob Dixon <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] wrote: >> "Jeff Pang" <[EMAIL PROTECTED]> writes: >> >>> On Dec 3, 2007 10:12 AM, <[EMAIL PROTECTED]> wrote: >>> #!/usr/local/bin/perl -w use strict; use warnings; my @ar = (); for(@ar){ pr

Re: readdir formulated badly? gives wrong count

2007-12-03 Thread Matthew Whipple
[EMAIL PROTECTED] wrote: > "Jeff Pang" <[EMAIL PROTECTED]> writes: > > >> On Dec 3, 2007 12:51 PM, <[EMAIL PROTECTED]> wrote: >> >>> "Jeff Pang" <[EMAIL PROTECTED]> writes: >>> mhh? It won't print a newline, it even won't print anything. b/c @ar is empty, for(...) doesn't

Re: readdir formulated badly? gives wrong count

2007-12-03 Thread Rob Dixon
[EMAIL PROTECTED] wrote: "Jeff Pang" <[EMAIL PROTECTED]> writes: On Dec 3, 2007 10:12 AM, <[EMAIL PROTECTED]> wrote: #!/usr/local/bin/perl -w use strict; use warnings; my @ar = (); for(@ar){ print "$_\n"; } But running that script just does nothing but gleefully print a ne

Re: readdir formulated badly? gives wrong count

2007-12-02 Thread reader
"Jeff Pang" <[EMAIL PROTECTED]> writes: > On Dec 3, 2007 12:51 PM, <[EMAIL PROTECTED]> wrote: >> "Jeff Pang" <[EMAIL PROTECTED]> writes: >> > mhh? It won't print a newline, it even won't print anything. >> > b/c @ar is empty, for(...) doesn't go into it, 'print' won't be happened. >> >> Yeah you

Re: readdir formulated badly? gives wrong count

2007-12-02 Thread Jeff Pang
On Dec 3, 2007 12:51 PM, <[EMAIL PROTECTED]> wrote: > "Jeff Pang" <[EMAIL PROTECTED]> writes: > > mhh? It won't print a newline, it even won't print anything. > > b/c @ar is empty, for(...) doesn't go into it, 'print' won't be happened. > > Yeah your right... (what was I thinking...) but my point

Re: readdir formulated badly? gives wrong count

2007-12-02 Thread reader
"Jeff Pang" <[EMAIL PROTECTED]> writes: > On Dec 3, 2007 10:12 AM, <[EMAIL PROTECTED]> wrote: > >> >> #!/usr/local/bin/perl -w >> use strict; >> use warnings; >> my @ar = (); >> >> for(@ar){ >> print "$_\n"; >> } >> >> But running that script just does nothing but gleefully print

Re: readdir formulated badly? gives wrong count

2007-12-02 Thread Jeff Pang
On Dec 3, 2007 10:12 AM, <[EMAIL PROTECTED]> wrote: > > #!/usr/local/bin/perl -w > use strict; > use warnings; > my @ar = (); > > for(@ar){ > print "$_\n"; > } > > But running that script just does nothing but gleefully print a > newline. mhh? It won't print a newline, it even

Re: readdir formulated badly? gives wrong count

2007-12-02 Thread reader
Harry wrote: >> @DirContent = grep { /^[0-9]/ } readdir(DIR); >> if ($DirContent[0]){ J. Krahn replied: > Again, you are doing boolean tests on the contents of array elements > when you should really be testing the array itself. What if > $DirContent[0] contained the

Re: readdir formulated badly? gives wrong count

2007-12-02 Thread kens
d; > > >> use File::Copy; > > > Define variables in the smallest scope > > Plus only define variables you use, otherwise it can get confusing > >> my ($HiNum, $Copied, $TrgDir, @DirContent, $Cnt, $Line); > >> $TrgDir = shift; > >> $HiNum = 0; > >>

Re: readdir formulated badly? gives wrong count

2007-12-02 Thread Matthew Whipple
Rob Dixon wrote: > Matthew Whipple wrote: >> >> The for loop won't execute if it has nothing through which to >> iterate. On my system the for won't execute with an empty list, but >> will once >> when the array is undefined. Changing the above to 'if >> (defined(@DirContent)) {' would be a bit cl

Re: readdir formulated badly? gives wrong count

2007-12-02 Thread Matthew Whipple
Rob Dixon wrote: > Matthew Whipple wrote: >> >> The for loop won't execute if it has nothing through which to >> iterate. On my system the for won't execute with an empty list, but >> will once >> when the array is undefined. Changing the above to 'if >> (defined(@DirContent)) {' would be a bit cl

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
John W.Krahn <[EMAIL PROTECTED]> writes: > On Friday 30 November 2007 22:47, [EMAIL PROTECTED] wrote: > > Sorry for taking so long to reply but I was mulling it over while > eating cold pizza and watching NCAAF. You don't specify the exact file > names so I will assume that they match the patte

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread John W . Krahn
repeating pattern (usage; print; exit) that you should encapsulate in one place, for example: sub usage { print < 2 and usage( "Too many arguments.. exiting\n" ); > use Cwd; > my $Cwd = getcwd; > > use File::Copy; > > my ($HiNum, $Copied, $TrgDir, @DirContent,

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
"Tom Phoenix" <[EMAIL PROTECTED]> writes: > On 12/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> John W.Krahn <[EMAIL PROTECTED]> writes: >> > perldoc -f rewinddir >> >> Is that faster or anything than using a second opendir? > > Is it faster? What did you find out when you benchmarked both

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread Rob Dixon
Matthew Whipple wrote: The for loop won't execute if it has nothing through which to iterate. On my system the for won't execute with an empty list, but will once when the array is undefined. Changing the above to 'if (defined(@DirContent)) {' would be a bit clearer. Now what would you mean

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread Tom Phoenix
On 12/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > John W.Krahn <[EMAIL PROTECTED]> writes: > > perldoc -f rewinddir > > Is that faster or anything than using a second opendir? Is it faster? What did you find out when you benchmarked both ways of coding it? In any case, when you're readin

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread John W . Krahn
On Saturday 01 December 2007 17:25, Matthew Whipple wrote: > > [EMAIL PROTECTED] wrote: > > > > kens <[EMAIL PROTECTED]> writes: > > > >> This test add nothing. The for loop will fail if there is no > >> content > >> > >>> if ($DirContent[0]){ > > > > Checking to make sure there are in fact numbere

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread John W . Krahn
On Saturday 01 December 2007 16:20, [EMAIL PROTECTED] wrote: > > John W.Krahn <[EMAIL PROTECTED]> writes: > > > > perldoc -f rewinddir > > Is that faster or anything than using a second opendir? I don't know, you'd have to use Benchmark to test it. (In my defense you only asked if it was possibl

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread Matthew Whipple
quot;; >>>exit;} >>> >>> use Cwd; >>> my $Cwd = getcwd; >>> >>> use File::Copy; >>> >>> >> Define variables in the smallest scope >> Plus only define variables you use, otherwise it can get confusing >>

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
John W.Krahn <[EMAIL PROTECTED]> writes: > perldoc -f rewinddir Is that faster or anything than using a second opendir? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread John W . Krahn
On Saturday 01 December 2007 08:30, [EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] writes: > >> The main problem, I believe, is that you are using a stale > >> directory handle. closedir (in main) and opendir here. > > > > Ha... and that was the problem... turns out it doesn't need to be > > moved.

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
[EMAIL PROTECTED] writes: >> The main problem, I believe, is that you are using a stale directory >> handle. closedir (in main) and opendir here. > > Ha... and that was the problem... turns out it doesn't need to be > moved. Once the typeo is corrected to closedir(DIR); it works, with > no reopen

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread reader
t; my ($HiNum, $Copied, $TrgDir, @DirContent, $Cnt, $Line); >> $TrgDir = shift; >> $HiNum = 0; >> $Copied = 0; Is there something there, I don't use? I'm not seeing which one. [...] > To declare in smallest scope: > my @DirContent = grep { /^[0-9]/ } readdir($DIR); >&

Re: readdir formulated badly? gives wrong count

2007-12-01 Thread kens
ontent, $Cnt, $Line); > $TrgDir = shift; > $HiNum = 0; > $Copied = 0; > #Use lexical file and directory handles: opendir my $DIR, $TrgDir or die "can't opendir $TgtDir: $!; > opendir(DIR,$TrgDir) or die "can't opendir $TrgDir: $!"; > > ## Find out

readdir formulated badly? gives wrong count

2007-11-30 Thread reader
le::Copy; my ($HiNum, $Copied, $TrgDir, @DirContent, $Cnt, $Line); $TrgDir = shift; $HiNum = 0; $Copied = 0; opendir(DIR,$TrgDir) or die "can't opendir $TrgDir: $!"; ## Find out if target directory has any numbered files in it. ## If it does get the highest number in there @DirCo

Re: Filtering output of readdir

2007-10-18 Thread Paul Lalli
On Oct 18, 4:53 pm, [EMAIL PROTECTED] (Chas. Owens) wrote: > Also, don't use > dirhandles if you are just going to use readdir in list context. > dirhandles are for iterative reading. Use a glob to get a list: First time I've ever heard that piece of advice. Can't unde

RE: Filtering output of readdir

2007-10-18 Thread Joseph L. Casale
Thanks Chas and Tom, its working great. jlc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

RE: Filtering output of readdir

2007-10-18 Thread Joseph L. Casale
ts. Thanks! jlc -Original Message- From: Chas. Owens [mailto:[EMAIL PROTECTED] Sent: October-18-07 2:53 PM To: Joseph L. Casale Cc: beginners@perl.org Subject: Re: Filtering output of readdir On 10/18/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > Hi All, > > I am needi

Re: Filtering output of readdir

2007-10-18 Thread Chas. Owens
uot;." and ".." but I need to add two more cases. I need to > make > sure none of the entries in the array are directories or files with > extensions. snip > my @files = grep { $_ ne '.' && $_ ne '..' } readdir(DIR); snip regexes and file test

Re: Filtering output of readdir

2007-10-18 Thread Tom Phoenix
t;.." but I need to add two more cases. I need to make > sure > none of the entries in the array are directories or files with extensions. > > Here is what I have: > > opendir DIR, $InDir or die "cannot open dir $InDir: $!"; > my @files = grep { $_ ne '.&#

Filtering output of readdir

2007-10-18 Thread Joseph L. Casale
entries in the array are directories or files with extensions. Here is what I have: opendir DIR, $InDir or die "cannot open dir $InDir: $!"; my @files = grep { $_ ne '.' && $_ ne '..' } readdir(DIR); closedir(DIR); foreach(@files){ print $_,"\n&

Re: readdir question

2005-09-30 Thread Jay Savage
On 9/30/05, Gergely Buday <[EMAIL PROTECTED]> wrote: > Hi, > > this is a working code snippet: > > opendir (DIR, $dir) || die "Open failed: $!\n"; > > $\ = "\n"; > while ($_ = readdir(DIR)) { print; }; > > But when I try to use > > whil

RE: readdir question

2005-09-30 Thread Thomas Bätzler
Hi, Gergely Buday <[EMAIL PROTECTED]> wrote: > this is a working code snippet: > > opendir (DIR, $dir) || die "Open failed: $!\n"; > > $\ = "\n"; > while ($_ = readdir(DIR)) { print; }; > > But when I try to use > > while (readdir(DI

readdir question

2005-09-30 Thread Gergely Buday
Hi, this is a working code snippet: opendir (DIR, $dir) || die "Open failed: $!\n"; $\ = "\n"; while ($_ = readdir(DIR)) { print; }; But when I try to use while (readdir(DIR)) ... my script writes only empty lines. It seems that the proper number of empty lines a

RE: question related to readdir function

2005-07-15 Thread Moon, John
Subject: question related to readdir function Dear all. I wrote a piece of code to read and open all files from a directory to do something with it. But I found that the variable assigned to @file_array split the file names into pieces. For example ". . test.rpt" file will be sepa

RE: question related to readdir function

2005-07-15 Thread Ankur Gupta
ng. perl is not splitting your file name into different strings. It is just reading all the file names in that directory. > Thanks, > > AG > > #!usr/local/bin/perl > > use strict; > use warnings; > > my $dirtoget="C:/perl/work/data/"; > > opend

question related to readdir function

2005-07-15 Thread Li, Aiguo (NIH/NCI)
x27;Can not open DIR'; my @file_array; @file_array =readdir(DIR); closedir(DIR); foreach my $filename (@file_array) { print $filename; open (IN, "$f") || die 'Can not open IN'; while(){ print $_;} close(IN);}

Re: Problem with READDIR

2003-12-31 Thread Owen
file and ignores the > list of files it retrieves from the remote server. > > I debugged this and found that the READDIR is working but the last > element in the list is the log file that is in the script directory. > > What can I do to make sure I get the list of *.log files o

RE: Problem with READDIR

2003-12-31 Thread Perl
Conversation: Problem with READDIR Subject: Re: Problem with READDIR On Tue, 30 Dec 2003 19:07:26 -0800 "Perl" <[EMAIL PROTECTED]> wrote: > $iisdir = '\\\server01\c$\winnt\system32\logfiles\W3SVC1'; > opendir LOGS, "$iisdir" or die "Directory error for

Re: Problem with READDIR

2003-12-30 Thread Owen
On Tue, 30 Dec 2003 19:07:26 -0800 "Perl" <[EMAIL PROTECTED]> wrote: > $iisdir = '\\\server01\c$\winnt\system32\logfiles\W3SVC1'; > opendir LOGS, "$iisdir" or die "Directory error for IIS LOGS: $!\n"; > > my @files = grep /\.log$/

Re: Problem with READDIR

2003-12-30 Thread Ramprasad A Padmanabhan
s and found that the READDIR is working but the last element in the list is the log file that is in the script directory. Never heard of such a thing. readdir gets only files in the directory which you have opened What can I do to make sure I get the list of *.log files on the remote machine regar

Problem with READDIR

2003-12-30 Thread Perl
that the READDIR is working but the last element in the list is the log file that is in the script directory. What can I do to make sure I get the list of *.log files on the remote machine regardless of what exists in my working local directory? $iisdir = '\\\server01\c$\winnt\system3

Re: Rename - readdir - Permission Denied

2003-07-08 Thread David Storrs
On Mon, Jul 07, 2003 at 11:45:34AM -0400, Paul Kraus wrote: > I am doing a readdir. > Taking the filenames that are found and trying to rename them. > > Opendir > @files = Readdir > > Foreach @files > parse filename > $newfile = newfile name based

Re: Rename - readdir - Permission Denied

2003-07-08 Thread Rob Dixon
Paul Kraus wrote: > I am doing a readdir. > Taking the filenames that are found and trying to rename them. > > Opendir > @files = Readdir > > Foreach @files > parse filename > $newfile = newfile name based on parsed name > push (@rename,[$_,$newfile]) > > Foreac

Re: readdir unlink any symlinks

2003-07-07 Thread Harry Putnam
Steve Grazzini <[EMAIL PROTECTED]> writes: > Ah, okay. But you'll need to make that into a real loop. > > use File::Spec::Functions; > ... > > foreach (readdir(DIR)) { > my $target = catfile($mnsd, $_); > if (-l $target) {

RE: readdir unlink any symlinks

2003-07-07 Thread Tim Johnson
(BIt doesn't look like you are setting the $_ variable anywhere. Maybe if you (Bput this line in after the opendir and before the first bracket: (B (Bforeach(readdir(DIR)) (B (Band closed the bracket (B (B-Original Message- (BFrom: Harry Putnam [mailto:[EMAIL PROTECTED] (

Re: readdir unlink any symlinks

2003-07-07 Thread Steve Grazzini
cript: > > my $mnsd = "/tmp/mns"; > if(! -d $mnsd){ > mkdir $mnsd or die "Can't mkdir $mnsd; $!"; > }else{ >opendir(DIR, $mnsd) or die "can?ft opendir DIR: $!"; >{ my $target = $mnsd . "/" . $_; ^ Hmmm? >unl

readdir unlink any symlinks

2003-07-07 Thread Harry Putnam
ot;Can't mkdir $mnsd; $!"; }else{ opendir(DIR, $mnsd) or die "can’t opendir DIR: $!"; { my $target = $mnsd . "/" . $_; unlink $target if (-l $target)} readdir(DIR); } close(DIR); Error this formulation gives is: Use of uninitialized value in concatenation (.) or stri

Rename - readdir - Permission Denied

2003-07-07 Thread Paul Kraus
I am doing a readdir. Taking the filenames that are found and trying to rename them. Opendir @files = Readdir Foreach @files parse filename $newfile = newfile name based on parsed name push (@rename,[$_,$newfile]) Foreach @rename rename $$_[0], $$_[1] or die

Rename - readdir - Permission Denied

2003-07-07 Thread Paul Kraus
I am doing a readdir. Taking the filenames that are found and trying to rename them. Opendir @files = Readdir Foreach @files parse filename $newfile = newfile name based on parsed name push (@rename,[$_,$newfile]) Foreach @rename rename $$_[0], $$_[1] or die

RE: Readdir

2002-12-24 Thread Paul Kraus
disregard I had a sneaky last statement messing me up. > -Original Message- > From: Paul Kraus [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, December 24, 2002 9:11 AM > To: 'Perl' > Subject: Readdir > > > Correct me if I am wrong but this should re

Readdir

2002-12-24 Thread Paul Kraus
Correct me if I am wrong but this should return a directory listing? use constant backupdir => "/"; opendir BACKUP, BACKUPDIR or die "Cannot open ".BACKUPDIR."!"; print "$_\n" foreach (readdir BACKUP); Paul Kraus Network Administrator PEL Supply

Re: Readdir to array

2002-12-13 Thread Mystik Gotan
I'd be using: #!/usr/bin/perl -w $dir = "/backup"; opendir BACKUPDIR, $dir or die "Cannot open $dir!"; foreach (readdir BACKUPDIR){ unless ($_ eq "." or $_ eq ".."){ #print "$_"; push (@dirs,$_); } foreach (@dirs) { print &

RE: Readdir to array

2002-12-13 Thread Paul Kraus
doht! Thanks! > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, December 13, 2002 10:13 AM > To: Paul Kraus; Perl > Subject: RE: Readdir to array > > > You are foreah'ing in your foreach. So it is printing the >

RE: Readdir to array

2002-12-13 Thread wiggins
> for some reason the output is different for this script. If I print $_ I > get the correct list. If I print the Array I get roughly the same list 4 > times? > > #!/usr/bin/perl -w > > $dir = "/backup"; > opendir BACKUPDIR, $dir or die "Cannot open $dir!&quo

Readdir to array

2002-12-13 Thread Paul Kraus
for some reason the output is different for this script. If I print $_ I get the correct list. If I print the Array I get roughly the same list 4 times? #!/usr/bin/perl -w $dir = "/backup"; opendir BACKUPDIR, $dir or die "Cannot open $dir!"; foreach (readdir BACKUPDIR){

Re: Looping through readdir()

2002-09-26 Thread Dharmender Rai
perldoc -f readdir --- [EMAIL PROTECTED] wrote: > Hello, All: > > When using... > > while ($x = readdir(DH)) { > # What came before $x? > # What will come after $x? > } > > How can I look at the next item in the directory? > > -- > E

Re: Looping through readdir()

2002-09-25 Thread david
[EMAIL PROTECTED] wrote: > Hello, All: > > When using... > > while ($x = readdir(DH)) { > # What came before $x? > # What will come after $x? > } > > How can I look at the next item in the directory? > i don't really know what you mean by before or af

Re: Looping through readdir()

2002-09-25 Thread Bob Showalter
- Original Message - From: <[EMAIL PROTECTED]> To: "Beginners Perl Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, September 25, 2002 3:33 AM Subject: Looping through readdir() > Hello, All: > > When using... > > while ($x = readdir(DH)) { > #

Looping through readdir()

2002-09-25 Thread eric-perl
Hello, All: When using... while ($x = readdir(DH)) { # What came before $x? # What will come after $x? } How can I look at the next item in the directory? -- Eric P. Sunnyvale, CA -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: Scalar and readdir

2001-12-24 Thread Jeff 'japhy' Pinyan
On Dec 24, Eric said: >perl -e 'opendir(T,"."); $a = scalar(readdir(T)); print "$a\n";' >.. > >perl -e 'opendir(T,"."); @b = readdir(T) ; $a = scalar(@b); print "$a\n";' >22 readdir() is documented to behave this w

Scalar and readdir

2001-12-24 Thread Eric
Jsut wondering, been working with perl for about 1.5 years now off and on. I've got most things locked down, but this ones a bit wierd. Why would: perl -e 'opendir(T,"."); $a = scalar(readdir(T)); print "$a\n";' give : .. You would think it would give s

Re: readdir

2001-07-27 Thread Maxim Berlin
Hello COLLINEAU, Friday, July 27, 2001, COLLINEAU Franck FTRD/DMI/TAM <[EMAIL PROTECTED]> wrote: CFFDT> I have a problem with my code: CFFDT> #!/usr/bin/perl -w CFFDT> opendir (LMI,"lmi") || die "impossible d'ouvrir lmi: $!"; CFFDT> $chaine="

readdir

2001-07-27 Thread COLLINEAU Franck FTRD/DMI/TAM
I have a problem with my code: #!/usr/bin/perl -w opendir (LMI,"lmi") || die "impossible d'ouvrir lmi: $!"; $chaine="BEGIN PAPIER"; while($fichier=readdir LMI) { open (FICHIER,"lmi/$fichier") || die "impossible d'ouvrir $fichier: !