[23729] in Perl-Users-Digest
Perl-Users Digest, Issue: 5935 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 13 03:05:49 2003
Date: Sat, 13 Dec 2003 00:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 13 Dec 2003 Volume: 10 Number: 5935
Today's topics:
Re: @ISA specific to instance rather than class? <usenet@morrow.me.uk>
Re: @ISA specific to instance rather than class? (Malcolm Dew-Jones)
[OT] Re: Scp files to another server help <mhunter@uclink.berkeley.edu>
Re: A way to grab string from another program in perl? <jurgenex@hotmail.com>
Re: A way to grab string from another program in perl? (Tad McClellan)
Re: Comparison Value (Jay Tilton)
Concatenation Question <ccarpenter@erols.com>
Re: Concatenation Question <DSX@comcast.net>
Re: Concatenation Question <DSX@comcast.net>
Re: Concatenation Question (Sam Holden)
Re: Concatenation Question <matthew.garrish@sympatico.ca>
Re: Concatenation Question (Tad McClellan)
Re: Concatenation Question <jurgenex@hotmail.com>
Re: how to read data from EXCEL <carlo.runner@libero.it>
How to write MIME header for application/x-javascript? <test@test.com>
Re: LWP install MacOS X <spamfilter@dot-app.org>
Re: Newsgroup Searching Program <gerardlanois@netscape.net>
Re: Passing a hash by reference <invalid-email@rochester.rr.com>
REQUEST: Problem with Perl (Win32) on Windows98SE and r (AT)
Re: REQUEST: Problem with Perl (Win32) on Windows98SE a (Jay Tilton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 13 Dec 2003 00:22:40 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: @ISA specific to instance rather than class?
Message-Id: <brdm4g$625$1@wisteria.csv.warwick.ac.uk>
Matthew Braid <mb@uq.net.au.invalid> wrote:
> sub use_something {
> my $self = shift;
> eval {use base qw/My::Package::Something/};
As someone else pointed out, a 'use' statement is a BEGIN block, so
this is silly. What you perhaps meant was
eval {
require qw/My::Package::Something/;
@ISA = qw/My::Package::Something/
}
> die $@ if $@;
> return 1;
> }
>
> This works well, but it means that once one instance of the class uses
> the 'something', then all of them have it loaded on creation.
I think you have perhaps misunderstood how 'require' works: the module
file is only loaded and compiled *once*, the first time it is required
(used). Thereafter, giving your objects extra base classes has no
effect beyond the extra entries in @ISA.
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
ben@morrow.me.uk |----------------+---------------| The Levellers, 'Believers'
------------------------------
Date: 12 Dec 2003 20:07:46 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: @ISA specific to instance rather than class?
Message-Id: <3fda9092@news.victoria.tc.ca>
Ben Morrow (usenet@morrow.me.uk) wrote:
: Matthew Braid <mb@uq.net.au.invalid> wrote:
: > sub use_something {
: > my $self = shift;
: > eval {use base qw/My::Package::Something/};
: As someone else pointed out, a 'use' statement is a BEGIN block, so
: this is silly. What you perhaps meant was
: eval {
: require qw/My::Package::Something/;
: @ISA = qw/My::Package::Something/
: }
No, what he meant was that it needed to be a string eval.
eval 'use base qw/My::Package::Something/';
(or better because of a bit more syntax checking, as long as you remember
the "q")
eval q{use base qw/My::Package::Something/};
The string form of eval is evaluated at run time, which means the "use"
statement is _not_ evaluated as per a BEGIN block, and yet it still
includes what ever chicanery is going on in the background (importing,
exporting etc.)
------------------------------
Date: Sat, 13 Dec 2003 00:59:44 +0000 (UTC)
From: Mike Hunter <mhunter@uclink.berkeley.edu>
Subject: [OT] Re: Scp files to another server help
Message-Id: <slrnbtkp0c.1r8.mhunter@celeste.net.berkeley.edu>
On 12 Dec 2003 13:41:46 -0800, JoelAshton wrote:
> "Tintin" <me@privacy.net> wrote in message news:<br68g0$28enps$1@ID-172104.news.uni-berlin.de>...
> > "JennAshton" <> wrote in message
> > news:c5b9b407.0312081805.19193fd1@posting.google.com...
> > > Hi,
> > >
> > > I wrote a simple scp script from my server to pacman server which
> > > copies all jpg files to /jennash/ directory.
> > >
> > > Now, I need help with this script. I would like it to pull not just
> > > *.jpg files but other file types as well. Also, is it possible to pull
> > > only files that is 3 minutes old? Please help.
> > >
> > > Thanks!
> > >
> > > JennAsh
> > >
> > > #!/usr/bin/perl
> > >
> > > system('scp /export/www/docs/*.jpg pacman:/export/www/jennash/');
> > >
> > > exit;
> >
> > And the relevance to Perl is???
> >
> > Here's a shell script to do it:
> >
> > #!/bin/sh
> > scp `find /export/www/docs -type f -mmin 3` pacman:/export/www/jennash
>
>
> Well, seeing your shell script I was able to come up with this
> rsync -rt -e /usr/local/bin/ssh /htodcs/www/my_folder/
> pacman:/htdocs/www/remote_folder
>
> The above script allows me to execute via command line in Unix.
> However, when I saved the script has shell script and tried to
> executed via browser it didn't work.
>
> The page displays:
>
> We trust you have received the usual lecture from the local System
> Administrator. It usually boils down to these two things: #1) Respect
> the privacy of others. #2) Think before you type. Password:
>
>
> Not sure why it is displaying since the sys-admin open up ssh
> connection and a key has been established in my local directory in the
> remote server.
>
> Can anyone advise?
If you run it as a CGI, you'll be running it as a different user. I don't
know how your web server is set up, so I can't tell you how to fix it, but
you somehow need to get the script to run as the appropriate user, perhaps
using the "setuid" bit for the executable permission.
Mike
------------------------------
Date: Sat, 13 Dec 2003 01:43:52 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: A way to grab string from another program in perl?
Message-Id: <s9uCb.1452$cO5.129@nwrddc03.gnilink.net>
Jeff wrote:
> I'm looking for a way to run another program from a system call and
> get the output produced into a perl variable without going through a
> file intermediary.
>
> system('program');
>
> produces a string on STDOUT. I want to grab this in a variable but
> can't figure out how to do it. Any ideas?
Did you read the man pages for the functions you are using?
Please pay particular attention to the third sentence in the third paragraph
for "perldoc -f system".
Or just check the FAQ: " Why can't I get the output of a command with
system()?"
jue
------------------------------
Date: Fri, 12 Dec 2003 22:26:09 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: A way to grab string from another program in perl?
Message-Id: <slrnbtl571.3mv.tadmc@magna.augustmail.com>
Jeff <jeffrey@cunningham.net> wrote:
> system('program');
>
> I want to grab this in a variable but can't
> figure out how to do it.
Give up on programming. You are not suited to it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 13 Dec 2003 04:37:29 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Comparison Value
Message-Id: <3fda96b2.518064141@news.erols.com>
cool_ian10@hotmail.com (ThERiZla) wrote:
: I want find in an array a value start by this character : "-".
: This is two examples of value in my array, I want find: -c, -s .
: I use a while to scan my array, but I don't know how compare my values to find
: the good one.
Sounds like you're trying to recognize switches passed in from the command
line. The Getopt::Std module would be useful.
------------------------------
Date: Sat, 13 Dec 2003 03:32:31 GMT
From: "Chip" <ccarpenter@erols.com>
Subject: Concatenation Question
Message-Id: <jLvCb.456$xH2.307902@news1.news.adelphia.net>
How can I add a ".jpg" extension to a string?
I'm trying the following with 12345 as the input.
#!/usr/bin/perl -w
print "Please enter the item picture number to remove: ";
my $number=<STDIN>;
my $path=http://someplace.com/images/;
my $ext=".jpg";
my $picture="$path . $number . $ext";
system rm $picture;
print "$picture has been removed";
__END__
The output I'm hoping for is:
http://someplace.com/images/12345.jpg has been removed
What I get is:
http://someplace.com/images/12345 has been removed
How do I add the ".jpg"
Thanks
Chip
------------------------------
Date: Sat, 13 Dec 2003 03:48:31 GMT
From: "Nick Santos" <DSX@comcast.net>
Subject: Re: Concatenation Question
Message-Id: <j_vCb.379074$ao4.1265853@attbi_s51>
"Chip" <ccarpenter@erols.com> wrote in message
news:jLvCb.456$xH2.307902@news1.news.adelphia.net...
> How can I add a ".jpg" extension to a string?
>
> I'm trying the following with 12345 as the input.
>
> #!/usr/bin/perl -w
> print "Please enter the item picture number to remove: ";
> my $number=<STDIN>;
> my $path=http://someplace.com/images/;
> my $ext=".jpg";
> my $picture="$path . $number . $ext";
> system rm $picture;
> print "$picture has been removed";
> __END__
>
> The output I'm hoping for is:
> http://someplace.com/images/12345.jpg has been removed
>
> What I get is:
> http://someplace.com/images/12345 has been removed
>
> How do I add the ".jpg"
>
> Thanks
> Chip
>
Ok, I put this code into my interpreter, and it founf a problem with your
$path declaration. Other than that, what you need is to put this in before
you declare $picture
chomp ($number);
so your code will look like this
print "Please enter the item picture number to remove: ";
my $number=<STDIN>;
my $path='http://someplace.com/images/';
my $ext='.jpg';
chomp ($number);
my $picture="$path$number$ext";
print "$picture has been removed";
That should give you output of
http://someplace.com/images/12345 has been removed
------------------------------
Date: Sat, 13 Dec 2003 03:50:44 GMT
From: "Nick Santos" <DSX@comcast.net>
Subject: Re: Concatenation Question
Message-Id: <o0wCb.100475$_M.530166@attbi_s54>
> "Chip" <ccarpenter@erols.com> wrote in message
> news:jLvCb.456$xH2.307902@news1.news.adelphia.net...
> How can I add a ".jpg" extension to a string?
>
> I'm trying the following with 12345 as the input.
>
> #!/usr/bin/perl -w
> > print "Please enter the item picture number to remove: ";
> > my $number=<STDIN>;
> > my $path=http://someplace.com/images/;
> > my $ext=".jpg";
> > my $picture="$path . $number . $ext";
> > system rm $picture;
> > print "$picture has been removed";
> > __END__
> >
> > The output I'm hoping for is:
> > http://someplace.com/images/12345.jpg has been removed
> >
> > What I get is:
> > http://someplace.com/images/12345 has been removed
> >
> > How do I add the ".jpg"
> >
> > Thanks
> > Chip
> >
> Ok, I put this code into my interpreter, and it founf a problem with your
> $path declaration. Other than that, what you need is to put this in before
> you declare $picture
>
> chomp ($number);
>
> so your code will look like this
>
> print "Please enter the item picture number to remove: ";
> my $number=<STDIN>;
> my $path='http://someplace.com/images/';
> my $ext='.jpg';
> chomp ($number);
> my $picture="$path$number$ext";
> print "$picture has been removed";
>
> That should give you output of
>
> http://someplace.com/images/12345 has been removed
>
>
I'm sorry...I meant that it would give you
http://someplace.com/images/12345.jpg has been removed
Nick
------------------------------
Date: 13 Dec 2003 03:54:39 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Concatenation Question
Message-Id: <slrnbtl3bv.7tm.sholden@flexal.cs.usyd.edu.au>
On Sat, 13 Dec 2003 03:32:31 GMT, Chip <ccarpenter@erols.com> wrote:
> How can I add a ".jpg" extension to a string?
>
> I'm trying the following with 12345 as the input.
>
> #!/usr/bin/perl -w
> print "Please enter the item picture number to remove: ";
> my $number=<STDIN>;
> my $path=http://someplace.com/images/;
> my $ext=".jpg";
> my $picture="$path . $number . $ext";
> system rm $picture;
> print "$picture has been removed";
> __END__
>
> The output I'm hoping for is:
> http://someplace.com/images/12345.jpg has been removed
>
> What I get is:
> http://someplace.com/images/12345 has been removed
No you don't. Since it doesn't compile.
--
Sam Holden
------------------------------
Date: Fri, 12 Dec 2003 22:50:17 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Concatenation Question
Message-Id: <U%vCb.16250$aF2.1846115@news20.bellglobal.com>
"Chip" <ccarpenter@erols.com> wrote in message
news:jLvCb.456$xH2.307902@news1.news.adelphia.net...
> How can I add a ".jpg" extension to a string?
>
> I'm trying the following with 12345 as the input.
>
> #!/usr/bin/perl -w
> print "Please enter the item picture number to remove: ";
> my $number=<STDIN>;
> my $path=http://someplace.com/images/;
> my $ext=".jpg";
> my $picture="$path . $number . $ext";
> system rm $picture;
> print "$picture has been removed";
> __END__
>
> The output I'm hoping for is:
> http://someplace.com/images/12345.jpg has been removed
>
> What I get is:
> http://someplace.com/images/12345 has been removed
>
You couldn't possibly be getting that output based on the code above. For
one, it would never run because your $path variable is not quoted. Second,
when you read from STDIN, you also get the carriage return (\n). Third,
your extension is statically defined, so it must appear somewhere in your
output. And finally, you're not concatenating your string when you put it in
double quotes. Fixing your above code to run produces the following result:
http://someplace.com/images/ . 12345
. .jpg has been removed
If you post your real code, someone might be able to help you.
Matt
------------------------------
Date: Fri, 12 Dec 2003 22:29:55 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Concatenation Question
Message-Id: <slrnbtl5e3.3mv.tadmc@magna.augustmail.com>
Chip <ccarpenter@erols.com> wrote:
> my $path=http://someplace.com/images/;
> What I get is:
A syntax error.
Put quotes around strings.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 13 Dec 2003 04:44:25 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Concatenation Question
Message-Id: <JOwCb.1039$gk1.711@nwrddc01.gnilink.net>
Chip wrote:
> How can I add a ".jpg" extension to a string?
>
> I'm trying the following with 12345 as the input.
>
> #!/usr/bin/perl -w
> print "Please enter the item picture number to remove: ";
> my $number=<STDIN>;
> my $path=http://someplace.com/images/;
> my $ext=".jpg";
> my $picture="$path . $number . $ext";
> system rm $picture;
> print "$picture has been removed";
> __END__
>
> The output I'm hoping for is:
> http://someplace.com/images/12345.jpg has been removed
>
> What I get is:
> http://someplace.com/images/12345 has been removed
You do? Most interesting! I am getting:
Unquoted string "http" may clash with future reserved word at C:\tmp\t.pl
line 4.
Bareword found where operator expected at C:\tmp\t.pl line 4, near
"//someplace"
(Missing operator before eplace?)
Unquoted string "eplace" may clash with future reserved word at C:\tmp\t.pl
line 4.
Unquoted string "com" may clash with future reserved word at C:\tmp\t.pl
line 4.
Unquoted string "images" may clash with future reserved word at C:\tmp\t.pl
line 4.
syntax error at C:\tmp\t.pl line 4, near "http:"
Execution of C:\tmp\t.pl aborted due to compilation errors.
If you fix the syntax error (hint hint: do not retype your code, copy and
paste it!) and comment out the bogus "system" call, then I get (in two
lines!):
http://someplace.com/images/ . 123
. .jpg has been removed
from the one single print statement.
> How do I add the ".jpg"
First of all you don't want to add something but you want to get rid of that
superflous line break from your input line: perldoc -f chomp
And then you want to get rid of those additional spaces when defining
$mypicture. Why did you put them in there?
And then you can use either a string
my $picture="$path$number$ext";
or a concatenation
my $picture=$path . $number . $ext;
but dots inside of a string are just that: dots.
Inserting slashes in the proper places is left as an excercise.
As far as the bogus system call is concerned: Did you mean something like
system "rm $mypicture";
If yes then I wonder why you are forking off an external process instead of
using Perl's unlink() command.
jue
------------------------------
Date: Sat, 13 Dec 2003 07:42:41 GMT
From: "Carlo Cazzaniga" <carlo.runner@libero.it>
Subject: Re: how to read data from EXCEL
Message-Id: <RpzCb.186680$e6.6985490@twister2.libero.it>
Thanks ,
but I'm not an expert , my environment is NT,
thweversion of perl is 5
How can I call the the mentioned Cpan module,
I don't use visual perl or other recently version.
I have coded a simple script..
Carlo
"Gunnar Hjalmarsson" <noreply@gunnar.cc> ha scritto nel messaggio
news:brd8sl$26s3e$1@ID-184292.news.uni-berlin.de...
> Carlo Cazzaniga wrote:
> > I need to read data from EXCEL worksheets...
>
> Use the CPAN module Spreadsheet::ParseExcel::Simple.
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>
------------------------------
Date: Sat, 13 Dec 2003 06:34:58 GMT
From: "Fengshui" <test@test.com>
Subject: How to write MIME header for application/x-javascript?
Message-Id: <mqyCb.186402$Ec1.6996420@bgtnsc05-news.ops.worldnet.att.net>
I remember every CGI output must start as this:
print "text/html\n\n";
I guess what it does is it tells the client the type of the document as text
or html
I need to write a perl to let the client know it is a
application/x-javascript file.
What I try to do is that within the HTML page, there will be request for
extenal .js files, but I want the SRC="xxxx.cgi" and let the Perl script to
out put the .js file.
Anyone done this before?
------------------------------
Date: Sat, 13 Dec 2003 01:53:16 GMT
From: Sherm Pendley <spamfilter@dot-app.org>
Subject: Re: LWP install MacOS X
Message-Id: <giuCb.431$xH2.283611@news1.news.adelphia.net>
Henry wrote:
> I had your your post open on the desktop as I worked. I _thought_ I was
> doing what you said.
Sorry, my bad. I gave you outdated advice. :-(
Once upon a time, installing Bundle::CPAN would tickle the bug, whereas
installing just CPAN would not. So, the workaround was to install just
the module by itself, and once the module had been upgraded to a version
that didn't have the bug, then install the bundle.
As it happens, I've done some housecleaning recently, so I had a clean
Jaguar installation on another partition. So I booted into that and
tried upgrading CPAN.pm just to be certain, and sure enough, that
work-around no longer does the trick.
There are still some options - reconfiguring the CPAN shell to ask
before resolving dependencies, or not to resolve them at all, or
installing CPAN.pm by hand.
But you've indicated that you're not really interested in developing in
Perl, you just want to write a quick little script to get a job done.
With that in mind, upgrading CPAN.pm might be more trouble than it's
worth to you. If all you want is to install LWP, the CPAN.pm version
that you already have is perfectly capable of doing that.
>>The latest LWP version takes case-insensitive filesystems
>>into account, and will ask you before installing /usr/bin/HEAD. When it
>>asks about that, simply tell it not to.
>
> Yes, I can try.
FWIW, While I was experimenting with Jaguar, I installed Bundle::LWP
too. The current version doesn't try to install /usr/bin/HEAD unless you
specifically ask it to. When it asks if you want to install it, the
default is "n".
So basically, what you're left with is, don't bother upgrading the CPAN
shell if all you want is to install LWP. The bug in LWP has been fixed,
so simply entering "install Bundle::LWP" and accepting all the defaults
will safely install it.
sherm--
------------------------------
Date: Sat, 13 Dec 2003 07:01:32 GMT
From: Gerard Lanois <gerardlanois@netscape.net>
Subject: Re: Newsgroup Searching Program
Message-Id: <ullphtd4h.fsf@netscape.net>
Les Hazelton <seawolf@attglobal.net> writes:
> $port = '563';
> $nntp = Net::NNTP->new($SERVER, Debug=>0, Port=>$port)
> or die "Can't connect to server $SERVER: $!\n";
>
> Did I misunderstand how to supply the port number or ??
Looks good the way you have it.
Let's take Perl out of the equation.
What happens if you telnet into port 563 on the server?
You should be able to speak raw NNTP commands to it. And you might
get some useful error messages.
-Gerard
------------------------------
Date: Sat, 13 Dec 2003 03:25:40 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Passing a hash by reference
Message-Id: <3FDA861F.1030503@rochester.rr.com>
Niall Macpherson wrote:
> Apologies if this has been covered before - I have seen a number of
> posts on this subject but I still cannot work out my code doesn't
> work.
>
> I have been working with C / C++ for over 10 years and am fully
> conversant with pointers and passing by reference in C. However ,
> passing by reference in perl is causing me some problems.
>
> Here is a little bit of test code -
>
> ##----------------------------------------------------------------------
use strict;
use warnings;
If you had used warnings, Perl would have told you what was wrong. Let
Perl help you.
> sub AddHashEntries
> {
> my($rh_hashref) = @_;
> for($cnt = 0; $cnt < 10; $cnt ++)
> {
> $value = "value " . $cnt;
> $key = "key" . $cnt;
> $$rh_hashref{$key} = $value;
> }
> return;
> }
> ##----------------------------------------------------------------------
> sub PrintHashEntries
> {
> my($rh_hashref) = @_;
>
> foreach my $key (keys $$rh_hashref)
%-----------------------------^
That won't compile. Keys expects a hash, not a scalar.
> {
> print("\nKey = [$key], value = $$rh_hashref{$key}");
> }
> return;
> }
> ##----------------------------------------------------------------------
> my %testhash = {};
()---------------^^
Using {} generates a scalar value which is a reference to an anonymous
hash. That is the "weird" value that is showing up in your printed hash
contents. This hash reference goes in as a key; keys must be strings,
so it is stringified, and this stringified hash reference is the
HASH(0x1abefac) key in your output. The value is the empty string
because %testhash = expects to find a list with an even number of
entries; if an odd number (like one) is present, Perl emits a warning
(if you asked for warnings as you should during development) and assigns
undef as the value.
> AddHashEntries(\%testhash);
> print("\nAdded all entries OK");
> foreach my $lkey (keys %testhash) ## *** 1 ****
> {
> print("\nKey = [$lkey], value = $testhash{$lkey}");
> }
> PrintHashEntries(\%testhash);
> ##----------------------------------------------------------------------
>
>
> The values appear to get added to hash OK - the call at *** 1 ****
> produces output as I would expect , eg
>
> Added all entries OK
> Key = [key7], value = value 7
> Key = [HASH(0x1abefac)], value =
> Key = [key8], value = value 8
> Key = [key9], value = value 9
> Key = [key0], value = value 0
> Key = [key1], value = value 1
> Key = [key2], value = value 2
> Key = [key3], value = value 3
> Key = [key4], value = value 4
> Key = [key5], value = value 5
> Key = [key6], value = value 6
>
> However , I can't even get the PrintHashEntries routine to compile - I
> get
>
> Type of arg 1 to keys must be hash (not scalar dereference) at
> C:\MoreTestStuff\
> GMPriceConf\hashreftest.pl line 20, near "$rh_hashref)
> "
> Execution of C:\MoreTestStuff\GMPriceConf\hashreftest.pl aborted due
> to compilat
> ion errors.
...
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Fri, 12 Dec 2003 14:31:50 +1100
From: "Jeff" <jeffcrow(AT)tpg.com.au>
Subject: REQUEST: Problem with Perl (Win32) on Windows98SE and reading files
Message-Id: <3fda88a4$2@dnews.tpgi.com.au>
Hi all
I don't usually follow these groups so replies to my email
(jeffcrow(AT)tpg.com.au) would be preferred in addition to posts to the
group. Thanks.
I am having problems reading a file from a perl script running under
windows98se. This seems to be a recent problem as I've had several scripts
in the past work fine. The general flow of data is;
Data in a spreadsheet in OpenOffice.org 1.1 is output as text file to a dir.
A perl script is kicked off to read all files in the dir and process the
data for output as webpages. I was trying to read files in a dir in a
scalar context but when I was having problems I changed to an array context.
A snip of code is now;
opendir(OUTDOOR, "${autodir}") || die "Can't open the dir ${autodir}";
@files = readdir(OUTDOOR);
closedir(OUTDOOR);
foreach $file (@files) {
TEST READABLE
IF !READABLE
CHANGE MODE TO READABLE OR DIE WITH ERROR MESSAGE
}
What I get as output is 'File is not readable and permissions can't be
changed'. I have checked the directories in the path (\auto\process0) to
ensure they are visible and readable. I have checked the files in the dir
are visible and readable. I have opened the files in a text editor and they
are readable and plain text. I have opened a console/MS-DOS Prompt window
and opened the file with "edit test.out" and viewed the contents fine.
I wrote a perl script that creates some file in the directory and puts some
text into the file. I then close the file, sleep for 30 seconds and then
readdir(directory) and again the files are reported as NOT readable and
permissions can't be changed. Again, the file I output is fine and readable
in consoles, editors etc.
I deleted the version of perl I was using (Activestate 5.?? I can't recall)
cleaned the REGISTRY and installed a GNU perl 5.004_02 and still the same
problem.
Short of running this under LINUX as I would ordinarily do, can any win32
Perl guru offer any assistance?
Thanks in advance for any and all for assistance provided.
Jeff
------------------------------
Date: Sat, 13 Dec 2003 04:54:14 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: REQUEST: Problem with Perl (Win32) on Windows98SE and reading files
Message-Id: <3fda9949.518727501@news.erols.com>
"Jeff" <jeffcrow(AT)tpg.com.au> wrote:
: opendir(OUTDOOR, "${autodir}") || die "Can't open the dir ${autodir}";
: @files = readdir(OUTDOOR);
: closedir(OUTDOOR);
: foreach $file (@files) {
: TEST READABLE
: IF !READABLE
: CHANGE MODE TO READABLE OR DIE WITH ERROR MESSAGE
: }
:
: What I get as output is 'File is not readable and permissions can't be
: changed'.
Murphy is telling me the problem is somewhere in those paraphrased lines.
It's impossible to diagnose boguscode accurately.
You've probably made a mistake using the return from readdir()--a mistake
so common that half of the documentation for readdir() is there to ensure
you don't make it.
[...]
If you're planning to filetest the return values out of a
"readdir", you'd better prepend the directory in question.
Otherwise, because we didn't "chdir" there, it would have
been testing the wrong file.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5935
***************************************