[13329] in Perl-Users-Digest
Perl-Users Digest, Issue: 739 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 8 10:07:20 1999
Date: Wed, 8 Sep 1999 07: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)
Perl-Users Digest Wed, 8 Sep 1999 Volume: 9 Number: 739
Today's topics:
Re: Accessing NT DB from Linux Perl <brent@one.net>
Re: addressing multiple columns with sort (Abigail)
Re: array of binary to hex (Abigail)
Re: Checking type input (Anno Siegel)
converting a number into a binary? <zhuang@ic.sunysb.edu>
Re: Counting duplicate list elements in Perl <aqumsieh@matrox.com>
Re: Day of the week (Larry Rosler)
edit this perl script <wlhst6+@pitt.edu>
Re: edit this perl script <garethr@cre.canon.co.uk>
Re: Help - Porting code from UNIX to NT <allan.hagan@bt.com>
Re: Help - Porting code from UNIX to NT <allan.hagan@bt.com>
Re: Help - Porting code from UNIX to NT <allan.hagan@bt.com>
help: multithreading in perl ashishkjain@hotpop.com
Re: Job opportunities (Bbirthisel)
Re: mod_perl? help! <clavikal@voicenet.com>
Re: Old Script Doesn't Like My New Perl? Help! (Abigail)
Re: Old Script Doesn't Like My New Perl? Help! (Bill Moseley)
Re: Pattern Matching Question <aqumsieh@matrox.com>
Re: Problem with <!--#exec cgi=/scripts/script.pl%22--> <wyzelli@yahoo.com>
Re: Problems using grep <jpeterson@office.colt.net>
Re: Problems using grep (Abigail)
Re: Problems using grep (Bill Moseley)
Re: proxy-server problem with perl <allan.hagan@bt.com>
Re: Question about a hash <aqumsieh@matrox.com>
race condition in forking server (keywords: waitpid, re dud@sydney.net
running perl script on local apache server <maureen@islandwebdesign.com>
Re: STL difference - VC vs BCB (Abigail)
Re: suggestion to revise grep (another Q: reference com (Larry Rosler)
Re: Unix Trouble <theglauber@my-deja.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Sep 1999 09:51:02 -0300
From: Brent Foster <brent@one.net>
Subject: Re: Accessing NT DB from Linux Perl
Message-Id: <37d669c6_1@news2.one.net>
You need to get a commercial ODBC driver for the Linux box.
I think OpenLink software makes one. Check their web site
at http://www.openlinksw.com/
Brent
In onenet.cgi Mike Flora <mflora@fmca.com> wrote:
> Can anyone tell me:
> 1) If it is possible to access an NT MS SQL Server from a Linux box using
> Perl?
>
> 2) If so, do I need special Linux drivers (if they exist)?
>
> 3) How to do it...
>
> Thanks for any help or information you can pass my way.
>
> Mike Flora
--
Brent Foster
Lead Systems Administrator
OneNet Communications
513.618.1000 - brent@one.net
------------------------------
Date: 8 Sep 1999 08:16:54 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: addressing multiple columns with sort
Message-Id: <slrn7tcoje.ncm.abigail@alexandra.delanet.com>
rootdog (corlando@NOTpop.phnx.uswest.net) wrote on MMCXCIX September
MCMXCIII in <URL:news:6amB3.1269$IP5.153029@news.uswest.net>:
::
:: how do i use the sort { $a <=> $b} and its variants to sort on any
:: of the columns that I wish or how do I construct a subroutine that
:: given n columns will sort on any combination of the given columns.
RTFFAQ.
:: In other words I am blocking (sucking) big-time on figuring out complex
:: sorting with the sort command.
That's majorly stupid, as it's spelled out in the FAQ.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 8 Sep 1999 08:18:33 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: array of binary to hex
Message-Id: <slrn7tcomg.ncm.abigail@alexandra.delanet.com>
John Wilkinson (john.wilkinson@soton.sc.philips.com) wrote on MMCXCIX
September MCMXCIII in <URL:news:37D641A2.845D29C0@soton.sc.philips.com>:
&& Hi,
&& I have just started programming in Perl, and I have a little problem
&& that I need help with.
&& I have 3 arrays each of 8 cells. In each cell is a binary digit, and the
&& combination of the three arrays make up a 24 bit word. I now need to
&& gather all these arrays together and produce a printout in hex
&& representing this word.
&& How do I do this?
You would use printf.
If you would show us what you've already done, and where you got
stuck, you might get a better response.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 8 Sep 1999 13:48:31 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Checking type input
Message-Id: <7r5pff$7vm$1@lublin.zrz.tu-berlin.de>
Larry Rosler <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
>In article <slrn7tbkmt.n2g.abigail@alexandra.delanet.com> on 7 Sep 1999
>22:04:21 -0500, Abigail <abigail@delanet.com> says...
>> Mike (info@counter.w-dt.com) wrote on MMCXCIX September MCMXCIII in
>> <URL:news:37D5C9E5.6ACBC720@counter.w-dt.com>:
>> ,, How do you check to make sure a variable only has numbers in it.
>>
>> $var !~ /\D/
>>
>> Abigail
>
>Impostor! You gave a useful answer instead of a RTFFAQ.
Are you implying RTFFAQ isn't a useful answer?
Anno
------------------------------
Date: Wed, 08 Sep 1999 09:17:41 -0400
From: "Z. Huang" <zhuang@ic.sunysb.edu>
Subject: converting a number into a binary?
Message-Id: <37D661F5.1293E218@ic.sunysb.edu>
can anyone tell me how to convert a number (integer or float) into a
binary? For, example:
8 ---> 100
0.125---> 0.001
------------------------------
Date: Wed, 8 Sep 1999 08:37:54 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Counting duplicate list elements in Perl
Message-Id: <x3yso4ph93y.fsf@tigre.matrox.com>
abigail@delanet.com (Abigail) writes:
> Ala Qumsieh (aqumsieh@matrox.com) wrote on MMCXCIII September MCMXCIII in
> <URL:news:x3ylnapwaxe.fsf@tigre.matrox.com>:
> []
> [] "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net> writes:
> []
> [] > Uri Guttman wrote:
> [] > >
> [] > > a little perl golf here
> [] > >
> [] > > perl -lne '$c{$_}++; END{print "$_,$c{$_}" for sort keys %c}'
> [] >
> [] > perl -lne '$c{$_}++;END{print"$_,$c{$_}"for sort keys%c}'
> [] >
> [] > Four fewer strokes! (And no closing -n loop with }, either!) Do I get a
> [] > prize? (Tested, too!)
> []
> [] Is this considered valid Perl Golf:
> []
> [] % alias p perl -nle
> [] % p '$c{$_}++;END{print"$_,$c{$_}"for sort keys%c}'
> []
> [] Eight (yes 8!!!) fewer strokes. That's VERY close to a hole in one!
>
>
> Well, if you go that way:
>
> $ alias p perl -nle '$c{$_}++;END{print"$_,$c{$_}"for sort keys%c}'
> $ p
That's cheating ;-)
--Ala
------------------------------
Date: Wed, 8 Sep 1999 06:32:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Day of the week
Message-Id: <MPG.1240054be37ae5a9989f2c@nntp.hpl.hp.com>
In article <uso4pivvs.fsf@infoscience.otago.ac.nz> on 08 Sep 1999
21:40:39 +1200, Andrew Gray <agray@infoscience.otago.ac.nz> says...
> david_2exvia@my-deja.com writes:
> > I have a date in string format (mm/dd/yyyy) and I'd like to find the day
> > of the week (Mon, Tue...)
>
> If you don't already have Steffen Beyer's Date::Calc module, you may
> want to download it from CPAN. The script below shows how you could
> determe the day of the week (you will need to split your date format
> given above first to get the individual components).
>
> #!usr/bin/perl -w
> use strict;
> use Date::Calc q(:all);
>
> my $year=1999;
> my $month=9;
> my $day=8;
>
> my $dayname=Day_of_Week($year,$month,$day);
> print $dayname."\n";
> $dayname=Day_of_Week_to_Text(Day_of_Week($year,$month,$day));
> print $dayname."\n";
> $dayname=Day_of_Week_Abbreviation(Day_of_Week($year,$month,$day));
> print $dayname."\n";
>
> produces
>
> 3
> Wednesday
> Wed
Serious overkill. The Time::Local module is already on the system. As
Dave Cross says, that is the way to go.
The following code produces
3
Wed
Producing 'Wednesday' is left as an exercise for the reader. Hint: not
using Date::Calc for such trivia.
#!/usr/bin/perl -w
use strict;
use Time::Local;
my $year=1999;
my $month=9;
my $day=8;
my $time = timelocal 0, 0, 0, $day, $month - 1, $year - 1900;
my $dayname = (localtime $time)[6];
print $dayname."\n";
$dayname = substr((localtime $time), 0, 3);
print $dayname."\n";
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 8 Sep 1999 09:27:10 -0400
From: "W. Lyle Hayhurst" <wlhst6+@pitt.edu>
Subject: edit this perl script
Message-Id: <Pine.GSO.3.96L.990908092544.18254A-100000@unixs5.cis.pitt.edu>
Hi, here's a cute li'l perl script I whipped
up to answr a Trivia Persuit question. Can
anyone optimize out the inner foreach loop?
--Lyle
#!/tmp_mnt/usr/local/bin/perl -w
# perl script to find the longest word in the dictionary
# that only uses the top row of the keyboard for letters
open( WORDS, "/usr/share/dict/words" ) || die; #open the dictionary
$longest = "q"; #variable to remember the longest
#all the letters to filter out
@filter = ( 'a', 'A', 's', 'S', 'd', 'D', 'f', 'F',
'g', 'G', 'h', 'H', 'j', 'J', 'k', 'K',
'l', 'L', 'z', 'Z', 'x', 'X', 'c', 'C',
'v', 'V', 'b', 'B', 'n', 'N', 'm', 'M' );
#the WORD loop iterates through each word in the dictionary
WORD:
while( $_ = <WORDS> ) { #while words to read
chop; #remove the newline
foreach $char ( @filter ) { #see if it has a bad letter
next WORD if ( $_ =~ /$char/ ); #it does
}
#satisfies: all letters are on the top row
if ( length( $_ ) == length( $longest ) ) { #watch out for same size!
print "Tie between $_ and $longest\n";
}
$longest = $_ if( length( $_ ) > length( $longest ) ); #new longest
}
#output the answer
print "Answer is $longest\n";
------------------------------
Date: Wed, 8 Sep 1999 13:47:05 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: "W. Lyle Hayhurst" <wlhst6+@pitt.edu>
Subject: Re: edit this perl script
Message-Id: <si906hldly.fsf@cre.canon.co.uk>
W. Lyle Hayhurst <wlhst6+@pitt.edu> wrote:
> Perl script to find the longest word in the dictionary that only uses
> the top row of the keyboard for letters.
$ perl -ne '$w = $_, $l = length if /^[qwertyuiop]+$/i && length > $l;
END { print $w }' < words
prettypretty
$
I also like "proterotype" and "rupturewort".
--
Gareth Rees
------------------------------
Date: Wed, 8 Sep 1999 14:13:34 +0100
From: "Allan Hagan" <allan.hagan@bt.com>
Subject: Re: Help - Porting code from UNIX to NT
Message-Id: <7r5nej$bfa$1@pheidippides.axion.bt.co.uk>
This script is on an NT box - where file type defines by association which
program will execute it eg. *.doc will start up winword and dump the
document into it. The Nt extension for perl is usually *.pl
Allan
Jon Hall wrote in message <37d60b0b@dnews.tpgi.com.au>...
>Our company has just changes ISPs and now I've got to port our basic little
>PERL scripts to cope with the new environment.
>
>Unfortunatley I've not done much in the way of PERL and NT so I'm running
>into pitfalls.
>
>Here's a snippet:-
>
>#!c:\perl\bin\perl.exe
>print "Location: http://www.oursite.com/index.html\n\n";
>exit;
>
>When I run this I receive "HTTP/1.0 500 Server Error (/scripts/redir.cgi is
>not a valid Windows NT application. )"
>
>The ISP tells me the directory is set as executable - have I overlooked
>something blatant??
>
>Thanks for your help,
>
>Jon
>
>
>
> -----------== Posted via Newsfeeds.Com, Uncensored Usenet News
==----------
> http://www.newsfeeds.com The Largest Usenet Servers in the World!
>------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers
==-----
------------------------------
Date: Wed, 8 Sep 1999 14:16:18 +0100
From: "Allan Hagan" <allan.hagan@bt.com>
Subject: Re: Help - Porting code from UNIX to NT
Message-Id: <7r5njl$bhb$1@pheidippides.axion.bt.co.uk>
Nt executes programs on the basis of file extension eg *.doc opens winword.
Perl files are usually *.pl change your .cgi to pl and try again.
Allan
------------------------------
Date: Wed, 8 Sep 1999 14:25:11 +0100
From: "Allan Hagan" <allan.hagan@bt.com>
Subject: Re: Help - Porting code from UNIX to NT
Message-Id: <7r5o4a$bpq$1@pheidippides.axion.bt.co.uk>
Oops! sorry my news server is giving me warnings - please ignore my first
message - brain not quite in gear after lunch.
------------------------------
Date: Wed, 08 Sep 1999 13:35:39 GMT
From: ashishkjain@hotpop.com
Subject: help: multithreading in perl
Message-Id: <7r5ona$e0t$1@nnrp1.deja.com>
I am working on a program which takes lot of time doing the pattern
matching. To reduce time I think threading would help me but not able
to find good reference on how to achieve this.
Ashish
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 08 Sep 1999 13:34:47 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Job opportunities
Message-Id: <19990908093447.01626.00003647@ng-fs1.aol.com>
Hi Jon and Michelle:
>Michelle Fowler <ciber@vnet.net> wrote:
>> Can I post Perl job openings here?
>It is not an ideal forum. I would suggest that if you wish to advertise jobs
>directly to the Perl community, that you find a Perl Mongers group
While you are at www.pm.org, you can also check out the
perl-jobs-announce mailing list. That goes to people who are
actively seeking such posts.
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Wed, 8 Sep 1999 10:05:54 -0400
From: "clavikal" <clavikal@voicenet.com>
Subject: Re: mod_perl? help!
Message-Id: <ZYtB3.638$y51.67363@news3.voicenet.com>
What should I build first? Apache or mod_perl?
Do I just have to perl Makefile.PL && make && make install like other perl
modules?
Do I have to rebuild Apache after mod_perl?
Ahh!
Thanks for any help
Jon Peterson <jpeterson@office.colt.net> wrote in message
news:bhqB3.87$xa4.1217@news.colt.net...
> clavikal <clavikal@voicenet.com> wrote:
> > I (think) understand mod_perl somehow increases the speed, and lowers
the
> > cpu usage of perl programs because it doesn't spawn a separate process.
>
> > The installation documentation at the mod_perl web site really sucks
to me
> > anyways ), so if anyone wouldn't mind, could someone please post easy
>
> Sounds about right. Installing and maintaing a mod_perl/apache web server
is
> not a task for beginners. The fact that there are now n different and
variously
> incompatible ways to configure Apache doesn't help, either. My basic rules
> would be:
>
> Never ever use the 'APACI' configuration for Apache, it's dreadfully
confusing
> for anything more than a default install. Use the 'src/Configuration'
method
> aka 'the old method'.
>
> Never use the Apache dynamic modules, it's more trouble than it's worth -
make
> all modules, including perl, compiled in statically. This ought to always
be
> the default.
>
> Start with a fresh distro of everything - freshly unpacked Apache, freshly
> unpacked mod_perl.
>
> Consider simpler alternatives such as fastCGI, Velocigen, or what have
you.
>
> Oh, and Doug if you are listening I'm volunteering to re-do the
perl.apache.org
> website anytime you like :-0
>
>
------------------------------
Date: 8 Sep 1999 08:24:23 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Old Script Doesn't Like My New Perl? Help!
Message-Id: <slrn7tcp1f.ncm.abigail@alexandra.delanet.com>
Dan Poynor (designer@ricochet.net) wrote on MMCXCIX September MCMXCIII in
<URL:news:designer-ya02408000R0809990327050001@news.ricochet.net>:
[] I'm getting the following error when running an old script with newly
[] installed perl
[]
[] [root@server hq]# perl -w /home/httpd/cgi-bin/rotate.pl
[] Use of uninitialized value at /home/httpd/cgi-bin/rotate.pl line 7.
[]
[] ---------here's the script rotate.pl-------------
[] #! /usr/bin/perl
[]
[] $oldlink = readlink("/home/httpd/foobar.com/current");
[] @dirs = sort grep {!-l $_ && -d _} </home/httpd/foobar.com.com/slideshows/*>;
[] push(@dirs, $dirs[0]);
[] for (1..@dirs) { $newlink = $dirs[$_] and last if $dirs[$_-1] eq $oldlink }
[] symlink($newlink, "tmp.$$");
[] rename("tmp.$$", "/home/httpd/foobar.com.com/current");
[]
[] exit (0);
Consider what happens if the grep {...} <glob> returns an empty list.
Abigail
--
$" = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%_ = (Just => another => Perl => Hacker); &{%_};
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 8 Sep 1999 06:39:32 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Old Script Doesn't Like My New Perl? Help!
Message-Id: <MPG.124006ee2971f297989718@nntp1.ba.best.com>
Dan Poynor (designer@ricochet.net) seems to say...
> [root@server hq]# perl -w /home/httpd/cgi-bin/rotate.pl
> Use of uninitialized value at /home/httpd/cgi-bin/rotate.pl line 7.
>
> ---------here's the script rotate.pl-------------
> #! /usr/bin/perl
>
> $oldlink = readlink("/home/httpd/foobar.com/current");
> @dirs = sort grep {!-l $_ && -d _} </home/httpd/foobar.com.com/slideshows/*>;
> push(@dirs, $dirs[0]);
> for (1..@dirs) { $newlink = $dirs[$_] and last if $dirs[$_-1] eq $oldlink }
and line 7:
> symlink($newlink, "tmp.$$");
I'd guess either $newlink or $$. Did you check to see that they are
being assigned?
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Wed, 8 Sep 1999 08:34:54 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Pattern Matching Question
Message-Id: <x3yu2p5h98x.fsf@tigre.matrox.com>
stuart.mcintosh@db.com writes:
> 123.45678 P
> 3.4567890P
> 23.456789
>
> I tried m/\S+\s*\S/g - according to the "programming perl" book the \s*
> should match zero or more occurances of a whitespace character but I
> found it was failing on the second example above...
Hmmm... let's see:
% perl -wl
while (<DATA>) {
chomp;
print "Matched >>$_<<" if /\S+\s*\S/;
}
__DATA__
123.45678 P
3.4567890P
23.456789
This outputs:
Matched >>123.45678 P<<
Matched >> 3.4567890P<<
Matched >> 23.456789<<
Are you sure of your results?
--Ala
------------------------------
Date: Wed, 8 Sep 1999 23:30:42 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Problem with <!--#exec cgi=/scripts/script.pl%22--> in IIS4
Message-Id: <j_tB3.13$%R5.3393@vic.nntp.telstra.net>
Ethan H. Poole <ehpoole@ingress.com> wrote in message
news:37D56116.F3D8C542@ingress.com...
> Wyzelli wrote:
>
> What's amusing is the ignorance in that statement. Since IIS 2.0
> (currently version 4.0) IIS has supported the *full* range of SSI options.
>
> I guess I don't see how giving the original poster a wrong answer is going
> to prove "actually useful".
>
> --
> Ethan H. Poole **** BUSINESS ****
No.. definitely not useful at all... I sit corrected, and shall do penance
by updating my servers!
And apologies to the original poster who may have been led astray...
Wyzelli
------------------------------
Date: Wed, 08 Sep 1999 13:14:44 GMT
From: Jon Peterson <jpeterson@office.colt.net>
Subject: Re: Problems using grep
Message-Id: <8jtB3.89$xa4.1218@news.colt.net>
Robert Rawlinson <robert.rawlinson@worldnet.att.net> wrote:
> I am trying to use grep to find records in a list of files. I
> want grep to search in the files in the list looking for records
> with the search info. I used:
> @List = grep {"5551212"} "/work/D\?0606.dat"
> I had hoped it would look through the /work files for records
> containing 5551212 and place the records found in the @List. All
You have assumed that grep in perl is just like grep in unix. This is not the
case, in fact, grep is sufficiently different that it's name is confusing.
grep in perl takes an expression or block as one argument, and a list as
another argument. It returns a list consisting of every member of the argument
list for which the block or expression evaluates as true, where $_ is set to
be the current list member.
@List = grep {$_ > 4} ('1', '5', '2', '7');
This puts the values '5' and '7' in @List
------------------------------
Date: 8 Sep 1999 08:27:08 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Problems using grep
Message-Id: <slrn7tcp6k.ncm.abigail@alexandra.delanet.com>
Robert Rawlinson (robert.rawlinson@worldnet.att.net) wrote on MMCXCIX
September MCMXCIII in <URL:news:37D65CE2.5FDEE57B@worldnet.att.net>:
^^ I am trying to use grep to find records in a list of files. I
^^ want grep to search in the files in the list looking for records
^^ with the search info. I used:
^^ @List = grep {"5551212"} "/work/D\?0606.dat"
^^ I had hoped it would look through the /work files for records
^^ containing 5551212 and place the records found in the @List. All
^^ I get is the name of one of the files in @List. Could someone
^^ help find why this does not work?
Well, you start with a list, then grep through it, using an expression
that always returns true.
You might want to read a bit more in the manual.
Abigail
--
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 8 Sep 1999 06:43:43 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Problems using grep
Message-Id: <MPG.124007e9c43a7f20989719@nntp1.ba.best.com>
Robert Rawlinson (robert.rawlinson@worldnet.att.net) seems to say...
> @List = grep {"5551212"} "/work/D\?0606.dat"
> I had hoped it would look through the /work files for records
> containing 5551212 and place the records found in the @List. All
> I get is the name of one of the files in @List.
Robert,
Perl's grep is not the utility grep.
perldoc -f grep
and then read about backticks or system, or open()ing with a trailing
pipe if you want to use the grep program.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Wed, 8 Sep 1999 14:21:33 +0100
From: "Allan Hagan" <allan.hagan@bt.com>
Subject: Re: proxy-server problem with perl
Message-Id: <7r5ntf$blq$1@pheidippides.axion.bt.co.uk>
Try generating your own unique id and using cookies. Otherwise you'll have
to make them login ie open an account with you.
Allan
------------------------------
Date: Wed, 8 Sep 1999 08:42:59 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Question about a hash
Message-Id: <x3yr9k9h8vi.fsf@tigre.matrox.com>
Ilya <ilya@speakeasy.org> writes:
> I need an array to look like this:
>
> @data = ( [@new_array_time],
> [@{$input_params{'cpu_usr'}}],
> [@{$input_params{'cpu_sys'}}],
> [@{$input_params{'cpu_wio'}}],
> [@{$input_params{'cpu_idle'}}]
> );
Ok.
> The hash is %input_params. I am trying to build the above like this and fails
> to built it exactly the way it is above. I think it is missing the square
> brackets. Any thoughts on how to put them there?
Hmm... I usually type them in.
> foreach $key (sort keys %input_params)
> {
> if ($key ne 0)
> {
> push (@data, @{$input_params{$key}});
push @data => [@{$input_params{$key}}];
or
push @data => $input_params{$key};
The first one creates a fresh copy of @{$input_params{$key}}, and
saves a reference to it in @data. So, any changes to
$input_params{$key} will not affect @data. The other one saves
$input_params{$key} (which is itself an array ref) into @data. In this
case, any changes to $input_params{$key} will reflect in @data.
HTH,
--Ala
------------------------------
Date: Wed, 08 Sep 1999 13:35:32 GMT
From: dud@sydney.net
Subject: race condition in forking server (keywords: waitpid, reaper)
Message-Id: <7r5on2$e0r$1@nnrp1.deja.com>
We have a multi-process server (Perl 5.00503 running under Linux
Redhat) that sits waiting on a specific port to serve CGI requests.
Based on an example in the Perl Cookbook, the server preforks x number
of processes and maintains this child process population when each
child process dies (REAPER). We seem to have encountered a race
condition issue and, although have worked around the problem, would
like opinions of others on what else could better remedy the situation.
It seems that when multiple child processes terminate at the same time,
REAPER is only being called once. As this sub is responsible for
tracking the number of live children, the result is two child processes
dying but only one tracked, therefore only one re-created.
my $server;
my $client;
my %children;
my $children;
# create the server
$server = create_server($port);
if ($prefork == 0) {
while ($client = $server->accept()) {
handle_client($server,$client);
}
}
else {
# fork off our children
for (1..$prefork) {
make_new_child($server);
}
# install signal handlers
$SIG{CHLD} = \&REAPER;
$SIG{INT} = \&HUNTSMAN;
# and maintain the population
while (1) {
my $i;
sleep;
clear_dead_children(); # *** this is the work-around
for ($i=$children;$i<$prefork;$i++) {
make_new_child($server);
}
}
}
sub make_new_child
{
my $serv = shift;
my $i;
my $pid;
my $sigset;
my $client;
$sigset = POSIX::SigSet->new(SIGINT);
sigprocmask(SIG_BLOCK,$sigset)
or die "can't block SIGINT for fork: $!\n";
die "fork: $!" unless defined ($pid = fork);
if ($pid) {
sigprocmask(SIG_UNBLOCK,$sigset)
or die "can't unblock SIGINT for fork: $!\n";
$children{$pid} = 1;
$children++;
return;
}
else {
$SIG{INT} = 'DEFAULT';
sigprocmask(SIG_UNBLOCK,$sigset)
or die "can't unblock SIGINT for fork: $!\n";
$client = $serv->accept() or last;
handle_client($serv,$client);
exit; # *** this point is reached for every child process
}
}
sub REAPER
{
my $pid = waitpid(-1, &WNOHANG);
if ($pid == -1) {
# no child
}
elsif (WIFEXITED($?)) {
$children--;
delete $children{$pid};
}
$SIG{CHLD} = \&REAPER;
}
sub HUNTSMAN
{
local($SIG{CHLD}) = 'IGNORE';
kill 'INT' => keys %children;
exit;
}
to work-around the problem, we've added the clear_dead_children() sub
before re-populating.
sub clear_dead_children
{
my $pid;
my $i;
my %newchildren;
%newchildren = %children;
foreach $pid (keys %newchildren) {
$i = waitpid($pid,&WNOHANG);
if ($i == 0) {
print "pid $pid is still running - keep up the good work\n";
}
elsif ($i == -1) {
print "pid $pid doesn't exist - clearing\n";
delete $children{$pid};
$children--;
}
elsif ($i == $pid) {
print "pid $pid is dead - clearing\n";
delete $children{$pid};
$children--;
}
}
}
the above works and clears the dead children so that correct number are
re-populated.
is anyone able to offer suggestions as to why REAPER would only be
called the once (assuming that it is a race condition) or an opinion on
the work-around applied?
kind rgds,
/dave
--------------------
David Roe
davidroe@email.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 08 Sep 1999 09:09:16 -0400
From: Maureen Dunlap <maureen@islandwebdesign.com>
Subject: running perl script on local apache server
Message-Id: <37D65FFC.737E72F1@islandwebdesign.com>
Hi,
I'm not a programmer, but I have been using perl scripts for years on
remote servers with only the normal annoying configuration errors to
deal with.
Now I'm setting up a script on my local C: drive on my apache server and
am getting an Internal Server Error with the following showing up in the
error log:
"Premature end of script headers"
Is this something really obvious and simple? I have had other scripts
running on this server with no problems. I am running Windows NT. Any
help is appreciated.
Thanks in advance,
Maureen Dunlap
------------------------------
Date: 8 Sep 1999 08:30:14 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: STL difference - VC vs BCB
Message-Id: <slrn7tcpce.ncm.abigail@alexandra.delanet.com>
Pušić Goran (pusic.goran@ev.co.yu) wrote on MMCXCIX September MCMXCIII in
<URL:news:7r51oa$tqh$1@Mercury.ev.co.yu>:
\\ Can enyone explain to me why thi program compiles and works in BCB 3 and
\\ doesn't compile in VC 5?
And your Perl question is?
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 8 Sep 1999 06:06:17 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: suggestion to revise grep (another Q: reference comparison)
Message-Id: <MPG.123fff1a394620a7989f2b@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <slrn7tad96.m3v.sitaram@diac.com> on 8 Sep 1999 04:58:27 -
0700, Sitaram Chamarty <sitaram@diac.com> says...
..
> >How can we compare references?
>
> What do you mean by compare? If you want to know if two
> references are pointing at the exact same referant, then "eq"
> should do fine. It would string-ise the reference, and then
> compare. Exactly what you saw.
>
> If you mean what is also called a "deep compare" (comparing the
> referants for equality, recursively if they happen to be or
> contain references), then it may be a little more difficult. I'm
> sure there's a module for this somewhere though :-)
I don't understand what you mean. If two references are equal, they
refer to the same entity -- 'pointing at the exact same referant' in
your words. Therefore there is no such thing as a 'deep compare'.
I think you are confusing this comparison with 'deep copy'. Please
enlighten me if I have misunderstood your observation.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 08 Sep 1999 13:39:14 GMT
From: The Glauber <theglauber@my-deja.com>
Subject: Re: Unix Trouble
Message-Id: <7r5ou1$e2a$1@nnrp1.deja.com>
In article <uvh9lixgy.fsf@infoscience.otago.ac.nz>,
[...]
> Also, the
> philosophy of Perl is very compatible with the philosophy of UNIX:
> using many small tools (some of which may have been written by others)
> to solve a problem, as opposed to the MS Windows approach of using a
> small number of omni-powerful applications with overlapping
> functionality.
At the same time, it goes counter to that philosophy. When programming
in the Unix shell, you are pretty much scripting, tying together the
"little applications" that make up the Unix toolbox. In Perl, you move
a lot of the functionality to your program, and you eliminate a lot of
overhead, because you are not spawning all these little applications.
That's one of the things that makes Perl fast. (Compare using find and
rm to delete files older than X days, when you start rm once for each
file you find. With Perl, you do everything in your program, without
ever having to start rm.)
g.
--
Glauber Ribeiro
theglauber@my-deja.com
"Opinions stated are my own and not representative of Experian"
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 739
*************************************