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,
--
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
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
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
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] )
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
files = map { $_->[0] }
> >sort { $a cmp $b }
> >map {[$_, (stat("$dir/$_"))[9] ] }
> > grep { ! /^\./ && -f "$dir/$_" } readdir($dh);
>
> my @files = map { $_->[0] } # What happene
> ...
> 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
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
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
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
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)
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:
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
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
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
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
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
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 =
_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
{
#--
$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
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:\
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: $!"
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
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:
&
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
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 )
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
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
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 ...
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
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,
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
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 &
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
[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
[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
"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
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
"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
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
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
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;
> >>
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
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
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
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,
"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
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
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
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
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
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
>>
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/
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.
[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
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);
>&
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
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
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
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/
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
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
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 '.
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&
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
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
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
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
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
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);}
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
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
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$/
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
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
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
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
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) {
(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]
(
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
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
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
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
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
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
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 &
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
>
> 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
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){
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
[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
- 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)) {
> #
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
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
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
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="
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:
!
98 matches
Mail list logo