[15475] in Perl-Users-Digest
Perl-Users Digest, Issue: 2885 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 28 00:05:41 2000
Date: Thu, 27 Apr 2000 21:05:12 -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: <956894712-v9-i2885@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 27 Apr 2000 Volume: 9 Number: 2885
Today's topics:
Re: A script to make the output of "perldoc -f ..." mor (Randal L. Schwartz)
Re: AIX perl 5.6 compile <elaine@chaos.wustl.edu>
Cookie (Set-cookie:) & Redirect (Location:) in same HTT <caraudio@streetdreams.com>
Re: Cookie (Set-cookie:) & Redirect (Location:) in same (Clinton A. Pierce)
Re: Cookie (Set-cookie:) & Redirect (Location:) in same <caraudio@streetdreams.com>
Re: Cookie (Set-cookie:) & Redirect (Location:) in same <caraudio@streetdreams.com>
deleting a record in a TEXT database? (Mindunwind Sales Department)
Re: Eliminate duplicates from big file <tcuffel@exactis.com>
Getting start with perl <norazman@ti.com>
Re: GPIB <dhabersetzer@micron.com>
Re: Hashes -- case insensitive keys? (J. B. Moreno)
Re: help with large, complex data structure (Eric Bohlman)
Re: Hiding Password (Tad McClellan)
JARQ (Just Another Regex Question) <matt.stoker@motorola.com>
Re: JARQ (Just Another Regex Question) <wyzelli@yahoo.com>
latest perl-info for emacs - where to get one? <dimitrio@perlnow.com>
Re: Mass email question... (Clinton A. Pierce)
Re: min/max <dimitrio@perlnow.com>
Re: min/max <dimitrio@perlnow.com>
Re: Need help with the regex <matt.stoker@motorola.com>
Re: Need help with the regex <Greg@LibertyMarketing.com>
need resource for porting from nt to unix <mp3jon@columbus.rr.com>
Re: Net::SMTP on Windows woes mj_pepper@my-deja.com
Re: newbie q: Reassign STDOUT/ERR in DOS (Bart Lateur)
newbie question on GLOB <unclenospamarthur@oceanfree.net>
Re: overloading & 'constant' subroutines (Ilya Zakharevich)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Apr 2000 15:43:46 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: A script to make the output of "perldoc -f ..." more readable.
Message-Id: <m1og6vxizh.fsf@halfdome.holdit.com>
>>>>> "Francis" == Francis Litterio <franl-removethis@world.omitthis.std.com> writes:
Francis> This script arranges to feed the output of "perldoc -f ..." through
Francis> pod2man to make it more readable.
you don't like
perldoc -t -f FUNCNAME
That's what I use. Lot less work. :)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 28 Apr 2000 03:06:54 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: AIX perl 5.6 compile
Message-Id: <B52E78CD.32B2%elaine@chaos.wustl.edu>
in article 390890AB.607135E@uhc.com, Chris Covington at ccoving@uhc.com
quoth:
> It worked well using the extra cost IBM compiler instead of gcc.
> Fortunately we are a big enough shop to have one laying around. Thanks
> for the info. It's working now.
Sun is like this too. Sparcworks compiles like buttah though so it is often
worth the extra dough.
> Still, too bad perl doesn't compile with gcc on AIX.
You might have a go at the P5P archive. I recall gcc on AIX working with
5.6.0 but only with -lmssa or somesuch added into the libs.
e.
------------------------------
Date: Thu, 27 Apr 2000 19:47:20 -0400
From: "StreetDreams" <caraudio@streetdreams.com>
Subject: Cookie (Set-cookie:) & Redirect (Location:) in same HTTP header??
Message-Id: <8eal75$b90$1@slb2.atl.mindspring.net>
I am trying to save a cookie, and do a redirect at the same time. Is this
possible??
My application is:
1. User enters name/password
2. If valid store in cookie (crypted) and bring up a little menu with
some admin options.
Each "admin" script after that can check the cookie, and can decide if
the user is authorized to run the script or not, based on if the cookie
exists, and name/password is correct.
Here is latest version I have tried: (struggling)
my $c = new CGI::Cookie(-name=> 'admin',
-value=> ['user','password']);
print "Set-Cookie: $c\n";
print "Location: script.cgi\n\n";
I am testing on a Windows 98 machine running ActiveState Perl (current
version) and the current version of "Microsoft Personal Webserver" --- all
this for testing before upload to a UNIX server.
Is there a better way to do this than to store the userid/password in a
cookie? I have heard time and time again not to store sensetive info in a
cookie. All I need to do is to get the userid/password fields to every
script that is executed. Most are executed using the print "Locaton:
domain.com\n\n";
Any help would be appreciated.
Thank you for your time,
Paul
Atlanta, GA
------------------------------
Date: Fri, 28 Apr 2000 01:05:56 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Cookie (Set-cookie:) & Redirect (Location:) in same HTTP header??
Message-Id: <Ut5O4.50334$h01.360300@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <8eal75$b90$1@slb2.atl.mindspring.net>,
"StreetDreams" <caraudio@streetdreams.com> writes:
> I am trying to save a cookie, and do a redirect at the same time. Is this
> possible??
Yes, quite and it's been answered thoroughly before. Search www.deja.com
(use the Power Search), and search comp.lang.perl.misc and look for
redirect and cookie.
If you get too many hits, try my name as author. The answer is there.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Thu, 27 Apr 2000 23:39:37 -0400
From: "StreetDreams" <caraudio@streetdreams.com>
Subject: Re: Cookie (Set-cookie:) & Redirect (Location:) in same HTTP header??
Message-Id: <8eb1bp$qot$1@slb6.atl.mindspring.net>
I tried your suggestion....I had no luck! AUGHHHHH!! I know I'm going to
kick myself when I get this figured out!
Here is what I have now:
use CGI qw(:standard);
$cookie=cookie(-name=>'admin', -value=>'paul');
$redirect_to="http://www.perl.com";
print redirect(-uri => $redirect_to,-cookie => $cookie);
The redirect works...but no cookie! :(
I am running:
Windows 98 SE
ActiveState Perl (new version)
CGI.pm (just downloaded the new one tonight)
Internet Explorer (with cookies ON)
Thanks!
Paul
Clinton A. Pierce <clintp@geeksalad.org> wrote in message
news:Ut5O4.50334$h01.360300@news1.rdc1.mi.home.com...
> [Posted and mailed]
>
> In article <8eal75$b90$1@slb2.atl.mindspring.net>,
> "StreetDreams" <caraudio@streetdreams.com> writes:
> > I am trying to save a cookie, and do a redirect at the same time. Is
this
> > possible??
>
> Yes, quite and it's been answered thoroughly before. Search www.deja.com
> (use the Power Search), and search comp.lang.perl.misc and look for
> redirect and cookie.
>
> If you get too many hits, try my name as author. The answer is there.
>
> --
> Clinton A. Pierce Teach Yourself Perl in 24 Hours!
> clintp@geeksalad.org for details see http://www.geeksalad.org
> "If you rush a Miracle Man,
> you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Thu, 27 Apr 2000 23:42:39 -0400
From: "StreetDreams" <caraudio@streetdreams.com>
Subject: Re: Cookie (Set-cookie:) & Redirect (Location:) in same HTTP header??
Message-Id: <8eb1ih$hk1$1@nntp9.atl.mindspring.net>
I knew I forgot something...
I'm also running the latest version of "Microsoft Personal Webserver" (off
the Win98 SE CD)
Please help :)
Clinton A. Pierce <clintp@geeksalad.org> wrote in message
news:Ut5O4.50334$h01.360300@news1.rdc1.mi.home.com...
> [Posted and mailed]
>
> In article <8eal75$b90$1@slb2.atl.mindspring.net>,
> "StreetDreams" <caraudio@streetdreams.com> writes:
> > I am trying to save a cookie, and do a redirect at the same time. Is
this
> > possible??
>
> Yes, quite and it's been answered thoroughly before. Search www.deja.com
> (use the Power Search), and search comp.lang.perl.misc and look for
> redirect and cookie.
>
> If you get too many hits, try my name as author. The answer is there.
>
> --
> Clinton A. Pierce Teach Yourself Perl in 24 Hours!
> clintp@geeksalad.org for details see http://www.geeksalad.org
> "If you rush a Miracle Man,
> you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: 28 Apr 2000 03:35:18 GMT
From: mindunwindsales@aol.com (Mindunwind Sales Department)
Subject: deleting a record in a TEXT database?
Message-Id: <20000427233518.09500.00000167@ng-cn1.aol.com>
any idea how to do this? Thanks a bunch for tthe help
<A HREF="http://www.mindunwind.com">www.MindUnwind.com - Hard to find Compact
discs and Cassettes at hard to believe prices!!! Come on in and unwind your
mind </A> --------------------------------
Hundreds of Compact Discs for only 99 cents each!
------------------------------
Date: Thu, 27 Apr 2000 16:15:55 -0500
From: "Tim Cuffel" <tcuffel@exactis.com>
Subject: Re: Eliminate duplicates from big file
Message-Id: <5M2O4.285$jY2.47842@den-news1.rmi.net>
Samay wrote in message <2865e92c.edc612cc@usw-ex0104-087.remarq.com>...
>Hi,
> I have big file (size around 400 MB) with approximately 2.5
>million lines. Each line is in particular format.
>
>Now, I want to eliminate duplicate lines from this files..
>The file is not essentially sorted. I can use Hash to store the
>line and count or can store the lines in Array and apply grep
>to see if they exist etc..
>
>This has cause 'out of memory' problem on my system, which has
>come from the hash size, I believe.. The program takes more than
>10 minute to run also..
>
>Is there any way I can solve this problem??
>
>Dividing the file into different file was one solution. I don't
>know how I can apply that effectively..
>
>I appriciate your solutions or pointers.
I had a similar problem. I used DB_File to move the deduplication
hash from memory to disk. That helped a lot, but the disk usage
was still too much. Then I ran each line (100-2000 bytes) through
Digest::MD5, which reduced the key size to ~32 bytes.
The two of those did the trick.
------------------------------
Date: Fri, 28 Apr 2000 11:47:04 +0800
From: Norazman Abu Sahir <norazman@ti.com>
Subject: Getting start with perl
Message-Id: <390909B8.637B2732@ti.com>
Hi,
Sorry but I have to ask this question.
I downloaded Perl from ActiveState.
While reading perl, I understand to connect to database I have to use DBI/DBD
module.
So I download it from DBI site.
I have once create cgi with vb but vb is gui so any module can easily get
integrated.
Can anybody explain to how to do with perl (integrating new module so that it
can be use
by my exixting perl)
My perl is inside C:\perl
After download DBI, it was in .tar compressed format, but i've extract it to
C:\DBD
Now how can I intergrate this 2 together.
Thanks.
------------------------------
Date: Thu, 27 Apr 2000 16:59:09 -0600
From: Daryl Habersetzer <dhabersetzer@micron.com>
Subject: Re: GPIB
Message-Id: <3908C63D.6FDB5DEA@micron.com>
Dave Zempel wrote:
>
> I'm attempting to communicate with a GPIB device (HP8594E). I've just
> recently realized that my problem is in specifying the HPIB device
> address. This is not /dev/gpib0. I open /dev/gpib0 and then print to
> that IO channel. The problem is that since many devices can be
> connected to /dev/gpib0, I also need to specify an address (718). All
> of the example programs provided with the GPIB interface card come with
> IO libraries that hide this addressing issue.
>
> Has anyone done this before in PERL or any other scripting language.
> And can you tell me how to handle the addressing issue?
Two separate opens are required. One for gpib0 and one for the specific
device (dev7 or whatever). After they are open, print to the device,
not to gpib0.
I haven't done a pure perl solution, but I have written an XS module for
National Instruments gpib library if you are interested.
------------------------------
Date: Thu, 27 Apr 2000 21:04:58 -0400
From: planb@newsreaders.com (J. B. Moreno)
Subject: Re: Hashes -- case insensitive keys?
Message-Id: <1e9rl04.6tdlbpuwsejpN%planb@newsreaders.com>
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> J. B. Moreno wrote:
> > Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
>
> > > By the way, "keys %hash" returns something, but it's not "whatever was
> > > first used", unless I'm mistaken.
> >
> > If there's no "whatever was used first", then if it's not unique it's
> > the same as whatever was used first.
> >
> > $hash{'john'}=1; $hash{'JOHN'}++;
> > and then keys %hash returns (john, JOHN) and both have a value of 1.
> > What I was asking for was for keys %hash to return (john) and for
> > $hash('john'} to have a value of 2.
>
> I probably just misunderstood. The point I was making is that "keys" does
> not return the keys of a hash in any particulary order
Ah, no problem then -- I know that keys doesn't return any kind of
sorted list.
--
John B. Moreno
------------------------------
Date: 27 Apr 2000 22:48:19 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: help with large, complex data structure
Message-Id: <8eag3j$64i$2@slb1.atl.mindspring.net>
John S. J. Anderson (janderso@ncbi.nlm.nih.gov) wrote:
: The arrays are pretty sparsely populated, maybe ~25% filled on
: average, and actually map to strings rather than numbers[3], so I
: considered using a hash of hashes...but I also need this to be
: persistent (i.e., written out to disk), and from the *DBM_File docs,
: multi-level structures are a no-op.
Take a look at MLDBM, which allows you to more-or-less
transparently serialize multi-level structures in DBM files (you can use
Data::Dumper, Storable or FreezeThaw to do the serialization; my choice
would be Storable).
------------------------------
Date: Thu, 27 Apr 2000 19:38:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Hiding Password
Message-Id: <slrn8ghjrh.1fr.tadmc@magna.metronet.com>
On Thu, 27 Apr 2000 13:53:46 GMT, Gary <hg009873@my-deja.com> wrote:
>How can
>I get perl to hide password (i.e. not echo to screen)as the user types
^^^^^^^^
^^^^^^^^
>their password in.
By checking the Perl FAQ before posting to the Perl newsgroup,
( have you been to news.announce.newusers yet?).
perldoc -q password
=head2 How do I ask the user for a password?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 27 Apr 2000 19:50:34 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: JARQ (Just Another Regex Question)
Message-Id: <3908FC7A.F4F4149B@motorola.com>
I need to search through a file for the first occurance of the phrase
"NUMBER OF COWS", however if the matching phrase is preceded by a ! on
the same line, it is a comment and should not match. Can this be done
with a single regex?
I tried to use:
$line=<FILEHANDLE> until ($line =~ /[^!].*NUMBER OF COWS/);
but that still matches when the phrase is preceded by ! .
Here is an example of what it should match:
---start of file---
SOME JUNK
! THIS IS A COMMENT
COUNT BESSY'S ! NUMBER OF COWS
! NUMBER OF COWS ! NUMBER OF COWS
! COUNT THE NUMBER OF COWS
MORE JUNK
BIG NUMBER OF COWS ! LARGE NUMBER OF COWS
SMALL NUMBER OF COWS
FINAL JUNK
---end of file---
After running the desired value of $line would be:
BIG NUMBER OF COWS ! LARGE NUMBER OF COWS
I realize that I could use:
do {
$line = <FILEHANDLE>;
($search,$comment) = split /!/, $line, 2;
} until ($search =~ /NUMBER OF COWS/)
but, I'd really like to do it with a single regex if possible. Any
suggestions?
--
/------------------------------------------------------------------\
| Matt Stoker | email: matt.stoker@motorola.com |
| Unit Process Modeling | Mail Drop: M360 |
| DigitalDNA(TM) Laboratories| Phone: (480)655-3301 |
| Motorola, SPS | Fax: (480)655-5013 |
| 2200 W Broadway Road | Pager: (888)699-8803 |
| Mesa, AZ 85202 | |
\------------------------------------------------------------------/
------------------------------
Date: Fri, 28 Apr 2000 13:24:54 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: JARQ (Just Another Regex Question)
Message-Id: <kY7O4.14$IM6.2377@vic.nntp.telstra.net>
Matthew Stoker <matt.stoker@motorola.com> wrote in message
news:3908FC7A.F4F4149B@motorola.com...
> I need to search through a file for the first occurance of the phrase
> "NUMBER OF COWS", however if the matching phrase is preceded by a ! on
> the same line, it is a comment and should not match. Can this be done
> with a single regex?
>
> I tried to use:
>
> $line=<FILEHANDLE> until ($line =~ /[^!].*NUMBER OF COWS/);
>
> but that still matches when the phrase is preceded by ! .
>
> Here is an example of what it should match:
>
> ---start of file---
> SOME JUNK
> ! THIS IS A COMMENT
> COUNT BESSY'S ! NUMBER OF COWS
> ! NUMBER OF COWS ! NUMBER OF COWS
> ! COUNT THE NUMBER OF COWS
> MORE JUNK
> BIG NUMBER OF COWS ! LARGE NUMBER OF COWS
> SMALL NUMBER OF COWS
> FINAL JUNK
> ---end of file---
>
> After running the desired value of $line would be:
>
> BIG NUMBER OF COWS ! LARGE NUMBER OF COWS
>
Here is the proverbial 'One Way':
#!/usr/bin/perl -w
use strict;
my $line;
while (<DATA>){
last if (($line) = /^([^!].+?[^!] NUMBER OF COWS.*)/);
}
print "$line\n";
__END__
SOME JUNK
! THIS IS A COMMENT
COUNT BESSY'S ! NUMBER OF COWS
! NUMBER OF COWS ! NUMBER OF COWS
! COUNT THE NUMBER OF COWS
MORE JUNK
BIG NUMBER OF COWS ! LARGE NUMBER OF COWS
SMALL NUMBER OF COWS
FINAL JUNK
Product:
BIG NUMBER OF COWS ! LARGE NUMBER OF COWS
Wyzelli
------------------------------
Date: Fri, 28 Apr 2000 02:25:34 GMT
From: "Dimitri Ostapenko" <dimitrio@perlnow.com>
Subject: latest perl-info for emacs - where to get one?
Message-Id: <yE6O4.84895$2D6.2170544@news20.bellglobal.com>
Recently installed emacs with perl extensions - love it. But can't find
latest perl-info file.
Also, is there place to get the whole suite - customized emacs + utils and
other good stuff for developers?
Thanks
Dimitri Ostapenko
------------------------------
Date: Fri, 28 Apr 2000 01:20:28 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Mass email question...
Message-Id: <wH5O4.50355$h01.360698@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <39087191.ACEDB2F0@sdrc.com>,
Nathan Wright <nathan.wright@sdrc.com> writes:
> Where I work I have constructed this page that my team can track work
> on. Recently my boss asked me if we could have the page email whoever
> assigned the work when the entry is unchanged after so many days.
My friends who are waiting for SDRC to fix bugs will be SO glad to
hear this. :)
> So I wrote into the page an if construct that compares todays date to
> the date of when the case was assigned. If the difference was greater
> than 7 I would call an email subroutine and pass it who to mail, then
> increment the date in the data(so it would only email the owner once a
> day).
Technique nit: rather than trying to juggle dates around, does this
data have a "case number" or a "open bug number"? Some kind of unique
identifier?
What I'd do is write a DBM file or something which containted the
case number (as a key) and the recipient's name as the data. If the
key already exists, you don't send the mail. If it doesn't, then
you do.
That's just the way I think. The "already sent mail" state is a boolean,
and needs to be treated as such and not overcomplicated.
> This works great if it only has to email one person, but when it has to
> call the subroutine say ten times. It will email the same message over
> and over.
I didn't follow this at all. Probably a logic bug from
overcomplicating the send flag with a bunch of date manipulation logic.
:)
> Any and all help would be greatly appreciated. And go easy on me all
> you hard core perlers, I know my code is long and drawn out, I like it
> the way I can understand it all.
A few nits, and they're all right here:
open(MAIL3,">$TMP_MAIL")
|| die ("Cannot open mail file $TMP_MAIL: $!\n");
write MAIL3;
Why the temp file? Why not just:
open(MAIL3, "|/usr/lib/sendmail -t") || die...
instead? Save yourself a temp file, and keep people from spying
on you, or worse, exploiting a race condition and getting sendmail
to do something EVIL.
system("cat $TMP_MAIL | /usr/lib/sendmail -t");
Useless use of cat(1). If you use a temp file, then:
system("/usr/lib/sendmail -t < $TMP_MAIL");
would suffice. But don't use a temp file.
Your one real bug:
unlink('$TMP_MAIL');
If this code is what you've got in production...I'll bet your temp
files never get deleted. Because you're trying to delete the literal
filename dollar-tee-em-pee-underscore-em-ah-eye-ell -- which probably
doesn't exist. The single quotes prevent interpolation which is
what you want.
You don't need quotes at all there.
Besides, you would have caught this if you had followed the rule:
ALL SYSTEM CALLS CAN FAIL, ALWAYS CHECK THE RETURN VALUE.
unlink($TMP_MAIL) || warn "Cannot delete $TMP_MAIL: $!";
Good luck!
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Fri, 28 Apr 2000 02:15:04 GMT
From: "Dimitri Ostapenko" <dimitrio@perlnow.com>
Subject: Re: min/max
Message-Id: <Iu6O4.151444$1C2.3818650@news20.bellglobal.com>
Bart Lateur <bart.lateur@skynet.be> wrote in message
news:39054762.1057306@news.skynet.be...
> Dimitri Ostapenko wrote:
>
> >is there a better (shorter) way to get min/max of 2/many values without
> >loading any modules ?
> >
> >I use : $min = ($a>$b)?b:a; for 2 values
> >
> >and (sort {$a<=>$b} @nums)[0]; for many
> >
> >while 2-nd seems concise enough for what it does, I'm too lazy and
curious
> >about the 1st.
>
> It's concise, but it's also quite inefficient. Say you're comparing 1000
> numbers, then you'll roughly do 500000 (N*N/2) comparisons, to get the
> minimum or maximum of this list.
>
> A sub looks more efficient to me:
>
> sub min {
> my $min = shift;
> foreach(@_) {
> $min = $_ if $_ < $min;
> }
> return $min;
> }
>
> $min = min (2, 3, 1);
>
> likewise:
>
> sub max {
> my $max = shift;
> foreach(@_) {
> $max = $_ if $_ > $max;
> }
> return $max;
> }
>
> $max = max (2, 3, 1);
>
> You want to combine them?
>
> sub minmax {
> my $min = my $max = shift;
> foreach(@_) {
> $min = $_ if $_ < $min;
> $max = $_ if $_ > $max;
> }
> return ($min, $max);
> }
>
>
> ($min, $max) = minmax(5, 3, 1, 6, 8, 10, 4);
> or
> ($min, $max) = minmax(@array);
>
> --
> Bart.
makes perfect sence, but i like it short
Thanks
Dimitri
------------------------------
Date: Fri, 28 Apr 2000 02:16:01 GMT
From: "Dimitri Ostapenko" <dimitrio@perlnow.com>
Subject: Re: min/max
Message-Id: <Bv6O4.151446$1C2.3818837@news20.bellglobal.com>
brian d foy <brian@smithrenaud.com> wrote in message
news:brian-2304002135320001@183.sanjose-13-14rs16rt.ca.dial-access.att.net..
.
> In article <0JPM4.58659$2D6.1781800@news20.bellglobal.com>, "Dimitri
Ostapenko" <dimitrio@perlnow.com> wrote:
>
> >is there a better (shorter) way to get min/max of 2/many values without
> >loading any modules ?
>
> why don't you want to use List::Util?
>
> --
> brian d foy
> Perl Mongers <URI:http://www.perl.org>
> CGI MetaFAQ
> <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
>
I do. Now that I know about it. :)
it's just unexplained fear of a black box..
------------------------------
Date: Thu, 27 Apr 2000 19:19:50 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: Need help with the regex
Message-Id: <3908F546.53B03CBA@motorola.com>
Larry Rosler wrote:
<snip>
> >
> > $keyword =~ /^.*/oi
> > ^^^^^^^
> > This is where i am having the problem.
>
> Indeed. What are you trying to match? Your regex matches a string that
> has a beginning followed by anything at all, i.e. it matches anything at
> all.
>
> My crystal ball says that you are trying to do a case-independent match
> against some user-supplied variable, which is constant for the run of
> the program, and in which metacharacter interpretation isn't desired.
> So:
>
> $keyword =~ /\Q$variable/oi
>
Good suggestions Larry, but if I understood his post correctly I think
he wants to match all of the fields (not just $keywords) against some
user-supplied "$keyword" variable. In this case it is simply:
if (/\Q$keyword/oi && $adminbutton eq "Search By keyvar"){
push @searchresults,$_;
}
Note that /\Q$keyword/oi is a shortcut for $_=~/\Q$keyword/oi, so $_
which contains all of the fields is searched for $keyword.
--
/------------------------------------------------------------------\
| Matt Stoker | email: matt.stoker@motorola.com |
| Unit Process Modeling | Mail Drop: M360 |
| DigitalDNA(TM) Laboratories| Phone: (480)655-3301 |
| Motorola, SPS | Fax: (480)655-5013 |
| 2200 W Broadway Road | Pager: (888)699-8803 |
| Mesa, AZ 85202 | |
\------------------------------------------------------------------/
------------------------------
Date: Fri, 28 Apr 2000 03:05:38 GMT
From: "Gregory D. Fox" <Greg@LibertyMarketing.com>
Subject: Re: Need help with the regex
Message-Id: <6e7O4.47585$MZ2.557082@news1.wwck1.ri.home.com>
"Matthew Stoker" <matt.stoker@motorola.com> wrote in message
news:3908F546.53B03CBA@motorola.com...
> Good suggestions Larry, but if I understood his post correctly I think
> he wants to match all of the fields (not just $keywords) against some
> user-supplied "$keyword" variable. In this case it is simply:
>
> if (/\Q$keyword/oi && $adminbutton eq "Search By keyvar"){
> push @searchresults,$_;
> }
>
> Note that /\Q$keyword/oi is a shortcut for $_=~/\Q$keyword/oi, so $_
> which contains all of the fields is searched for $keyword.
>
This worked. Thanks Larry & Matt.
------------------------------
Date: Thu, 27 Apr 2000 23:47:08 -0400
From: "JR" <mp3jon@columbus.rr.com>
Subject: need resource for porting from nt to unix
Message-Id: <8eb1lj$omr$1@charm.magnus.acs.ohio-state.edu>
I need help finding an online tutorial/hint guide for porting perl from NT
to unix
thanks!
------------------------------
Date: Fri, 28 Apr 2000 02:34:43 GMT
From: mj_pepper@my-deja.com
Subject: Re: Net::SMTP on Windows woes
Message-Id: <8eatc3$gln$1@nnrp1.deja.com>
In article <38F0D541.E7CFFAA@online-testing.net>,
Jordan Hiller <jhiller@online-testing.net> wrote:
> I am having some trouble getting a simple Net:SMTP script to work on
> Windows 98 with ActivePerl build 518. Perl outputs "Bad command or
file
> name" and doesn't send the email. It appears to be happening on the
> connection line:
>
> use Net::SMTP; # No problem with this line
> $smtp = Net::SMTP->new('smtp.rossvito.com'); # This seems to fail
>
> Any suggestions?
>
> Jordan Hiller
> Online Quiz and Testing Solutions
> http://www.online-testing.net/
>
Jordan, this may seem trivial, but which single-quote character are you
using? Remember that 'x' is a string, but `x` sends the x to your
command processor (COMMAND.COM,CMD.EXE,etc.) to be processed. If your
string is really `smtp.rossvito.com` then you are trying to execute a
command that will result in the error message you are seeing.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 28 Apr 2000 00:43:00 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: newbie q: Reassign STDOUT/ERR in DOS
Message-Id: <3909dbe0.770048@news.skynet.be>
pt wrote:
> I want to redirect STDERR (or STDOUT) before doing a "system" cmd,
>then restore these streams.
>This code will compile, but is it the "right" way (error handling left
>out for simplicity).
>$OldStdErr = STDERR ;
This is wrong.
>open(STDERR,">$ErrFile");
>system $syscmd ;
>close(STDERR) ;
This is OK.
>$STDERR = $OldStdErr ;
This is most definitely wrong.
What I would expect to work, but doesn't (not on my slightly outdated
systems, anyway), is
{
local *STDERR;
open STDERR, ">error.log";
system $syscmd;
}
Methinks this is a bug. It ought to work.
So for the time being, you're stuck with saving and restoring STDERR
yourself, pretty much as you did, but in a way that actually works. You
can do that by duping filehandles (open with ">&" prefix).
{
local *SAVEERR;
open SAVEERR, '>&STDERR';
open STDERR, ">error.log";
system $syscmd;
open STDERR, '>&SAVEERR';
}
--
Bart.
------------------------------
Date: Fri, 28 Apr 2000 00:11:33 +0100
From: "Uncle Arthur" <unclenospamarthur@oceanfree.net>
Subject: newbie question on GLOB
Message-Id: <2R3O4.8346$sB3.5960@news.indigo.ie>
Hi,
I am trying to use TokeParser at the moment but I keep getting this error
when I'm using this script I got from the Web Developer's site. Their script
is at the following URL:
http://wdvl.internet.com/Authoring/Languages/Perl/PerlfortheWeb/summarizer.h
tml
It is called parsepage.cgi. What I want to know is what this error message
means and how I should solve it? The error is below:
Not a GLOB reference at /usr/local/lib/perl5/site_perl/HTML/TokeParser.pm
line 43.
Thanks for your help,
Mark
------------------------------
Date: 28 Apr 2000 03:17:50 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: overloading & 'constant' subroutines
Message-Id: <8eavsu$o6m$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Phoenix
<rootbeer@redcat.com>],
who wrote in article <Pine.GSO.4.10.10004261125520.25963-100000@user2.teleport.com>:
> > x * x
> >
> > is, obviously to any Perler ;-), x(*x).
> > How would one fix this? The only thing which comes to mind is
> >
> > use strict 'globs';
> >
> > which would require globs to be written as *{'x'}?
>
> Well, it might require that, if only it were implemented. (So, are you
> saying this will be implemented in 5.6.1?)
It might be implemented, if only people would find it desirable.
> But that wouldn't solve the problem of x * x being misunderstood; it would
> simply make it a compile-time error. (Right?)
Yes, all that use/strict implies is an early detection of possible
errors. Which is good, especially if you use x * x to mean x(*x). ;-)
perl -wle 'print ******'
Ilya
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 2885
**************************************