[18838] in Perl-Users-Digest
Perl-Users Digest, Issue: 1006 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 28 21:05:42 2001
Date: Mon, 28 May 2001 18:05:11 -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: <991098311-v10-i1006@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 28 May 2001 Volume: 10 Number: 1006
Today's topics:
Re: [Q] count number of emails (Clinton A. Pierce)
Re: [Q] count number of emails (Abigail)
Re: archieve newsgroups (Abigail)
Re: Array slice: how about the remainder? <johnlin@chttl.com.tw>
Re: dbi, fork and ipc-shareable - having problems <djberg96@hotmail.com>
Re: END{} and tempfiles (Abigail)
Re: Function Call (Abigail)
Re: Function Call <joe+usenet@sunstarsys.com>
Re: Function Call <krahnj@acm.org>
Re: Function Call (Abigail)
Re: How to create a text file in Windows/DOS with PERL? <abe@ztreet.demon.nl>
Re: How to launch a program in the background from perl (Clinton A. Pierce)
Re: How to launch a program in the background from perl <extramail@qwest.net>
Re: How to launch a program in the background from perl <extramail@qwest.net>
Re: How to launch a program in the background from perl <extramail@qwest.net>
Re: How to match and print like this ??? <krahnj@acm.org>
Re: How to match and print like this ??? <cadmcse@hotmail.com>
Re: How to match and print like this ??? <krahnj@acm.org>
Re: Looking for perl programming article writers (Abigail)
Re: Match Parsing Glitch (Abigail)
Re: Match Parsing Glitch (Abigail)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 28 May 2001 22:44:25 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: [Q] count number of emails
Message-Id: <dxAQ6.93887$V5.16749674@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <1eu53hv.659bvl17zn7oqN%g.durr@free.fr>,
g.durr@free.fr (Guillaume Durr) writes:
> hi,
> I am a newbie to perl, and I have the following problems
> I want to count the number of email in a file
> I tried :
A proper Unix mbox file should have:
/^From\s/
Mark the beginning of every e-mail message. This string will not occur
in the body of a mail message. So if you just want to count them:
while(<>) {
$heads++ if /^From\s/;
}
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Mon, 28 May 2001 23:22:45 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: [Q] count number of emails
Message-Id: <slrn9h5ne5.fv8.abigail@tsathoggua.rlyeh.net>
Clinton A. Pierce (clintp@geeksalad.org) wrote on MMDCCCXXVII September
MCMXCIII in <URL:news:dxAQ6.93887$V5.16749674@news1.rdc1.mi.home.com>:
[] [Posted and mailed]
[]
[] In article <1eu53hv.659bvl17zn7oqN%g.durr@free.fr>,
[] g.durr@free.fr (Guillaume Durr) writes:
[] > hi,
[] > I am a newbie to perl, and I have the following problems
[] > I want to count the number of email in a file
[] > I tried :
[]
[] A proper Unix mbox file should have:
[]
[] /^From\s/
[]
[] Mark the beginning of every e-mail message. This string will not occur
[] in the body of a mail message. So if you just want to count them:
[]
[] while(<>) {
[] $heads++ if /^From\s/;
[] }
A proper Unix mbox file will put '>' in front of any line of the body
starting with 'From', so the point is moot.
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
------------------------------
Date: Mon, 28 May 2001 22:20:09 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: archieve newsgroups
Message-Id: <slrn9h5jop.fv8.abigail@tsathoggua.rlyeh.net>
me@nowhere.com (me@nowhere.com) wrote on MMDCCCXXIV September MCMXCIII in
<URL:news:165634527897443.Post@ithinknot.net>:
^^ is it ethical to copy the newsgroups from google into my database?
Is it ethical to post such a question in this group?
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: Mon, 28 May 2001 10:12:29 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Array slice: how about the remainder?
Message-Id: <9euosi$801@netnews.hinet.net>
"Mister Satan" wrote
> How about this:
> # assuming @chosen is sorted
> my @not_chosen = (
> 0 .. $chosen[0]-1,
> map( {$chosen[$_-1]+1 .. $chosen[$_]-1} 1..$#chosen ),
> $chosen[$#chosen]+1 .. $#array
> );
> my @stay_home = @array[@not_chosen];
Great!!! This is a new born totally different idea.
John Lin
------------------------------
Date: Mon, 28 May 2001 23:19:55 GMT
From: "Daniel Berger" <djberg96@hotmail.com>
Subject: Re: dbi, fork and ipc-shareable - having problems
Message-Id: <v2BQ6.37617$V6.1935182@typhoon.mn.mediaone.net>
> Well, the goal was to try to run each sql statement concurrently in its
own
> process. Playing with this, I got it to work using your method. Of
course,
> if I 'wait' for each child, then I am effectively running the queries one
> after another rather than simultaneously.
>
> I will have to use Uri's idea of having 4 different shared areas, each
> dedicated to an array/fork.
>
> Regards,
>
> Dan
Further experimentation with Ruby & threads is leading me to believe that no
matter what I do from the client side, the Oracle server is going to cue the
damn things up anyway (or optimize, thread or whatever it is Oracle does - I
ain't no friggin' DBA). I haven't completely verified this, but it's
looking like *nothing* is faster than just `sqlplus blah/blah@music_teleblah
< sqlfile.txt`.
I haven't run any official benchmarking but the ol' sit and watch method has
been plenty telling. Sigh....
Regards,
Dan
------------------------------
Date: Mon, 28 May 2001 23:29:37 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: END{} and tempfiles
Message-Id: <slrn9h5nr1.fv8.abigail@tsathoggua.rlyeh.net>
Jörg Ziefle (gt4556a@acmex.gatech.edu) wrote on MMDCCCXXVII September
MCMXCIII in <URL:news:slrn9h5mfo.ebi.gt4556a@acmex.gatech.edu>:
}} I am using the little code from Perlfaq 5 ("How do I make a temporary
}} file name?", 2nd example) in a subroutine to generate and return the
}} names of temporary files that the caller then uses.
}}
}} However, the END{} block that unlinks the temporary file is only
}} executed for the first temporary file name.
You only have one END{} block, deleting one file.
END {} blocks don't spring into existance at run time, just like any
other piece of code doesn't do so.
Either use eval, or, better, use an array to keep track of files
opened. But then you still have a problem if END {} isn't run,
for instance when doing an exec, or a kill -9. Better might be to
unlink the file right after opening. It'll get deleted as soon as
the program finishes, for whatever reason.
Abigail
--
use lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";
------------------------------
Date: Mon, 28 May 2001 23:13:05 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Function Call
Message-Id: <slrn9h5ms1.fv8.abigail@tsathoggua.rlyeh.net>
Grod (ggrothendieck@volcanomail.com) wrote on MMDCCCXXVII September
MCMXCIII in <URL:news:ffd662ea.0105281252.1609044d@posting.google.com>:
<> The following function correctly outputs <1 2 3 4 5>
<>
<> use diagnostics;
<> @a = sort(&f());
<> print "@a\n";
<>
<> sub f {
<> return reverse (1..5);
<> }
<>
<> however, if I remove the & before the f then Perl complains
<> about the string f and outputs <> .
<>
<> If I replace the line with the sort in it with these two lines
<>
<> @a = f();
<> @a = sort @a;
<>
<> it works again.
<>
<> Why can't Perl tell that f() is a function in all these cases?
<> Do I have to put & in front of every function call in all my
<> programs just to be absolutely sure everything works?
That's because by the time the compiler sees 'sort f', it hasn't seen
the sub f yet. So, it has to guess what 'f' is.
Put your sub before the call to it, use a forward declaration, or use &f().
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
------------------------------
Date: 28 May 2001 19:54:27 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Function Call
Message-Id: <m37kz1owr0.fsf@mumonkan.sunstarsys.com>
ggrothendieck@volcanomail.com (Grod) writes:
> The following function correctly outputs <1 2 3 4 5>
>
> use diagnostics;
> @a = sort(&f());
> print "@a\n";
>
> sub f {
> return reverse (1..5);
> }
>
You might also want to try
sub f {
return reverse (1..15);
}
to see if the output is still ok.
> however, if I remove the & before the f then Perl complains
> about the string f and outputs <> .
> If I replace the line with the sort in it with these two lines
>
> @a = f();
> @a = sort @a;
>
> it works again.
>
> Why can't Perl tell that f() is a function in all these cases?
It can and it does. The problem is what to do with the parens:
% perl -MO=Deparse -wle '@a=sort(f());print "@a";sub f {reverse 1..5}'
Unquoted string "f" may clash with future reserved word at -e line 1.
@a = sort('f' ());
print "@a";
sub f {
reverse +(1, 2, 3, 4, 5);
}
> Do I have to put & in front of every function call in all my
> programs just to be absolutely sure everything works?
No- but you have to be careful about DWIM's bastard child-
"prototypes". Part of gaining admission to the Perl Bourbaki
requires arcane knowledge of prototypes for builtins like sort().
See the documentation in
% perldoc -f sort
for a clue.
--
Joe Schaefer "A witty saying proves nothing."
-- Voltaire
------------------------------
Date: Tue, 29 May 2001 00:19:37 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Function Call
Message-Id: <3B12EB25.91C2AA58@acm.org>
Abigail wrote:
>
> Grod (ggrothendieck@volcanomail.com) wrote on MMDCCCXXVII September
> MCMXCIII in <URL:news:ffd662ea.0105281252.1609044d@posting.google.com>:
> <>
> <> Why can't Perl tell that f() is a function in all these cases?
> <> Do I have to put & in front of every function call in all my
> <> programs just to be absolutely sure everything works?
>
> That's because by the time the compiler sees 'sort f', it hasn't seen
> the sub f yet. So, it has to guess what 'f' is.
>
> Put your sub before the call to it, use a forward declaration, or use &f().
$ perl -v
This is perl, version 5.005_03 built for i586-linux
$ perl -le 'sub f{reverse 1..5} @a=sort(f()); print "@a\n"'
$ perl -le 'sub f{reverse 1..5} @a=sort(+f()); print "@a\n"'
1 2 3 4 5
$ perl -le 'sub f{reverse 1..5} @a=sort(&f()); print "@a\n"'
1 2 3 4 5
$ perl -MO=Deparse -le 'sub f{reverse 1..5} @a=sort(f()); print "@a\n"'
-e syntax OK
sub f {
reverse +(1, 2, 3, 4, 5);
}
@a = sort(f ());
print "@a\n";
Hmmm..., So why is Perl parsing sort(f()) as sort(f ())?
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 29 May 2001 00:33:28 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Function Call
Message-Id: <slrn9h5rio.la0.abigail@tsathoggua.rlyeh.net>
John W. Krahn (krahnj@acm.org) wrote on MMDCCCXXVIII September MCMXCIII
in <URL:news:3B12EB25.91C2AA58@acm.org>:
()
() Hmmm..., So why is Perl parsing sort(f()) as sort(f ())?
A block followed by a(n empty) list.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Tue, 29 May 2001 00:46:57 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: How to create a text file in Windows/DOS with PERL?
Message-Id: <l8l5ht0kat07ps7mjlg7gb76fknlrvpvev@4ax.com>
On 28 May 2001 13:31:33 GMT, Jim Cook <jcook@strobedata.com> wrote:
> I've taken to writing these types of lines as:
> open (HANDLE, $_ = ">temp.txt") || die "Cannot open file $_: $!";
>
> Does that seem like a good way to give sufficient information? Also, I
> remember seeing something about precedence and using "or" instead of
> "||" but can't locate it right now. 'perldoc -f open' shows both in the
> example. Could somebody please point me to the faq / documentation for
> that again so I am sure to use the right one in the future?
http://perl.plover.com/FAQs/Precedence.html
--
Good luck, Abe
Amsterdam Perl Mongers http://amsterdam.pm.org
perl -e '$_=sub{split//,pop;print pop while@_};&$_("rekcah lreP rehtona tsuJ")'
------------------------------
Date: Mon, 28 May 2001 22:32:53 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: How to launch a program in the background from perl web script?
Message-Id: <pmAQ6.93882$V5.16745452@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <3B12BD7B.AAF65633@qwest.net>,
Joel <extramail@qwest.net> writes:
>
> I am launching the perl script from a shell script because I couldn't
> use the '&' to start the process in the background any other way. It
> works from the shell prompt but not from the web script. I am assuming
> it may have something to do with the rights of the web user Apache is
> running as but I have chown the file as such.
>
> Am I just brain farting? I am obviously not understanding something
> important like 'this can't be done' or something. Can you give me a clue
> or point me in the right direction? Thx!
Sure thing. You didn't say what was going wrong. (No, really you didn't
indicate what kind of error you got at all.) This is almost an FAQ, and
falls into two categories:
1. The process starts but not in the background -or- it starts, but the
web page just waits and waits and waits for it to finish which it obviously
won't. This is caused by not properly separating the child process from
the one that the web server started (CGI). Use "perldoc -q daemon" to
find out how to do this, and it should help.
2. The process never starts. Tougher to diagnose and is almost always a.
permissions related (the web server isn't running as *you* it's running as
a "nobody" user or something) or b. environment related (some environment
variable isn't set that should be, you're in the wrong directory, etc...).
The only fix for this is to make sure all of the necessary resources that
the script needs are available.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Mon, 28 May 2001 23:28:31 GMT
From: Joel <extramail@qwest.net>
Subject: Re: How to launch a program in the background from perl web script?
Message-Id: <3B12DF12.A688C4F9@qwest.net>
"Clinton A. Pierce" wrote in response to Joels incredible problem:
> > I am launching the perl script from a shell script because I couldn't
> > use the '&' to start the process in the background any other way. It
> > works from the shell prompt but not from the web script. I am assuming
> > it may have something to do with the rights of the web user Apache is
> > running as but I have chown the file as such.
> >
> > Am I just brain farting? I am obviously not understanding something
> > important like 'this can't be done' or something. Can you give me a clue
> > or point me in the right direction? Thx!
>
> Sure thing. You didn't say what was going wrong. (No, really you didn't
> indicate what kind of error you got at all.) This is almost an FAQ, and
> falls into two categories:
Okay, yer right. I actually don't get any errors. See below.
> 1. The process starts but not in the background -or- it starts, but the
> web page just waits and waits and waits for it to finish which it obviously
> won't. This is caused by not properly separating the child process from
> the one that the web server started (CGI). Use "perldoc -q daemon" to
> find out how to do this, and it should help.
This is definately my situation. My test scripts kills time for about 8
seconds
so I can test it out before runing a command that will take minutes or hours.
> 2. The process never starts. Tougher to diagnose and is almost always a.
> permissions related (the web server isn't running as *you* it's running as
> a "nobody" user or something) or b. environment related (some environment
> variable isn't set that should be, you're in the wrong directory, etc...).
> The only fix for this is to make sure all of the necessary resources that
> the script needs are available.
This was part of my problem which I have now fixed. The process gets kicked
off
and creates entries in a file. However, the browser still waits until the 8
seconds
are over before indicating it is done.
I took your advice and looked at "perldoc -q daemon". There were some stranges
instructions like 'Open /dev/tty and use the TIOCNOTTY ioctl on it'. It also
said to
check out 'Proc::Daemon'. I ended up downloading and installing from CPAN the
'Proc::Background' module as this is what I want to do. It claims to work on
both
unix and win32.
Still no go, it waits the full 8 seconds before the browser knows it's done.
The html the
script produces is shown right away even though the process is kicked off even
before
I print headers under IE 5.0 and at the end of the time under Netscape.
Maybe that's a clue? The file is updated so the process does run and I see the
text in
the file. It just can't seem to seperate itself from the perl script/Apache
Server? I have
had no problems under win32 getting this to work using Win32::Process. I am
writing
a web based application with intense mysql action which can take up to an hour
or two
to run so you see why I don't want the browser to wait? It all runs much
faster under
linux. I gotta get this to work. Any more suggestions would be appreciated!
I am running perl 5.005_03 on Mandrake Linux 7.1
Thanks again Clinton!
Joel
------------------------------
Date: Mon, 28 May 2001 23:29:04 GMT
From: Joel <extramail@qwest.net>
Subject: Re: How to launch a program in the background from perl web script?
Message-Id: <3B12DF33.1FAA9199@qwest.net>
"Clinton A. Pierce" wrote in response to Joels incredible problem:
> > I am launching the perl script from a shell script because I couldn't
> > use the '&' to start the process in the background any other way. It
> > works from the shell prompt but not from the web script. I am assuming
> > it may have something to do with the rights of the web user Apache is
> > running as but I have chown the file as such.
> >
> > Am I just brain farting? I am obviously not understanding something
> > important like 'this can't be done' or something. Can you give me a clue
> > or point me in the right direction? Thx!
>
> Sure thing. You didn't say what was going wrong. (No, really you didn't
> indicate what kind of error you got at all.) This is almost an FAQ, and
> falls into two categories:
Okay, yer right. I actually don't get any errors. See below.
> 1. The process starts but not in the background -or- it starts, but the
> web page just waits and waits and waits for it to finish which it obviously
> won't. This is caused by not properly separating the child process from
> the one that the web server started (CGI). Use "perldoc -q daemon" to
> find out how to do this, and it should help.
This is definately my situation. My test scripts kills time for about 8
seconds
so I can test it out before runing a command that will take minutes or hours.
> 2. The process never starts. Tougher to diagnose and is almost always a.
> permissions related (the web server isn't running as *you* it's running as
> a "nobody" user or something) or b. environment related (some environment
> variable isn't set that should be, you're in the wrong directory, etc...).
> The only fix for this is to make sure all of the necessary resources that
> the script needs are available.
This was part of my problem which I have now fixed. The process gets kicked
off
and creates entries in a file. However, the browser still waits until the 8
seconds
are over before indicating it is done.
I took your advice and looked at "perldoc -q daemon". There were some stranges
instructions like 'Open /dev/tty and use the TIOCNOTTY ioctl on it'. It also
said to
check out 'Proc::Daemon'. I ended up downloading and installing from CPAN the
'Proc::Background' module as this is what I want to do. It claims to work on
both
unix and win32.
Still no go, it waits the full 8 seconds before the browser knows it's done.
The html the
script produces is shown right away even though the process is kicked off even
before
I print headers under IE 5.0 and at the end of the time under Netscape.
Maybe that's a clue? The file is updated so the process does run and I see the
text in
the file. It just can't seem to seperate itself from the perl script/Apache
Server? I have
had no problems under win32 getting this to work using Win32::Process. I am
writing
a web based application with intense mysql action which can take up to an hour
or two
to run so you see why I don't want the browser to wait? It all runs much
faster under
linux. I gotta get this to work. Any more suggestions would be appreciated!
I am running perl 5.005_03 on Mandrake Linux 7.1
Thanks again Clinton!
Joel
------------------------------
Date: Mon, 28 May 2001 23:30:36 GMT
From: Joel <extramail@qwest.net>
Subject: Re: How to launch a program in the background from perl web script?
Message-Id: <3B12DF8F.A53DA8F@qwest.net>
"Clinton A. Pierce" wrote in response to Joels incredible problem:
> > I am launching the perl script from a shell script because I couldn't
> > use the '&' to start the process in the background any other way. It
> > works from the shell prompt but not from the web script. I am assuming
> > it may have something to do with the rights of the web user Apache is
> > running as but I have chown the file as such.
> >
> > Am I just brain farting? I am obviously not understanding something
> > important like 'this can't be done' or something. Can you give me a clue
> > or point me in the right direction? Thx!
>
> Sure thing. You didn't say what was going wrong. (No, really you didn't
> indicate what kind of error you got at all.) This is almost an FAQ, and
> falls into two categories:
Okay, yer right. I actually don't get any errors. See below.
> 1. The process starts but not in the background -or- it starts, but the
> web page just waits and waits and waits for it to finish which it obviously
> won't. This is caused by not properly separating the child process from
> the one that the web server started (CGI). Use "perldoc -q daemon" to
> find out how to do this, and it should help.
This is definately my situation. My test scripts kills time for about 8
seconds
so I can test it out before runing a command that will take minutes or hours.
> 2. The process never starts. Tougher to diagnose and is almost always a.
> permissions related (the web server isn't running as *you* it's running as
> a "nobody" user or something) or b. environment related (some environment
> variable isn't set that should be, you're in the wrong directory, etc...).
> The only fix for this is to make sure all of the necessary resources that
> the script needs are available.
This was part of my problem which I have now fixed. The process gets kicked
off
and creates entries in a file. However, the browser still waits until the 8
seconds
are over before indicating it is done.
I took your advice and looked at "perldoc -q daemon". There were some stranges
instructions like 'Open /dev/tty and use the TIOCNOTTY ioctl on it'. It also
said to
check out 'Proc::Daemon'. I ended up downloading and installing from CPAN the
'Proc::Background' module as this is what I want to do. It claims to work on
both
unix and win32.
Still no go, it waits the full 8 seconds before the browser knows it's done.
The html the
script produces is shown right away even though the process is kicked off even
before
I print headers under IE 5.0 and at the end of the time under Netscape.
Maybe that's a clue? The file is updated so the process does run and I see the
text in
the file. It just can't seem to seperate itself from the perl script/Apache
Server? I have
had no problems under win32 getting this to work using Win32::Process. I am
writing
a web based application with intense mysql action which can take up to an hour
or two
to run so you see why I don't want the browser to wait? It all runs much
faster under
linux. I gotta get this to work. Any more suggestions would be appreciated!
I am running perl 5.005_03 on Mandrake Linux 7.1
Thanks again Clinton!
Joel
------------------------------
Date: Mon, 28 May 2001 23:54:35 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to match and print like this ???
Message-Id: <3B12E537.14B75373@acm.org>
cad fei wrote:
>
> "John W. Krahn" <krahnj@acm.org>
> > #!/usr/bin/perl -w
> > use strict;
> >
> > my %graph;
> > my @masters;
> > my $mast_wid = 0;
> > my $col_wid = 0;
> > while ( <DATA> ) {
> > my @f = split " ";
> > my $master = shift @f;
> > my $instance = pop @f;
> > push @masters, $master;
> > $mast_wid = length $master if $mast_wid < length $master;
> >
> > for ( @f ) {
> > $graph{ $_ }{ $master } = substr $master, 0, 1;
> > $col_wid = length if $col_wid < length;
> > }
> > }
> > $col_wid++;
> > $mast_wid++;
> >
> > printf "%${mast_wid}s" . "%${col_wid}s" x @masters . "\n", ' ',
> > @masters;
> > for my $x ( sort keys %graph ) {
> > printf "%${mast_wid}s", $x;
> > for my $y ( @masters ) {
> > printf "%${col_wid}s", exists $graph{$x}{$y} ? $graph{$x}{$y} : ' ';
> > }
> > print "\n";
> > }
> >
> > __DATA__
> > MN109 ADDPAD hn
> > MN207 n1 ADDPAD hn
> > MN208 n1 CEB hn
> > MN209 n1 hn
> > MP202 ADDPAD NP1 hp
> > MP204 ADDPAD NP1 hp
> > MP206 NP1 hp
> > MP216 net145 ADD n1 hp
> > MP205 NP1 CEB n1 hp
> > XI119 ADD n1 inv
> > MP234 NP1 CEB net145 hp
> >
> Thanks for instruction! actually I still have difficulty to understand your
> code,
> becuase I am new to perl ... I had study one day try to modify the code ,
> but every time cause the error....because I don't know hash well..
> the real data format actually is like this :
>
> .subckt seo_TTL ADD ADDPAD CEB VCCIO
> XI119 ADD n1 inv
> MN109 ADDPAD hn
> MN207 n1 ADDPAD hn
> MN208 n1 CEB hn
> MN209 n1 hn
> MP202 ADDPAD NP1 hp
> MP204 ADDPAD NP1 hp
> MP206 NP1 hp
> MP216 net145 ADD n1 hp
> MP205 NP1 CEB n1 hp
> MP234 NP1 CEB net145 hp
>
> only first line from 3th element to the end are belong to "Terminal" (they
> are part of netnames)
> I want to modify the code to print the format like this,
> Ternimal master1(instance1) master2(instance2) .....
Change:
my $master = shift @f;
my $instance = pop @f;
To:
my $master = shift @f;
my $instance = pop @f;
$master = "$master($instance)";
> but doesn't work...my concept about array,hash and reference is very poor ><
>
> Terminal MN109(hn) MN207(hn) MN208(hn) MN209(hn)
> MP202(hp) MP204
> ADD X
> ADDPAD X X
> CEB X
> NP1
> n1
> net145
>
> from running the code, some mark by "M", some by"x".. I even don't know
> why..
$graph{ $_ }{ $master } = substr $master, 0, 1;
This line gets the first character of $master ('X' or 'M') and stores it
in the %graph hash.
> would u have some free time, can you teach me how to do it?
> I am struggling with your code and read the Programing Perl Book for whole
> day,
If you have specific questions on some code you are having problems with
just post them here and someone should be able to help. :-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 29 May 2001 00:38:56 GMT
From: "cadfei" <cadmcse@hotmail.com>
Subject: Re: How to match and print like this ???
Message-Id: <AcCQ6.46545$ko.640626@news1.frmt1.sfba.home.com>
>
> $graph{ $_ }{ $master } = substr $master, 0, 1;
>
> This line gets the first character of $master ('X' or 'M') and stores it
> in the %graph hash.
OH!!Oh!, I see,, so it print out depends on first character of master name..
If I want use "X" replace all marks, I try this
$graph{ $_ }{ $master } = substr($master, 0, 1, "X");
but looks wrong...?? why
#I am following the book example
$oldstr = substr($var, -1, 1, "Curly"); # programming perl 3rd p.806
>
> If you have specific questions on some code you are having problems with
> just post them here and someone should be able to help. :-)
Sure, I would like to solve the check terminal problem myself..
in programming world,that's no lucky! :)
I am still trying to modify the code, thanks!!
------------------------------
Date: Tue, 29 May 2001 00:59:05 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to match and print like this ???
Message-Id: <3B12F47A.BE1B2253@acm.org>
cadfei wrote:
>
> >
> > $graph{ $_ }{ $master } = substr $master, 0, 1;
> >
> > This line gets the first character of $master ('X' or 'M') and stores it
> > in the %graph hash.
>
> OH!!Oh!, I see,, so it print out depends on first character of master name..
> If I want use "X" replace all marks, I try this
>
> $graph{ $_ }{ $master } = substr($master, 0, 1, "X");
>
> but looks wrong...?? why
$graph{ $_ }{ $master } = 'X'
> #I am following the book example
> $oldstr = substr($var, -1, 1, "Curly"); # programming perl 3rd p.806
>
> >
> > If you have specific questions on some code you are having problems with
> > just post them here and someone should be able to help. :-)
>
> Sure, I would like to solve the check terminal problem myself..
> in programming world,that's no lucky! :)
> I am still trying to modify the code, thanks!!
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 28 May 2001 23:36:53 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Looking for perl programming article writers
Message-Id: <slrn9h5o8l.fv8.abigail@tsathoggua.rlyeh.net>
William Cross (william@perlcoders.com) wrote on MMDCCCXXVII September
MCMXCIII in <URL:news:759114d.0105280450.601ab@posting.google.com>:
__ Hello all,
__
__ PerlCoders dot com is looking for someone who can write professional
__ articles or mini tutorials on perl programming. If this is you please
__ contact Jaime at jaime@perlcoders.com
Yes, we can. Do you want me to ask out company's contact person to
contact you with our rates?
Abigail
--
@;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
;print@;[@;{A..Z}];
------------------------------
Date: Mon, 28 May 2001 23:40:32 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Match Parsing Glitch
Message-Id: <slrn9h5ofg.fv8.abigail@tsathoggua.rlyeh.net>
Eric (nospam@xx.com) wrote on MMDCCCXXVI September MCMXCIII in
<URL:news:3B107B8C.BF7D679C@xx.com>:
`' Abe Timmerman wrote:
`'
`' >> RE: global type errors
`' >
`' > Descriptions of these errors can be found in perldiag.pod
`' > perldoc perldiag
`'
`' I finally got Perl 5.6.1 Plus installed, but the above doesn't work
`' on my WIN32 system. Must be a Unix thing?
No, not a Unix thing. In fact, if all the world was Unix, we wouldn't
need this form of 'perldoc', which is mainly there for the windows weenies
that face life without 'man'.
It's likely to be either a user error, or a broken installation.
Which, since windows tends to be single-user, is a user error as well.
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54"; s/<<EOT/<<EOT/e; print;
Just another Perl Hacker
EOT
------------------------------
Date: Mon, 28 May 2001 23:41:44 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Match Parsing Glitch
Message-Id: <slrn9h5oho.fv8.abigail@tsathoggua.rlyeh.net>
Eric (nospam@xx.com) wrote on MMDCCCXXVI September MCMXCIII in
<URL:news:3B1084B4.2B4986E@xx.com>:
?? Eric wrote:
??
?? > I tried this ... total "Greek" to me about initializing a filehandle.
??
?? OK...I did some more reading, but it appears I am already making a
?? filehandle initialization???
??
?? $filename = <STDIN>;
?? open (INFILE, "$filename")
?? or die "Could not open $filename as read: $!";
??
?? The script will be used to open a number of different files. Would
?? taking vitamins help here? ;-(
Do you always use filenames whose final character is a newline?
(And why quote $filename?)
Abigail
--
perl -wlne '}for($.){print' file # Count the number of lines.
------------------------------
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 1006
***************************************