[24188] in Perl-Users-Digest
Perl-Users Digest, Issue: 6380 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 10 03:05:52 2004
Date: Sat, 10 Apr 2004 00:05:08 -0700 (PDT)
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, 10 Apr 2004 Volume: 10 Number: 6380
Today's topics:
Re: "perl -w" vs "use warnings" <jtc@shell.dimensional.com>
Re: "perl -w" vs "use warnings" <remorse@partners.org>
Re: "perl -w" vs "use warnings" (neo88)
Re: Archive::Zip Adding files with out directory info (Aqua)
CGI query - paths and locations <sandem_uk@yahoo.co.uk>
Re: CGI query - paths and locations <noreply@gunnar.cc>
Re: Cygwin and path question <ddunham@redwood.taos.com>
Re: Design choice: subclassing or "supplementing" <dwall@fastmail.fm>
Re: Design choice: subclassing or "supplementing" (Anno Siegel)
Re: File::Tail just...stops. <wherrera@lynxview.com>
How can this be done? <ducott_99@yahoo.com>
Re: How can this be done? <postmaster@castleamber.com>
Re: How can this be done? <ducott_99@yahoo.com>
Re: How can this be done? <wherrera@lynxview.com>
Re: How can this be done? <Petri_member@newsguy.com>
Re: How can this be done? <jtc@shell.dimensional.com>
Re: HTML Tag Counter (Shah Karim)
Re: Initializing an anonymous hash (repost) ctcgag@hotmail.com
Re: MySQL perl script <mr@sandman.net>
Parallel Parser IPC and IO - Need Direction (dwknapp)
Perl Timer (jon)
Re: Perl Timer <glex_nospam@qwest.invalid>
Re: problem calling perl script from SOAP server perl s (pj)
Recompile perl with cpan-shell? <holger@marzen.de>
Re: Win32::OLE / WMEncoderAgent issue (Simon Lockhart)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Apr 2004 14:16:01 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: "perl -w" vs "use warnings"
Message-Id: <slrnc7e141.vge.jtc@shell.dimensional.com>
In article <_yudc.97920$gA5.1309464@attbi_s03>, Joe Smith wrote:
> Jim Cochrane wrote:
>
>> In article <4075da0d$0$24341$58c7af7e@news.kabelfoon.nl>, John Bokma wrote:
>>>>>#!/usr/bin/perl -w
>>>
>>>use warnings;
>>>
>>>not -w
>>
>>
>> Sorry to get off the topic of the thread, but I've been wondering whether
>> it's best to include "use warnings" in a module file or just use the -w
>> option when the program is run. So, with that background, I'll ask:
>>
>> Why do you suggest the "use warnings" method?
>
> Some modules produce warnings when processed with -w, which affects
> all files the compiler processes. "use warnings;" is file-scoped.
> -Joe
I see - It gives you more control, eliminating unecessary and distracting
warnings.
Thanks!
--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
------------------------------
Date: Fri, 09 Apr 2004 16:28:31 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: "perl -w" vs "use warnings"
Message-Id: <remorse-EBB949.16283109042004@plato.harvard.edu>
In article <slrnc7e141.vge.jtc@shell.dimensional.com>,
Jim Cochrane <jtc@shell.dimensional.com> wrote:
> In article <_yudc.97920$gA5.1309464@attbi_s03>, Joe Smith wrote:
> > Jim Cochrane wrote:
> >> Sorry to get off the topic of the thread, but I've been wondering whether
> >> it's best to include "use warnings" in a module file or just use the -w
> >> option when the program is run. So, with that background, I'll ask:
> >>
> >> Why do you suggest the "use warnings" method?
> >
> > Some modules produce warnings when processed with -w, which affects
> > all files the compiler processes. "use warnings;" is file-scoped.
> > -Joe
>
> I see - It gives you more control, eliminating unecessary and distracting
> warnings.
>
> Thanks!
One note though -- some locations may still have a version of perl <
5.6.1. For these computers, you need to use '-w'.
Ricky
--
Pukku
------------------------------
Date: 9 Apr 2004 14:00:13 -0700
From: solo88@truevine.net (neo88)
Subject: Re: "perl -w" vs "use warnings"
Message-Id: <6a73bb68.0404091300.340dc23@posting.google.com>
Joe Smith <Joe.Smith@inwap.com> wrote in message news:<_yudc.97920$gA5.1309464@attbi_s03>...
> Jim Cochrane wrote:
>
> > In article <4075da0d$0$24341$58c7af7e@news.kabelfoon.nl>, John Bokma wrote:
> >>>>#!/usr/bin/perl -w
> >>
> >>use warnings;
> >>
> >>not -w
> >
> >
> > Sorry to get off the topic of the thread, but I've been wondering whether
> > it's best to include "use warnings" in a module file or just use the -w
> > option when the program is run. So, with that background, I'll ask:
> >
> > Why do you suggest the "use warnings" method?
>
> Some modules produce warnings when processed with -w, which affects
> all files the compiler processes. "use warnings;" is file-scoped.
> -Joe
well, -w is a much older command-line option to show interpeter
warnings before the script\program ran. Now Larry has come up with
something I guess he thinks is better.
use warnings;
this alows the programmer to custimize the warning output a wee bit.
use strict;
no vars;
etc. and like Joe said, use warnings is file scoped which can be nice.
------------------------------
Date: 9 Apr 2004 21:23:27 -0700
From: junk@dlink.org (Aqua)
Subject: Re: Archive::Zip Adding files with out directory info
Message-Id: <55d7995c.0404092023.e1bc2a4@posting.google.com>
> foreach my $file (@files) {
> $zip->addFile($file, basename($file));
> }
This is exactly what I wanted. Thank you
Dominic
------------------------------
Date: Fri, 9 Apr 2004 20:36:15 +0100
From: "Sandem" <sandem_uk@yahoo.co.uk>
Subject: CGI query - paths and locations
Message-Id: <LTCdc.49593$Id.47490@news-binary.blueyonder.co.uk>
Hi
I may be missing something but here goes...
I have been asked to move a website from one hoster to another. The
original hoster has CGi scripts enabled on the root of the website, the new
hoster only has them enable on the cgi-bin directory and will not enable in
the root.
My problem is that despite going through the cgi scripts and include files
when the scripts run i.e. index.cgi in the cgi-bin directory the generated
buttons to 'Home' and 'Shop' for instance (index.cgi and shop.cgi) show that
you will be running in the root i.e. www.website.com/index.cgi instead of
www.website.com/cgi-bin/index.cgi
Am I missing something silly?
Yours hopefully
Jonathan
------------------------------
Date: Fri, 09 Apr 2004 22:13:17 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI query - paths and locations
Message-Id: <c5707c$2pgnkc$1@ID-184292.news.uni-berlin.de>
Sandem wrote:
> I have been asked to move a website from one hoster to another.
> The original hoster has CGi scripts enabled on the root of the
> website, the new hoster only has them enable on the cgi-bin
> directory and will not enable in the root.
>
> My problem is that despite going through the cgi scripts and
> include files when the scripts run i.e. index.cgi in the cgi-bin
> directory the generated buttons to 'Home' and 'Shop' for instance
> (index.cgi and shop.cgi) show that you will be running in the root
> i.e. www.website.com/index.cgi instead of
> www.website.com/cgi-bin/index.cgi
If the scripts are decently designed, you should be able to fix it via
a couple of configuration settings. Otherwise there is more work involved.
> Am I missing something silly?
The person who decided to run CGI scripts from the document root,
without knowing that the site would never be moved to another shared
server, sure missed something. It's common practice on shared servers
to only allow CGI scripts in the cgi-bin.
Btw, do you have a Perl question?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 09 Apr 2004 21:35:25 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Cygwin and path question
Message-Id: <xGEdc.50002$Vi2.4455@newssvr25.news.prodigy.com>
G. Randall <me@nospam.net> wrote:
> 1. Are there any advantages (from an administrative point of view) to
> using Cygwin's perl vs. ActiveState's? My gut feeling is that Cygwin
> would require more work to maintain.
Cygwin perl can handle all the file pathing and other features of
cygwin. You can pass in files like /usr/local/foo. The AS perl can't
cope with that. You'd probably have to specify something closer to
C:/cywgin/usr/local/foo.
I generally have both installed on windows boxes that I'm using for a
long period of time, but I tend to work more with the AS copy for some
reason.
--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Fri, 09 Apr 2004 19:03:51 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Design choice: subclassing or "supplementing"
Message-Id: <Xns94C6993E413Edkwwashere@216.168.3.30>
J Krugman <jkrugman@yahbitoo.com> wrote:
> I have this class from CPAN (let's call it, creatively enough,
> Foo) that suits me fine in almost every respect, except for one
> workhorse method (say, bar) that I think could be significantly
> enhanced. One possibility would be to create a subclass MyFoo of
> Foo just for the purpose of overriding bar. Alternatively, I
> could have a file FooSupplement.pm, in which I do something like
[redefining a method instead of subclassing and overriding it]
I'm no OOP guru, in fact I'm a downright novice at OOP, so keep that
in mind.
Subclassing and overriding the method seems to me the better way.
If you simply redefine the method, then someone reading your code
might look at the docs for Foo.pm and then wonder why bar() is not
functioning as documented. Yes, they should have looked at the docs
for FooSupplement as well, but why look there for a method for a Foo
object?
If you subclass, then your "main" program says 'use MyFoo;' and the
maintenance programmer knows to look at MyFoo.pm instead of Foo.pm.
Once there, it's obvious you're subclassing because the first thing
there is
package MyFoo;
use base 'Foo';
And, of course, you've documented everything in pod and perhaps in
comments as well.
--
David Wall
------------------------------
Date: 9 Apr 2004 21:43:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Design choice: subclassing or "supplementing"
Message-Id: <c575e7$q5$1@mamenchi.zrz.TU-Berlin.DE>
J Krugman <jkrugman@yahbitoo.com> wrote in comp.lang.perl.misc:
>
>
>
>
> I have this class from CPAN (let's call it, creatively enough, Foo)
> that suits me fine in almost every respect, except for one workhorse
> method (say, bar) that I think could be significantly enhanced.
> One possibility would be to create a subclass MyFoo of Foo just
> for the purpose of overriding bar.
Overriding base class methods is more than just replacement. If
the base class uses the overridden method internally, it will call
the *overriding* method on objects from your (inheriting) class.
This is what allows old code to call new code in OO, and it is at the
heart of inheritance.
> Alternatively, I could have a
> file FooSupplement.pm, in which I do something like
>
> use strict;
> use warnings;
> package Foo;
> {
> no warnings 'redefine';
> sub bar {
> # raise the bar to perfection
> }
> }
> 1;
>
> Then, instead of using some subclass MyFoo, I use good ol' Foo
> followed by "use FooSupplement".
Boo!
That's called "intrusion into Foo's living-room", and in languages less
forgiving than Perl you can get shot for that. Perl allows it, but
it's only for emergencies, not for regular programming.
> I *suppose* (please correct me if I'm wrong) that this is yet
> another one of those choices that boils down to personal preference,
> but I'd love to take a very informal poll on what programmers here
> would typically prefer to do in such a situation.
I don't think it is a matter of much choice. If you can do what you
need to do via inheritance, go that way. You need very good reasons
to change into someone else's name space, and you'd limit the access
to the absolute minimum. I don't think you have such a situation.
Anno
------------------------------
Date: Fri, 09 Apr 2004 23:08:13 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: File::Tail just...stops.
Message-Id: <ZO2dncb7DsujHOrdRVn-vA@adelphia.com>
Don W. wrote:
> I wrote a program that would continuously dump the output of a file to
> syslog, using File::Tail and Tie::Syslog. Problem is, after about two
> days of operation, the program just stops tailing -- it's still
> running, and if I strace it, I can see that the file is being
> stat()ed, but no data is being sent across the wire to the syslog
> server. If I restart the program, it starts tailing again.
>
> Any clues? This is what I'm using for the File::Tail constructor:
>
> my $tail = File::Tail->new(
> 'name' => $file,
> 'maxinterval' => '1'
> );
>
Don't see anything wrong in what you've posted. If you are still
stumped, maybe you can try debugging by setting $tail->nowait(1); to not
wait and sleeping a second in the loop via sleep 1;, then printing a a
debug message within your loop, and see whether anything changes in the
file or object status after the two days.
--hth
------------------------------
Date: Sat, 10 Apr 2004 03:33:23 GMT
From: "Robert TV" <ducott_99@yahoo.com>
Subject: How can this be done?
Message-Id: <7WJdc.63724$oR5.3009@pd7tw3no>
I am trying to manipulate the data of my @rray based on the first character
of each array element. My array contains many names sorted alphabetically.
EG:
Adam
Aron
Brian
Bert
Chris
Daniel
Derk
Ernie
Frank
and so on ....
Now, I want my script to dected the first letter of the name and take action
based on it like this:
foreach $name (@names) {
if (first letter of $name eq "A" or "a") {
$condition = "True";
$name = "A:$name\n";
} else {
$condition = "False";
}
}
So if the above syntax was valid, the names in the @rray would now print
like this:
A:Adam
A:Aron
Brian
Bert
Chris
Daniel
Derk
Ernie
Frank
I realize the script above will only do "A" ... and i'll need to figure out
how to do the whole alphabet ... but one step at a time, still need some
help how to detect the first letter and take action if conditions meet. TIA
Randy
------------------------------
Date: Fri, 09 Apr 2004 23:18:59 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: How can this be done?
Message-Id: <407775b5$0$24346$58c7af7e@news.kabelfoon.nl>
Robert TV wrote:
> I am trying to manipulate the data of my @rray based on the first character
> of each array element. My array contains many names sorted alphabetically.
> EG:
>
> Adam
> Aron
> Brian
> Bert
> Chris
> Daniel
> Derk
> Ernie
> Frank
>
> and so on ....
>
> Now, I want my script to dected the first letter of the name and take action
> based on it like this:
>
> foreach $name (@names) {
> if (first letter of $name eq "A" or "a") {
> $condition = "True";
> $name = "A:$name\n";
> } else {
> $condition = "False";
> }
> }
>
> So if the above syntax was valid, the names in the @rray would now print
> like this:
>
> A:Adam
> A:Aron
> Brian
> Bert
> Chris
> Daniel
> Derk
> Ernie
> Frank
>
> I realize the script above will only do "A" ... and i'll need to figure out
> how to do the whole alphabet ... but one step at a time, still need some
> help how to detect the first letter and take action if conditions meet. TIA
Not enough info :-D. If you want different actions, you can make a hash
with references to subs, and use the first letter (perldoc -f substr) to
obtain (perldoc -f lc) the sub ref, and execute its sub.
But from the above it's really unclear what you want. For example,
$condition. Do you want 26 different ones? If you just want to prefix it
with caps first letter followed by :, use substr.
PS: use strict and use warnings on top of your script. I guess you don't
use those...
--
John personal page: http://johnbokma.com/
Experienced Perl / Java developer available - http://castleamber.com/
------------------------------
Date: Sat, 10 Apr 2004 04:31:01 GMT
From: "Robert TV" <ducott_99@yahoo.com>
Subject: Re: How can this be done?
Message-Id: <9MKdc.63896$oR5.8950@pd7tw3no>
> Not enough info :-D. If you want different actions, you can make a hash
> with references to subs, and use the first letter (perldoc -f substr) to
> obtain (perldoc -f lc) the sub ref, and execute its sub.
>
> But from the above it's really unclear what you want. For example,
> $condition. Do you want 26 different ones? If you just want to prefix it
> with caps first letter followed by :, use substr.
>
> PS: use strict and use warnings on top of your script. I guess you don't
> use those...
What I am trying to do is take action based on the first letter of the @rray
ellement. Ok, forget about the "A:" etc ect. Lets just say I wanted to do
this ... no @rrays ... just a normal string ...
$mystring = "Grettings fellow programmer";
if (first letter of $mystring eq "G") {
do this
} else {
do that
}
Once I have this basic piece of the puzzle, I can make the rest work. TIA
R
------------------------------
Date: Fri, 09 Apr 2004 23:24:28 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: How can this be done?
Message-Id: <foqdnZwTvuKTGOrdRVn-uQ@adelphia.com>
Robert TV wrote:
>>Not enough info :-D. If you want different actions, you can make a hash
>>with references to subs, and use the first letter (perldoc -f substr) to
>>obtain (perldoc -f lc) the sub ref, and execute its sub.
>>
>>But from the above it's really unclear what you want. For example,
>>$condition. Do you want 26 different ones? If you just want to prefix it
>>with caps first letter followed by :, use substr.
>>
>>PS: use strict and use warnings on top of your script. I guess you don't
>>use those...
>
>
> What I am trying to do is take action based on the first letter of the @rray
> ellement. Ok, forget about the "A:" etc ect. Lets just say I wanted to do
> this ... no @rrays ... just a normal string ...
>
> $mystring = "Grettings fellow programmer";
>
> if (first letter of $mystring eq "G") {
> do this
> } else {
> do that
> }
>
> Once I have this basic piece of the puzzle, I can make the rest work. TIA
untested--get Switch from CPAN:
#!/usr/bin/perl
use strict;
use warnings;
use Switch;
foreach my $phrase (@array) {
my $firstchar = lc substr($phrase, 0, 1);
switch($firstchar) {
case 'a' : { do_a($phrase) }
case 'b' : { do_b() }
case 'c' : { do_c($etc_and_so_forth) }
else { do_else_stuff() }
}
}
------------------------------
Date: 9 Apr 2004 22:56:41 -0700
From: Petri <Petri_member@newsguy.com>
Subject: Re: How can this be done?
Message-Id: <c582ap02co5@drn.newsguy.com>
In article <9MKdc.63896$oR5.8950@pd7tw3no>, Robert TV says...
> What I am trying to do is take action based on the first letter of
> the @rray ellement. Ok, forget about the "A:" etc ect. Lets just say
> I wanted to do this ... no @rrays ... just a normal string ...
> Once I have this basic piece of the puzzle, I can make the rest work.
Sure, that's easy.
Either a substring as has been mentioned, or a regex, like in this
oversimplified example:
---8<---
use strict;
use warnings;
my @a=qw(alfa bravo charlie delta);
my $s;
for('a'..'d'){
# Anchor to beginning of string, use /i to make case insensitive.
print "$_:$s\n" if ($s = <@a>) =~ /^$_/i;
}
---8<---
Read up on regular expressions here:
perldoc perlre
You seem like you'll be able to proceed on your own from here.
Hope this helps,
Petri
------------------------------
Date: 10 Apr 2004 00:45:04 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: How can this be done?
Message-Id: <slrnc7f5vg.5j6.jtc@shell.dimensional.com>
In article <foqdnZwTvuKTGOrdRVn-uQ@adelphia.com>, Bill wrote:
> Robert TV wrote:
>
>>>Not enough info :-D. If you want different actions, you can make a hash
>>>...
>>
>> What I am trying to do is take action based on the first letter of the @rray
>> ellement. Ok, forget about the "A:" etc ect. Lets just say I wanted to do
>> this ... no @rrays ... just a normal string ...
>>
>> $mystring = "Grettings fellow programmer";
>>
>> if (first letter of $mystring eq "G") {
>> do this
>> } else {
>> do that
>> }
>>
>> Once I have this basic piece of the puzzle, I can make the rest work. TIA
>
> untested--get Switch from CPAN:
> ...
Or how about something like this:
#!/usr/bin/perl
use strict;
use warnings;
my @names = <>;
chomp @names;
initialize();
process_names(@names);
my %handlers = ();
sub process_names {
my (@names) = @_;
for my $n (@names) {
my $handler = $handlers{lc substr $n, 0, 1};
if ($handler) {
$handler->($n);
} else {
print "Could not process $n\n";
}
}
}
sub initialize {
my $a_handler = sub { print "a_handler handling @_\n"; };
my $b_handler = sub { print "b_handler handling @_\n"; };
my $c_handler = sub { print "c_handler handling @_\n"; };
my $other_handler = sub { print "other_handler handling @_\n"; };
# Set up a table of subroutine references to be keyed on first letter.
%handlers = (
a => $a_handler,
b => $b_handler,
c => $c_handler
);
# Example of using a generic 'handler', e.g., for the remaining letters:
for my $l ('d' .. 'z') {
$handlers{$l} = $other_handler;
}
}
--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
------------------------------
Date: 9 Apr 2004 12:46:33 -0700
From: hahsmirak@yahoo.com (Shah Karim)
Subject: Re: HTML Tag Counter
Message-Id: <28d5cf4f.0404091146.35449f77@posting.google.com>
Thanks!
I will try this out.
google@milbaugh.com (GreenLight) wrote in message news:<c4b60ce1.0404050730.b7d80fe@posting.google.com>...
> Gisle Aas <gisle@activestate.com> wrote in message news:<m31xn2q235.fsf@eik.i-did-not-set--mail-host-address--so-shoot-me>...
> >
> > #!/usr/bin/perl -w
> >
> > use strict;
> > use HTML::Parser;
> >
> > my %count;
> > my $p = HTML::Parser->new(start_h => [sub { $count{$_[0]}++ }, "tagname"],
> > end_h => [sub { $count{"/$_[0]"}++ }, "tagname"],
> > );
> > $p->parse_file(*STDIN);
> >
> > for (sort { $count{$b} <=> $count{$a} } keys %count) {
> > printf "%5d %s\n", $count{$_}, $_;
> > }
>
> Here is a variation that print the list in alphabetical order, with
> opening and closing tags (if applicable) listed together:
>
> #!/usr/bin/perl -w
>
> use strict;
> use HTML::Parser;
>
> my %count;
> my $p = HTML::Parser->new(start_h => [sub { $count{$_[0]}++ },
> "tagname"],
> end_h => [sub { $count{"/$_[0]"}++ }, "tagname"],
> );
> $p->parse_file(<THIS IS WHERE YOU DECIDE WHAT FILE TO PARSE>);
>
> for (sort keys %count) {
> next if(/^\//);
> printf "%5d %s\n", $count{$_}, $_;
> my $slashed = "/" . $_;
> if (defined($count{$slashed})) {
> printf "%5d %s\n", $count{$slashed}, $slashed;
> }
> }
------------------------------
Date: 09 Apr 2004 18:08:14 GMT
From: ctcgag@hotmail.com
Subject: Re: Initializing an anonymous hash (repost)
Message-Id: <20040409140814.103$Dd@newsreader.com>
neil.shadrach@corryn.com (Neil Shadrach) wrote:
> If I have 2 arrays @k and @v I can initialize a hash %h with
> @h{@k}=@v;
> If my next step is
> push @a,\%h;
> is there a neat way to skip creating %h and initialize an anonymous
> hash for use in a line like
> push @a, {};
Autovivify the hash in place.
use Data::Dumper;
my @a=({},{});
my @k=1..6;
my @v = map $_*$_, 1..6;
warn "Ugly, but works";
@{$a[@a]}{@k}=@v;
print Dumper(\@a);
__END__
Ugly, but works at - line 5.
$VAR1 = [
{},
{},
{
'6' => 36,
'4' => 16,
'1' => 1,
'3' => 9,
'2' => 4,
'5' => 25
}
];
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Fri, 09 Apr 2004 22:48:43 +0200
From: Sandman <mr@sandman.net>
Subject: Re: MySQL perl script
Message-Id: <mr-A9C3F2.22484309042004@news.fu-berlin.de>
In article <Xns94C61D1FB6E26asu1cornelledu@132.236.56.8>,
"A. Sinan Unur" <1usa@llenroc.ude> wrote:
> > What do you mean by interpolate ?
>
> Again, learning just a little bit of Perl before programming in Perl
> might be a good idea.
OR - to answer the question:
"interpolating" means that variables are replaced by their value. So:
my $foo = "World";
print "Hello $foo!\n";
print 'Hello $foo!\n";
Would print:
Hello World!
Hello $foo!
Using " will interpolate, as will using qq{}. Using ' or q{} will not.
--
Sandman[.net]
------------------------------
Date: 9 Apr 2004 12:42:15 -0700
From: dwknapp@uvm.edu (dwknapp)
Subject: Parallel Parser IPC and IO - Need Direction
Message-Id: <3497629f.0404091142.3eb00b04@posting.google.com>
Here is an outline of what I'm trying to do:
1. Gather a list of data text files.
2. Create say 4 child process' and divi up the file list to the
children.
3. Parent will read the parsed output.
4. Each child will open and parse its files and return the output to
the parent. Each file parsed by the child will output multiple lines
of data.
5. Parent sends the data to an output file.
Here is a dumbed down version of my code:
use IO::Select;
use Symbol;
use IO::File;
use IO::Handle;
my $sel = new IO::Select;
my $parent = 1;
my $num_children = 0;
my @filelist;
my @holdfiles;
my $files_per_proc = sprintf("%d", @filelist/4);
while (@holdfiles = splice(@filelist, 0, $files_per_proc)) {
my ($reader, $writer) = (gensym, gensym);
pipe($reader, $writer) or die "pipe: $!";
my $kid = fork();
if ($kid) {
close $writer;
$sel->add($reader);
$num_children += 1;
}
else {
close $reader;
gen_sub($writer, \@holdfiles, \@opts);
$parent = 0;
last;
}
}
while (1) {
foreach my $client ($sel->can_read()) {
my $line = <$client>;
if (!$line) {
$sel->remove($client);
next;
}
print $line; # STDOUT HERE BUT MAYBE EVENTUALLY A FILEHANDLE
}
if ($sel->count == 0) {
last;
}
}
if ($parent) {
while ($num_children) {
my $dead_child = wait;
$num_children--;
}
}
exit(0);
sub gen_sub {
my ($writer, $ra_holdfiles, $ra_options) = @_;
foreach my $file (@{$ra_holdfiles}) {
die "Error" unless (open(IN, $file));
while (my $line = <IN>) {
LOTS OF PARSING HERE
print $writer "SOME DATA THAT I'VE PARSED\n"; # MANY
TIMES PER FILE
}
close IN;
}
}
This may seem to work ok but the output of the parent is all garbaged
up. I think my problem is entirely to do with buffered data but I'm
really stuck. I'm seeing incomplete output from one child, multiple
child outputs on one line, and then also good lines. I know I can
have the children output their data to files but this is NOT what I
want to do. Any direction, help, or suggestions anyone can offer
would be greatly appreciated.
Thanks, -Dave.
------------------------------
Date: Fri, 9 Apr 2004 15:54:17 -0700
From: xbg86@webtv.net (jon)
Subject: Perl Timer
Message-Id: <15067-40772999-310@storefull-3314.bay.webtv.net>
is there a way to make a perl timer?
------------------------------
Date: Fri, 09 Apr 2004 18:58:02 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Perl Timer
Message-Id: <eMGdc.92$fu3.85027@news.uswest.net>
jon wrote:
> is there a way to make a perl timer?
Sure...mmm.. what's a "perl timer"?
perldoc -f alarm
perldoc -f sleep
perldoc -f localtime
Is that what you want???? Otherwise:
# make "a perl timer"
make: don't know how to make a perl timer. Stop
:-)
------------------------------
Date: 9 Apr 2004 15:23:13 -0700
From: nsf470@yahoo.com (pj)
Subject: Re: problem calling perl script from SOAP server perl script
Message-Id: <11711ebf.0404091423.231a0c85@posting.google.com>
Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrnc7dfaf.cg8.tadmc@magna.augustmail.com>...
> pj <nsf470@yahoo.com> wrote:
>
> > #!/usr/bin/perl
>
>
> You should ask for all the help you can get:
>
> use warnings;
> use strict;
>
>
> > sub read_query{
> > my $file=$_[0];
> > open (fileOUT, "> dBDataFiles/$file");
>
>
> You should always, yes *always*, check the return value from open():
>
> open(fileOUT, "> dBDataFiles/$file") or
> die "could not open 'dBDataFiles/$file' $!";
>
>
> > foreach $line (@_)
>
>
> Do you _want_ the first iteration to have the same value as what
> you put into $file?
>
> Writing the name of the file into the file seems strange to me...
>
>
> > {
> > print fileOUT "$line";
> ^ ^
> ^ ^
>
> You should avoid useless uses of double quotes:
>
> print fileOUT $line;
>
>
> > return "done"."\n\n";
>
>
> return "done\n\n";
Thanks for the tips. It's still not working, that is system calll is
returning 256. any ideas why? please let me know.
------------------------------
Date: 9 Apr 2004 21:14:13 GMT
From: Holger Marzen <holger@marzen.de>
Subject: Recompile perl with cpan-shell?
Message-Id: <c573n5$4i5$1@bluebell.marzen.de>
Hi all,
I discovered the cool cpan-shell, and when I used it for the first time
it fetched and compiled a recent perl version.
Now I have a module (Sendmail::Milter) that wants a threaded perl
version. "install Sendmail::Milter" failed, because I didn't know how to
add 2 args (paths to my sendmail source), so I chdir'ed to
~/.cpan/build/Sendmail-Milter-0.18 and entered
perl Makefile.PL /usr/src/sendmail/sendmail-8.10.1 \
/usr/src/sendmail/sendmail-8.10.1/obj.Linux.2.4.18.i586
Then I got:
To use this module, your perl interpreter must have been compiled with
-Dusethreads.
1.) How can I enter arguments to the usual "perl Makefile.PL" that is
issued from the cpan shell?
2.) How can I rebuild perl within the cpan shell and add "-Dusethreads"?
------------------------------
Date: Fri, 9 Apr 2004 22:03:55 +0000 (UTC)
From: simonl@is.bbc.co.uk (Simon Lockhart)
Subject: Re: Win32::OLE / WMEncoderAgent issue
Message-Id: <c576kb$2vl$1@nntp0.reith.bbc.co.uk>
In article <pkent77tea-9391DE.19035009042004@pth-usenet-02.plus.net>,
pkent <pkent77tea@yahoo.com.tea> wrote:
>FWIW looking at Real's website it seems that Helix can encode Windows
>Media, and Helix appears to run on Unix :-)
It can? I've not seen that - URL?
>But, one thing you might find useful, if you haven't found it already,
>is the OLE Browser tool that comes with ActivePerl. Start at the perl
>docs index pages which is probably at C:/perl/html/index.html - in the
>lefthand nav under "Windows Specific" there's a link to the OLE Browser.
>Follow that link and you get a list of all the libraries etc. available,
>which you can click on to get details of their classes, methods,
>properties, etc. You might find something there, maybe.
Okay - I'll take a look at that.
>That said, is $encoder actually defined? Is it is, does it do what it's
>supposed to do? I mean might it just be that you have a perfectly valid
>object in $encoder but, for some reason, QueryObjectType() returns undef
>even though the object exists?
Yes, $encoder is defined, but I can't use it. Hence my problem ;-)
Simon
--
Simon Lockhart | Tel: +44 (0)1628 407720 (x(01)37720) | Si fractum
Technology Manager | Fax: +44 (0)1628 407701 (x(01)37701) | non sit, noli
BBC Internet Ops | Email: Simon.Lockhart@bbc.co.uk | id reficere
BBC Technology, Maiden House, Vanwall Road, Maidenhead. SL6 4UB. UK
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6380
***************************************