[18662] in Perl-Users-Digest
Perl-Users Digest, Issue: 830 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 4 00:06:01 2001
Date: Thu, 3 May 2001 21:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988949109-v10-i830@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 3 May 2001 Volume: 10 Number: 830
Today's topics:
a few quick questions <jnross@mtu.edu>
Re: a few quick questions <tony_curtis32@yahoo.com>
Re: a few quick questions <jboes@qtm.net>
Re: a few quick questions <jboes@qtm.net>
Re: a few quick questions (Tad McClellan)
Re: Algorithm ? <mischief@velma.motion.net>
Re: Alorithm ? addendum <bwalton@rochester.rr.com>
Any tip on accessing DB2 from NT (DBD::DB2 is not provi <mnarvaja@geocities.xyz.com>
Re: calling C functions (Martien Verbruggen)
CGI with conditional GET <goldbb2@earthlink.net>
cookie expiry <troyr@vicnet.net.au>
Re: DB_File make test failed <Juha.Laiho@iki.fi>
Re: Does 'exec' never fail? <time4tea@monmouth.com>
Re: Does 'exec' never fail? (Logan Shaw)
Downloading images with HTTP/LWP libraries <rhughes@fas.harvard.edu>
efficient <jhall@ifxonline.com>
Familiar with this perl fix permission script <newuser@nospam.slip.net>
Re: Familiar with this perl fix permission script <admin@bestwebscripts.com>
Re: flushing to gdbdm files <bwalton@rochester.rr.com>
Re: FTP->new <ravikrishna@nospam.com>
Re: help with parsing files <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 3 May 2001 21:46:55 -0400
From: "Joseph N Ross" <jnross@mtu.edu>
Subject: a few quick questions
Message-Id: <tf42dpr6m52e2a@corp.supernews.com>
1. Can anyone recommend a good book to learn perl for someone with
significant programming experience? preferably a book that is more of a
reference (function definitions with examples, or something like that)?
2. Is there any way to include a query string (the type that ends up in
URLs: http:// . . ./cgi-bin/perlscript.pl?[querystring]) but still the the
standard command "perl (filename)" so I can get a bug report?
Sorry to clog the newsgroup.
thanks
Joseph N Ross jnrossmtu@hotmail.com
------------------------------
Date: 03 May 2001 20:50:49 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: a few quick questions
Message-Id: <87r8y5j30m.fsf@limey.hpcc.uh.edu>
>> On Thu, 3 May 2001 21:46:55 -0400,
>> "Joseph N Ross" <jnross@mtu.edu> said:
> 1. Can anyone recommend a good book to learn perl for
> someone with significant programming experience?
> preferably a book that is more of a reference (function
> definitions with examples, or something like that)?
You probably just(?) need to get up to speed with the perl
idiom then. Try inhaling this link:
http://www.perl.com/pub/v/documentation
If you really want some Tree::Dead stuff:
http://www.perl.com/reference/query.cgi?books
> 2. Is there any way to include a query string (the type
> that ends up in URLs: http://
> . . ./cgi-bin/perlscript.pl?[querystring]) but still the
> the standard command "perl (filename)" so I can get a
> bug report?
I think you need to try that one again. It's unparseable.
Guess: use CGI.pm's, q.v., debugging facilities. You can
run the CGI program from the command line and pass the
key/value pairs on stdin.
hth
t
--
Just reach into these holes. I use a carrot.
------------------------------
Date: Thu, 03 May 2001 22:23:23 -0400
From: Jeff Boes <jboes@qtm.net>
Subject: Re: a few quick questions
Message-Id: <m744ftotgjjud6f291f3lu5fq1r49k0q53@4ax.com>
At some point in time, "Joseph N Ross" <jnross@mtu.edu> wrote:
>1. Can anyone recommend a good book to learn perl for someone with
>significant programming experience? preferably a book that is more of a
>reference (function definitions with examples, or something like that)?
Practically a FAQ. Check groups.google.com (the Deja.com heritage...) and look
in this newsgroup for 'book' in the subject. My personal favorites are here:
http://www.effectiveperl.com/
http://www.wiley.com/compbooks/stein/
http://www.oreilly.com/catalog/cookbook/
http://www.perl.com/language/critiques/ppc.html
>2. Is there any way to include a query string (the type that ends up in
>URLs: http:// . . ./cgi-bin/perlscript.pl?[querystring]) but still the the
>standard command "perl (filename)" so I can get a bug report?
Huh? Do you mean, "can you run your CGI script from the command line and feed it
a query string"?
If you are using CGI.pm, the answer's in the perldoc for that module (use
$ perldoc CGI
and look for the DEBUGGING topic). If you aren't (why not? Think you are better
than 95% of the Perl/CGI coders out there??), then you have to be clever and set
the environment variable QUERY_STRING to the appropriate stuff.
--
~~~~~~~~~~~~~~~~|It is by caffeine alone I set my mind in motion,
Jeffery Boes |It is by the beans of Java that thoughts acquire speed,
jboes@qtm.net |The hands acquire shaking, the shaking becomes a warning,
UIN 3394914 |It is by caffeine alone I set my mind in motion.
------------------------------
Date: Thu, 03 May 2001 22:30:30 -0400
From: Jeff Boes <jboes@qtm.net>
Subject: Re: a few quick questions
Message-Id: <2154ft42phu0mjkr1dni0uknasmvphu9od@4ax.com>
At some point in time, Jeff Boes <jboes@qtm.net> wrote:
>Practically a FAQ. Check groups.google.com (the Deja.com heritage...) and look
>in this newsgroup for 'book' in the subject. My personal favorites are here:
I should have also pointed out that
http://www.perl.com/reference/query.cgi?section=books&x=20&y=15
covers the Perl book field pretty thoroughly, too.
--
~~~~~~~~~~~~~~~~|It is by caffeine alone I set my mind in motion,
Jeffery Boes |It is by the beans of Java that thoughts acquire speed,
jboes@qtm.net |The hands acquire shaking, the shaking becomes a warning,
UIN 3394914 |It is by caffeine alone I set my mind in motion.
------------------------------
Date: Thu, 3 May 2001 22:47:53 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: a few quick questions
Message-Id: <slrn9f462p.256.tadmc@tadmc26.august.net>
Joseph N Ross <jnross@mtu.edu> wrote:
^^^
Hiya toot!
>Subject: a few quick questions
^^^^^
Then there should be one post for each subject with an appropriate
Subject (one that indicates what is in the body).
The other 199 posts here today also contain questions. Your Subject
is (worse than) useless.
>1. Can anyone recommend a good book to learn perl for someone with
>significant programming experience? preferably a book that is more of a
>reference (function definitions with examples, or something like that)?
The best Perl references are the docs that ship with perl.
If you are in a hurry, get "Learning Perl" to get up to speed the fastest.
Otherwise, start plowing through the docs:
perldoc perldoc
perldoc perl
Lemme skim through that big ol' list of docs and try to pare
it down to something less daunting:
Required reading:
perldata Perl data structures
perlsyn Perl syntax
perlop Perl operators and precedence
perlre Perl regular expressions
perlrun Perl execution and options
perlfunc Perl builtin functions
perlvar Perl predefined variables
perlsub Perl subroutines
Required reading if you plan to post to Usenet:
perlfaq Perl frequently asked questions
After all of that:
perlreftut Perl references short introduction
perlref Perl references, the rest of the story
perldsc Perl data structures intro
perllol Perl data structures: arrays of arrays
If you want to do OO:
perlboot Perl OO tutorial for beginners
perltoot Perl OO tutorial, part 1
perltootc Perl OO tutorial, part 2
perlobj Perl objects
You don't really need to read it, but you should know to
look up messages you get from perl in:
perldiag Perl diagnostic messages
( but you don't really _read_ perlfunc. It's awfully big. You skim
looking for "interesting" functions. Processing the perlfunc.pod
file to produce a list of Perl's functions is a good first project
for flexing your Perl muscles.
)
>2. Is there any way to include a query string (the type that ends up in
>URLs: http:// . . ./cgi-bin/perlscript.pl?[querystring]) but still the the
>standard command "perl (filename)" so I can get a bug report?
huh?
You seem to be saying something about a GET HTTP request?
The LWP::UserAgent module can do that.
>Sorry to clog the newsgroup.
We wouldn't have minded as much if "book for experienced programmer"
and "somthing unintelligible about query strings" were in the
Subject header.
Because then other members of the community might find the answer
to _their_ question. I doubt that your choice of Subject helps
anyone. Probably even hurts your chances of getting an answer.
Please take a bit of care when composing your 40 precious characters
of Subject. You are in competition with a couple hundred other folks.
The ones with the best Subjects win.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas BSEE, MTU 1985
------------------------------
Date: Thu, 03 May 2001 23:40:27 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Algorithm ?
Message-Id: <tf3r3bqfnpbi97@corp.supernews.com>
Doug O'Leary <dkoleary@ro05-24-29-232-217.ce.mediaone.net> wrote:
> The part I'm having a problem with is how to limit the processing. If
> the outer loop is reading the file, I have 600+ children which is a
> tad ... excessive.
> If I loop through the index, then how do I know when I can kick off
> another child? For instance:
There has been some good advice given already, but please notice
that there are many, many threads on Google about this.
Going to http://groups.google.com and entering 'Perl children'
in the main search box brings up 'about 16,400' posts in '0.52
seconds'. Here's the URL of the search results (URL wraps at ?):
http://groups.google.com/groups?
q=Perl+children&btnG=Search&meta=site%3Dgroups
Although I was pleasantly surprised to find my name next to
the first post listed, I think that post may help in this
situation.
I you wanted to narrow a search down a little better,
you might go to Google and go to their Advanced Search,
then tell it you want hits within comp.lang.perl.*
and that your keywords should be something like
'fork children limit'. Then you would get a URL such as
( URL wrapped at certain q{&} ):
http://groups.google.com/groups?as_q=fork+children+limit&
num=10&as_scoring=relevance&btnG=Google+Search&as_epq=&
as_oq=&as_eq=&as_ugroup=comp.lang.perl.%2A&as_usubject=&
as_uauthors=&as_umsgid=&lr=&as_drrb=quick&as_qdr=&
as_mind=29&as_minm=3&as_miny=1995&as_maxd=3&as_maxm=5&
as_maxy=2001
This will cut out a lot of examples, but it still shows almost
the exact problem answered many times in many ways by many
people. There are still some posts about slightly different
topics, but you should have enough from which to start.
Please, tell everyone you know that there is a newsgroup
archive at groups.google.com and that they should check there
if they think a question seems pretty common.
Chris
--
The purpose of a language is not to help you learn the
language, but to help you learn other things by using the
language. --Larry Wall, The Culture of Perl, August 1997
------------------------------
Date: Fri, 04 May 2001 03:00:24 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Alorithm ? addendum
Message-Id: <3AF21B88.B19F8A7C@rochester.rr.com>
Doug O'Leary wrote:
...
> Thanks again for the help yesterday. I finally have something
> working. The question is how come what I had originally
> wasn't working?
<code deleted>
> This works; I was originally reading each line within the loop
> as shown on line 19. Doing that, however, my output was
> completely mucked - lines munged together and other lines in the
> file were duplicated several times.
>
> Once I read the file into an array (#12/13), then iterated through the
> array, it worked perfectly.
>
> I guess it's a moot point, but I'm curious what happened with the
> file handle between the various forks.
...
> Doug
...
Would the following from perldoc -f fork be of help in explaining what
happened?:
File descriptors (and sometimes locks on those descriptors) are shared,
while everything else is copied.
--
Bob Walton
------------------------------
Date: Thu, 3 May 2001 20:22:25 -0300
From: "Marcelo Narvaja" <mnarvaja@geocities.xyz.com>
Subject: Any tip on accessing DB2 from NT (DBD::DB2 is not provided) ?
Message-Id: <3af1e98d_3@news1.prserv.net>
Hi all,
I want to use Db2 from Perl the same way I do it manually.
I use to connect from the command prompt and perform a query
typing:
db2 "select ... etc" > output.txt
The problem is that this is possible from db2cmd window.
I could execute a program using system this way:
$RC = system("db2cmd runqueries.pl");
but I need the return code from the program, and this call
always return me zero.
Any tip? Suggestion?
Thanks in advance,
Marcelo
mnarvaja@geocities.com
------------------------------
Date: Fri, 4 May 2001 08:19:22 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: calling C functions
Message-Id: <slrn9f3mba.v5e.mgjv@martien.heliotrope.home>
On Thu, 03 May 2001 12:25:37 GMT,
Bart Lateur <bart.lateur@skynet.be> wrote:
> nobull@mail.com wrote:
>
>>FAQ: "Where can I learn about linking C with Perl?"
>>
>>You are expected to check the FAQ _before_ you post.
>
> That FAQ entry *only* talks about using XS. This is not the easiest way.
Maybe Brian Ingerson would like to update that FAQ, and a few around it,
a little? Just suggesting Brian since he's the author of one of the most
easily accessible C-linking options for Perl: Inline::C, and therefore
probably would have an accurate amount of information available...
Every time I open my mouth about XS, I get corrected by one of the p5p
telling me that XS has evolved way past what I just said. Would be nice
if the documentation also evolved as quickly :)
Martien
--
Martien Verbruggen | Since light travels faster than
Interactive Media Division | sound, isn't that why some people
Commercial Dynamics Pty. Ltd. | appear bright until you hear them
NSW, Australia | speak?
------------------------------
Date: Fri, 04 May 2001 01:56:47 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: CGI with conditional GET
Message-Id: <3AF20D9D.6069719E@earthlink.net>
The http 1.0 standard descripes how a conditional GET can be done, using
an if-modified-since field in the request header.
If I'm writing a CGI which uses GET (not post), and generates all data
from it's parameters (no external files, nothing which comes from
outside the script), then I always want to respond "304 not modified"
in response to a request that has an if-modified-since header, since the
requester obviously has whatever it is that I might send him (unless the
script changes). How do I test for the existance of this header?
#!perl -w
use CGI;
use Date::Parse;
my $query = new CGI;
if( $query-> ???? has an if-modified-since header ) {
my $d0 = str2time($query-> ???? for if-modified-since value);
my $d1 = (stat($0))[9];
if( $d0 == $d1 ) {
print $query->header(-status => '304 not modified');
exit;
}
}
&other_stuff_here;
Yes, I know of the expires parameter for header, but that's not what I
want -- especially during the development stages of a script.
--
Shift to the left, shift to the right, mask in, mask out, BYTE, BYTE,
BYTE !!!
------------------------------
Date: Fri, 4 May 2001 09:46:05 +1000
From: "Troy Boy" <troyr@vicnet.net.au>
Subject: cookie expiry
Message-Id: <b8mI6.858$ZJ.22948@ozemail.com.au>
Hi there,
I have troubles resetting cookie expiry time in IE and some
versions of Netscape on Linux.
The code i use is as follows
$the_cookie = cookie(-name=>'sid',
-value=>$session_id,
-expires=>'+2m',
-domain=>'.vicnet.net.au',
-path=>'/');
print header(-cookie=>$the_cookie);
Time passes..........The user hits on a log out button and the same code is
called..but the expires variable gets reset to '1s' .My problem is...that it
doesn't take this into account..and keeps the cookie active till the 2
minutes have passed.
Has anyone come across this problem..?
--
----------------------------------------------------------------
Troy Rasiah
Melbourne, Aus
------------------------------
Date: 3 May 2001 17:11:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: DB_File make test failed
Message-Id: <9cs3f5$v9v$1@ichaos.ichaos-int>
duverm@hotmail.com said:
>Could somebody please help me?? I've downloaded and installed DB_File v1.77.
>My Perl version is 5.6.0. I am running on HPUX 11. The install went fine, but
>the test bombs (see below.) I don't even know where to go from here.
...
>$ make test
>PERL_DL_NONLAZY=1 /opt/perl5/bin/perl -Iblib/arch -Iblib/lib -I/opt/perl
>5/lib/5.6.0/PA-RISC1.1 -I/opt/perl5/lib/5.6.0 -e 'use Test::Harness qw(&runtests
>$verbose); $verbose=0; runtests @ARGV;' t/*.t
>t/db-btree........../usr/lib/dld.sl: Unresolved symbol: pthread_cond_wait (code)
...
I think I've seen this one.
The 'configure' for db has built the library with thread support, yet
I'd guess your perl is built without threads.
I solved this by adding '-lpthread' to the library list within DB_File
Makefile.PM and rebuildig DB_File.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++ UL++++$ P++@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5 !X R tv--- b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Thu, 3 May 2001 20:58:55 -0400
From: "James Richardson" <time4tea@monmouth.com>
Subject: Re: Does 'exec' never fail?
Message-Id: <9csv0k$ldi$1@slb1.atl.mindspring.net>
"Bernie Cosell" <bernie@fantasyfarm.com> wrote in message
news:eitvetoa1jti8fbk8c5bku623bhelpp7p9@news.supernews.net...
> eins@durchnull.de (Rudolf Polzer) wrote:
>
> What's bizarre is that it can *NEVER* be a 'feature' -- it is, IMO, very
> bad programming practice not to check for errors [don't folk HARP on that
> around here all the time]. Plain and simple, exec can/does fail and perl
> basically encourages you to program poorly/dangerously [as I mentioned:
ala
> the 'forgetting to put an exit in the child fork branch' -- if, say, your
> PATH is wrong and you can't find the program to exec, instead of dealing
> with it gracefully, your program will just run onto what random code came
> next in the source... that *can't* be a good programming practice to
> virtually force on folk.
>
>
Yeah... I agree!
However, PATH is a convenience for people typing at the keyboard, I can
think of no reason to ever rely on it from within a program.
If you _must_ use it, then at least bother to find the program in PATH
yourself, and pass the whole program name to exec()
This is a possible solution, hopefully being reasonably careful to check for
errors.
Cheers
James
BTW: Theres another argument here about return undef vs. return, but I wont
go into that.
require "sys/syscall.ph";
sub run_program {
my ( $real_path, $nice_value, @args ) = @_;
if (! -x $real_path) {
Error ("File $real_path is not executable!");
return undef;
}
#$real_path is the path..... now we do a fork and exec
my $pid;
if ( defined($nice_value) && $nice_value != 0 && $nice_value > 0) {
Debug ( 1, "Setting nice value to $nice_value");
syscall ( &SYS_nice, $nice_value );
}
if ($pid = fork) {
#This is the parent, got child pid
Debug (2, "Forked, got PID = $pid");
}
elsif ($pid == 0) {
#This is the child....
Debug (1, "exec(): $real_path @args");
{ exec $real_path, @args };
#This should not be here....
Error ("Exec $real_path failed: $!");
exit (19); #Or you could do a return undef, but I figure exec failing
here (we know the path is executable) is probably real bad.
}
else {
#The fork failed.....
Error ("fork() failed: $!");
}
return $pid;
}
------------------------------
Date: 3 May 2001 21:15:33 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Does 'exec' never fail?
Message-Id: <9ct3c5$slv$1@boomer.cs.utexas.edu>
In article <9csv0k$ldi$1@slb1.atl.mindspring.net>,
James Richardson <time4tea@monmouth.com> wrote:
>However, PATH is a convenience for people typing at the keyboard, I can
>think of no reason to ever rely on it from within a program.
I can think of a great reason: you don't want your program to have to
be changed to include the full path of the program when it can
just find it through $PATH already.
This is especially true if people share a home directory (or whatever
directory the program is installed in) across machines. The desired
executable may be in different places on different hosts.
However, it is true that using the PATH means that you are relying on
the user having things set up correctly to work with your program.
And that's not always a safe assumption.
To me, then, the question is almost whether you want to make it easier
for users who have things set up wrong or easier for users who have
things set up right. :-) (Actually, there are other reasons to have
the "wrong" version of a command in the PATH -- one is that the program
requires a certain version, but you prefer another.)
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: Thu, 3 May 2001 23:20:19 -0400
From: "Robert Hughes" <rhughes@fas.harvard.edu>
Subject: Downloading images with HTTP/LWP libraries
Message-Id: <9ct72a$71u$1@news.fas.harvard.edu>
I'm trying to figure out how to download an embedded image
in a web page using the HTTP/LWP libraries. Right now,
I'm resorting to submitting a request with the image's URL.
This creates two problems:
1) The image I get when I save $request->content to a
file is very distorted.
2) In response to a request like http://www.foo.com/bar.jpg
some websites give an html page with bar.jpg embedded.
In this case, all I get in $request->content is the HTML code.
Here's the code I'm using now:
use HTTP::Request;
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$request = HTTP::Request->new('GET',
'http://www.foo.com/bar.jpg');
$request->header(Accept => "image/*");
$response = $ua->request($request);
open (OUTPUT, ">result.jpg");
print OUTPUT $response->content;
close OUTPUT;
Any suggestions on how to do this better?
Thanks.
-Rob
------------------------------
Date: Fri, 04 May 2001 00:23:26 GMT
From: "John Hall" <jhall@ifxonline.com>
Subject: efficient
Message-Id: <2EmI6.5686$t27.278946@news1.rdc1.sdca.home.com>
just when i thought i was writing good code, i revisited a subroutine...
and shortened it from 15 lines to 3.
!
just a note that everyone should keep at it!
http://moron.shutdown.com
------------------------------
Date: Thu, 3 May 2001 18:57:02 -0700
From: "newuser" <newuser@nospam.slip.net>
Subject: Familiar with this perl fix permission script
Message-Id: <mYnI6.227$Zd3.523@news2.dnvrcoidc.firstworld.net>
Hello,
Every once in awhile my shell account goes crazy and it never puts the
correct permission as I ask for. The tech from my isp always has to do a
ls -lag which he
says that only techs can do. He mentioned that there is a work around to
this if I know how to write a perl script that runs the following command
"chmod 777 1/u3/r/t/trrttt/public/test/test2/* 2> /dev/null
Have anyone seen a script that can do this and if so can they post it
here. I would also like if someone can explain to me how this works.
thanks a lot for your help
------------------------------
Date: Fri, 04 May 2001 06:13:00 +0400
From: Serge <admin@bestwebscripts.com>
Subject: Re: Familiar with this perl fix permission script
Message-Id: <3AF2102C.9AC67E16@bestwebscripts.com>
Hello,
why not try
system("chmod 777 1/u3/r/t/trrttt/public/test/test2/* 2> /dev/null");
newuser wrote:
>
> Hello,
> Every once in awhile my shell account goes crazy and it never puts the
> correct permission as I ask for. The tech from my isp always has to do a
> ls -lag which he
> says that only techs can do. He mentioned that there is a work around to
> this if I know how to write a perl script that runs the following command
> "chmod 777 1/u3/r/t/trrttt/public/test/test2/* 2> /dev/null
> Have anyone seen a script that can do this and if so can they post it
> here. I would also like if someone can explain to me how this works.
> thanks a lot for your help
--
CGI Scripts and Services
http://bestwebscripts.com
------------------------------
Date: Fri, 04 May 2001 03:38:29 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: flushing to gdbdm files
Message-Id: <3AF2246F.F2361378@rochester.rr.com>
Diana McCarthy wrote:
>
> I wish to flush buffers at specific points in my program. I can see that
> $oldfh = select("FILE");
------------------^^^^^^
Better stated as select(FILE) -- there is no need for the "'s.
> $| = 1;
>
> will flush FILE automatically, (presumably until I change back with $| = 0).
> Can I flush to GBDM files
...
> Diana
Hmmmmm...I don't think DBM-style tied hash files are buffered to start
with, so there should be no point to flushing them. You could, of
course, force matters by untie'ing them and then tie'ing them again if
there is any doubt (since there is no filehandle associated with tied
hash files, they can't be select'ed or have $| applied). If you are
worried about contention between different processes which may have the
tied hash file open simultaneously, note that it is necessary to apply
cooperative locking during the time the hash is tied to the file. In
other words, never have a tied hash file tied by two processes
simultaneously -- it won't work reliably, unless they both only read.
--
Bob Walton
------------------------------
Date: Thu, 03 May 2001 23:26:30 GMT
From: <ravikrishna@nospam.com>
Subject: Re: FTP->new
Message-Id: <GOlI6.8005$_f3.133477@news20.bellglobal.com>
Thanks. It worked.
Now the next question. Some of the files I am ftping are
huge files (80MB). Most of the time ftp fails after 35 MB or so.
No it has nothing to do with timeout since I have set it to
36000 ( 10 hrs). I know we are having bandwidth problems.
Could it be due to that?
Also if I increase the blocksize (default 10K) to 40K as follows,
my $ftp = Net::FTP->new($machineName,Timeout => 36000,BlockSize => 40960);
will it make FTP faster and more reliable.
thanks.
Ravi.
"Milton Road" <miltonroad@btinternet.com> wrote >
> > I am using perl FTP.
> >
> > my $ftp = Net::FTP->new($machineName,Timeout => 300) ;
> >
> > The timeout is in minutes right. So the default of 120 is 2 hours.
>
> Your timeout is in seconds, Ravi. Therefore the default of 120 is two
> minutes.
>
> Amazingly, the Net::FTP docs on the constructor don't seem to specify
> seconds - possibly because its reasonably self-explanatory.
>
> Anyway, you know now.
>
> Milton
>
>
>
>
>
------------------------------
Date: Fri, 04 May 2001 03:20:03 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: help with parsing files
Message-Id: <3AF22024.99CAA88D@rochester.rr.com>
Patrick Joyce wrote:
>
> I want to create a perl program that will search through a bunch of html
> files
> outside of my root directory, find logo_small.gif and add the following
> after that line.
> <div align="right"><a href="http://207.244.72.79"><img
> src="../pix/checkout.gif" width="120" height="20" alt="Go to Checkout"
> border="0"></a></div>
> This is what i have so far but it still doesnt
> seem to be working.
> it goes through all the folders but doesnt modify any files. If anybody can
> help me please reply
> or E-Mail me at joycefive@earthlink.net
...
> opendir (SSS, $sss_path);
-------------------------^^
insert or die "Oops, that wasn't so good, $!"
...
> foreach $file (<"$path/*.html">) {
-------------------^------------^
Remove the quotes, and you'll probably fare better. Check out the
syntax of <...> in perldoc perlop, in the I/O operators section. Your
filenames don't contain the " characters, so they shouldn't appear in
the filename pattern.
>
> open (OLD, $file);
--------------------^^
insert or die "Oops, that didn't work, $!"
>
> open (NEW, ">$file.x");
insert or die here also--^^
...
> unlink $file;
test for success
> rename "$file.x", $file;
test for success
...
--
Bob Walton
------------------------------
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 830
**************************************