Ask a Question related to PERL Miscellaneous, Design and Development.
-
Geoff Cox #1
readline() on closed fielhandle?
Hello,
Cannot see what is wrong with following - I get following error
message "readline() on closed fielhandle at line ++" - help please!
Cheers
Geoff
use warnings;
use strict;
use File::Find;
open (OUT, ">>out");
my $dir = 'c:/atemp1/test';
find ( sub {
open (IN, "$_");
++ while (defined(my $line=<IN>)) {
if ($line =~ /Mailto:(.*?)"/i) {
print OUT ("$1");
}
}
}, $dir);
close (OUT);
close (IN);
Geoff Cox Guest
-
How to glue Net::Server and readline ?
Hi, I'm trying to glue together an console application with readline extension (=I can edit the line befor I enter it). How can I make it work with... -
Readline API doc?
I'm looking for the info on how to define/modify/basically interact with readline keymaps from Ruby. Anyone have any pointers? -Mark -
readline.dll missing in 1.8 final?
Chris Morris wrote: .... Hi, WATANABE, Hirofumi maintains a very nice collection of Ruby relevant Windows ports (including readline and... -
readline.dll problem
I am using U.Nakamura's mswin32 Ruby 1.8.0. When I installed it and tried to use irb, I got an error "readline.dll not found". (Irb works fine... -
irb --readline
Hi, In message "irb --readline" on 03/07/25, Wybo Dekker <wybo@servalys.nl> writes: |When I try to have readline support with: | |irb... -
Kevin Michael Vail #2
Re: readline() on closed fielhandle?
In article <uab6mvob4hsaigjvqjrhutudhjs4kjh4rk@4ax.com>,
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
You don't even know if the open succeeded. **Always** check to be sure> Cannot see what is wrong with following - I get following error
> message "readline() on closed fielhandle at line ++" - help please!
>
> []
>
> open (IN, "$_");
open succeeds:
open IN, $_ or die "can't open $_: $!\n";
(Oh, and you don't need the quotes around $_.)
Don't need the quotes around $1, either.> print OUT ("$1");
--
Kevin Michael Vail | Dogbert: That's circular reasoning.
[email]kevin@vaildc.net[/email] | Dilbert: I prefer to think of it as no loose ends.
[url]http://www.vaildc.net/kevin/[/url]
Kevin Michael Vail Guest
-
Michael Budash #3
Re: readline() on closed fielhandle?
In article <uab6mvob4hsaigjvqjrhutudhjs4kjh4rk@4ax.com>,
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
open (IN, "$_") or return;> Hello,
>
> Cannot see what is wrong with following - I get following error
> message "readline() on closed fielhandle at line ++" - help please!
>
> Cheers
>
> Geoff
>
> use warnings;
> use strict;
>
> use File::Find;
>
> open (OUT, ">>out");
>
> my $dir = 'c:/atemp1/test';
>
> find ( sub {
>
> open (IN, "$_");
[snip]>
> ++ while (defined(my $line=<IN>)) {
>
hth-
--
Michael Budash
Michael Budash Guest
-
Geoff Cox #4
Re: readline() on closed fielhandle?
On Sat, 13 Sep 2003 11:07:59 -0400, Kevin Michael Vail
<kevin@vaildc.net> wrote:
Kevin,>In article <uab6mvob4hsaigjvqjrhutudhjs4kjh4rk@4ax.com>,
> Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>>> Cannot see what is wrong with following - I get following error
>> message "readline() on closed fielhandle at line ++" - help please!
>>
>> []
>>
>> open (IN, "$_");
>You don't even know if the open succeeded. **Always** check to be sure
>open succeeds:
>
>open IN, $_ or die "can't open $_: $!\n";
This has got me confused ! If I use the check for opening the file I
get error message "failed in open(): Permission denied at line 8" and
nothing goes into the file called out ...
If I use line 7 instead, I get error message "readline() on closed
filehandle IN at line 9" - but the email addresses are put into the
file
called out ..?? What am I missing here?
Geoff
1 use warnings;
2 use strict;
3 use File::Find;
4 open (OUT, ">>out");
5 my $dir = 'c:/atemp1/test';
6 find ( sub {
7 open (IN, "$_");
8 # open(IN, $_) or die "Failed in open(): $!";
9 while (defined(my $line=<IN>)) {
10 if ($line =~ /Mailto:(.*?)"/i) {
11 print OUT ("$1 \n");
12 }
13 }
14 }, $dir);
15 close (OUT);
16 close (IN);
>
>(Oh, and you don't need the quotes around $_.)
>>>> print OUT ("$1");
>Don't need the quotes around $1, either.Geoff Cox Guest
-
Bob Walton #5
Re: readline() on closed fielhandle?
Geoff Cox wrote:
> On Sat, 13 Sep 2003 11:07:59 -0400, Kevin Michael Vail
> <kevin@vaildc.net> wrote:
>
>>>>In article <uab6mvob4hsaigjvqjrhutudhjs4kjh4rk@4ax.com>,
>>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>
>>>>You don't even know if the open succeeded. **Always** check to be sure>>>Cannot see what is wrong with following - I get following error
>>>message "readline() on closed fielhandle at line ++" - help please!
>>>
>>>[]
>>>
>>>open (IN, "$_");
>>>
>>open succeeds:
>>
>>open IN, $_ or die "can't open $_: $!\n";
>>
> Kevin,
>
> This has got me confused ! If I use the check for opening the file I
> get error message "failed in open(): Permission denied at line 8" and
> nothing goes into the file called out ...
>
> If I use line 7 instead, I get error message "readline() on closed
> filehandle IN at line 9" - but the email addresses are put into the
> file
> called out ..?? What am I missing here?
As the sub code reference argument to File::Find's find function, note
that your sub (and your open statement) is being executed many times,
once for each file (but your close statement isn't -- but that doesn't
matter, since open() will first close the filehandle if it is still
open). Apparently somewhere down that list of files you have a file
with permissions set so the user you are running this under cannot read
that file. At that point your open fails with your permission denied
error, and you choose to either die or ignore that fact, depending upon
whether you put the "or die" in. When you told it to die on error, it
did. Maybe you want to just "or return" on error and ignore that file.
You will probably note that only some of your email addresses are put
into the file called out, and that it either skips those files or
terminates when it gets to the first file with the bad permissions
anyway. I'm not sure if the readline() error is a warning or a fatal
error -- I'd guess it is merely a warning, and that consequently your
code is essentially skipping your bad-permission file(s) when you omit
the "or die" on the open.
....>
> Geoff
>
>
> 1 use warnings;
> 2 use strict;
> 3 use File::Find;
> 4 open (OUT, ">>out");
> 5 my $dir = 'c:/atemp1/test';
> 6 find ( sub {
> 7 open (IN, "$_");
> 8 # open(IN, $_) or die "Failed in open(): $!";
> 9 while (defined(my $line=<IN>)) {
> 10 if ($line =~ /Mailto:(.*?)"/i) {
> 11 print OUT ("$1 \n");
> 12 }
> 13 }
> 14 }, $dir);
> 15 close (OUT);
> 16 close (IN);
--
Bob Walton
Bob Walton Guest
-
Geoff Cox #6
Re: readline() on closed fielhandle?
On Sat, 13 Sep 2003 19:29:13 GMT, Bob Walton
<bwalton@rochester.rr.com> wrote:
Bob,>Geoff Cox wrote:
>>>> On Sat, 13 Sep 2003 11:07:59 -0400, Kevin Michael Vail
>> <kevin@vaildc.net> wrote:
>>
>>>>>>>In article <uab6mvob4hsaigjvqjrhutudhjs4kjh4rk@4ax.com>,
>>>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>>
>>>
>>>>Cannot see what is wrong with following - I get following error
>>>>message "readline() on closed fielhandle at line ++" - help please!
>>>>
>>>>[]
>>>>
>>>>open (IN, "$_");
>>>>
>>>You don't even know if the open succeeded. **Always** check to be sure
>>>open succeeds:
>>>
>>>open IN, $_ or die "can't open $_: $!\n";
>>>
>> Kevin,
>>
>> This has got me confused ! If I use the check for opening the file I
>> get error message "failed in open(): Permission denied at line 8" and
>> nothing goes into the file called out ...
>>
>> If I use line 7 instead, I get error message "readline() on closed
>> filehandle IN at line 9" - but the email addresses are put into the
>> file
>> called out ..?? What am I missing here?
>
>As the sub code reference argument to File::Find's find function, note
>that your sub (and your open statement) is being executed many times,
>once for each file (but your close statement isn't -- but that doesn't
>matter, since open() will first close the filehandle if it is still
>open). Apparently somewhere down that list of files you have a file
>with permissions set so the user you are running this under cannot read
>that file. At that point your open fails with your permission denied
this is odd as I am using Windows 98(SE) and have checked that all
files have only the A atribute .. ?
with "or return" the code runs without error message and the email>error, and you choose to either die or ignore that fact, depending upon
>whether you put the "or die" in. When you told it to die on error, it
>did. Maybe you want to just "or return" on error and ignore that file.
addresses are extracted ..
Cheers
Geoff
> You will probably note that only some of your email addresses are put
>into the file called out, and that it either skips those files or
>terminates when it gets to the first file with the bad permissions
>anyway. I'm not sure if the readline() error is a warning or a fatal
>error -- I'd guess it is merely a warning, and that consequently your
>code is essentially skipping your bad-permission file(s) when you omit
>the "or die" on the open.
>
>>...>>
>> Geoff
>>
>>
>> 1 use warnings;
>> 2 use strict;
>> 3 use File::Find;
>> 4 open (OUT, ">>out");
>> 5 my $dir = 'c:/atemp1/test';
>> 6 find ( sub {
>> 7 open (IN, "$_");
>> 8 # open(IN, $_) or die "Failed in open(): $!";
>> 9 while (defined(my $line=<IN>)) {
>> 10 if ($line =~ /Mailto:(.*?)"/i) {
>> 11 print OUT ("$1 \n");
>> 12 }
>> 13 }
>> 14 }, $dir);
>> 15 close (OUT);
>> 16 close (IN);Geoff Cox Guest
-
Tad McClellan #7
Re: readline() on closed fielhandle?
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
> 1 use warnings;
> 2 use strict;
> 3 use File::Find;
> 4 open (OUT, ">>out");
> 5 my $dir = 'c:/atemp1/test';
> 6 find ( sub {
> 7 open (IN, "$_");
> 8 # open(IN, $_) or die "Failed in open(): $!";
> 9 while (defined(my $line=<IN>)) {
> 10 if ($line =~ /Mailto:(.*?)"/i) {
> 11 print OUT ("$1 \n");
> 12 }
> 13 }
> 14 }, $dir);
> 15 close (OUT);
> 16 close (IN);
Please spend the time to format your code sensibly.
Many people will just move on to help someone else who has
done what they can to make it easier to give an answer.
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest
-
Jay Tilton #8
Re: readline() on closed fielhandle?
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
: Bob Walton <bwalton@rochester.rr.com> wrote:
: >Geoff Cox wrote:
: >> Kevin Michael Vail <kevin@vaildc.net> wrote:
: >>>open IN, $_ or die "can't open $_: $!\n";
: >> This has got me confused ! If I use the check for opening the file I
: >> get error message "failed in open(): Permission denied at line 8" and
: >> nothing goes into the file called out ...
: >Apparently somewhere down that list of files you have a file
: >with permissions set so the user you are running this under cannot read
: >that file.
: this is odd as I am using Windows 98(SE) and have checked that all
: files have only the A atribute .. ?
Win98 will also say "Permission denied" when your program tries to open
a directory as if it is a file.
Jay Tilton Guest
-
Geoff Cox #9
Re: readline() on closed fielhandle?
On Sat, 13 Sep 2003 20:51:28 GMT, [email]tiltonj@erols.com[/email] (Jay Tilton)
wrote:
Jay,>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>: Bob Walton <bwalton@rochester.rr.com> wrote:
>: >Geoff Cox wrote:
>: >> Kevin Michael Vail <kevin@vaildc.net> wrote:
>
>: >>>open IN, $_ or die "can't open $_: $!\n";
>
>: >> This has got me confused ! If I use the check for opening the file I
>: >> get error message "failed in open(): Permission denied at line 8" and
>: >> nothing goes into the file called out ...
>
>: >Apparently somewhere down that list of files you have a file
>: >with permissions set so the user you are running this under cannot read
>: >that file.
>
>: this is odd as I am using Windows 98(SE) and have checked that all
>: files have only the A atribute .. ?
>
>Win98 will also say "Permission denied" when your program tries to open
>a directory as if it is a file.
the email addresses are in files which are in a folder with no
sub-folders so it cannot be this, can it?
Geoff
Geoff Cox Guest
-
Geoff Cox #10
Re: readline() on closed fielhandle?
On Sat, 13 Sep 2003 15:24:31 -0500, [email]tadmc@augustmail.com[/email] (Tad
McClellan) wrote:
Tad,>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>>> 1 use warnings;
>> 2 use strict;
>> 3 use File::Find;
>> 4 open (OUT, ">>out");
>> 5 my $dir = 'c:/atemp1/test';
>> 6 find ( sub {
>> 7 open (IN, "$_");
>> 8 # open(IN, $_) or die "Failed in open(): $!";
>> 9 while (defined(my $line=<IN>)) {
>> 10 if ($line =~ /Mailto:(.*?)"/i) {
>> 11 print OUT ("$1 \n");
>> 12 }
>> 13 }
>> 14 }, $dir);
>> 15 close (OUT);
>> 16 close (IN);
>
>Please spend the time to format your code sensibly.
>
>Many people will just move on to help someone else who has
>done what they can to make it easier to give an answer.
sorry about that - would you recommend any program which automates the
formatting?
Cheers
Geoff
Geoff Cox Guest
-
Tad McClellan #11
Re: readline() on closed fielhandle?
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
> would you recommend any program which automates the
> formatting?
vi or emacs
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest
-
Jay Tilton #12
Re: readline() on closed fielhandle?
Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
: On Sat, 13 Sep 2003 20:51:28 GMT, [email]tiltonj@erols.com[/email] (Jay Tilton)
: wrote:
: >Win98 will also say "Permission denied" when your program tries to open
: >a directory as if it is a file.
:
: the email addresses are in files which are in a folder with no
: sub-folders so it cannot be this, can it?
Instead of asking me, ask your program to give you that information.
find ( sub {
if( -d $_ ) {
warn "'$_' is a subdirectory.\n";
return;
}
# rest of subroutine goes here
}, $dir);
Jay Tilton Guest
-
Geoff Cox #13
Re: readline() on closed fielhandle?
On Sat, 13 Sep 2003 17:04:05 -0500, [email]tadmc@augustmail.com[/email] (Tad
McClellan) wrote:
thanks>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>>>> would you recommend any program which automates the
>> formatting?
>
>vi or emacs
Geoff
Geoff Cox Guest
-
Geoff Cox #14
Re: readline() on closed fielhandle?
On Sat, 13 Sep 2003 22:42:36 GMT, [email]tiltonj@erols.com[/email] (Jay Tilton)
wrote:
ok !>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>
>: On Sat, 13 Sep 2003 20:51:28 GMT, [email]tiltonj@erols.com[/email] (Jay Tilton)
>: wrote:
>
>: >Win98 will also say "Permission denied" when your program tries to open
>: >a directory as if it is a file.
>:
>: the email addresses are in files which are in a folder with no
>: sub-folders so it cannot be this, can it?
>
>Instead of asking me, ask your program to give you that information.
>
> find ( sub {
> if( -d $_ ) {
> warn "'$_' is a subdirectory.\n";
> return;
> }
> # rest of subroutine goes here
> }, $dir);
Geoff
Geoff Cox Guest



Reply With Quote

