[11856] in Perl-Users-Digest
Perl-Users Digest, Issue: 5455 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 22 15:07:25 1999
Date: Thu, 22 Apr 99 12:00:27 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 22 Apr 1999 Volume: 8 Number: 5455
Today's topics:
cookie being shown in browser <rgl34@hotmail.com>
Error 2 during "make install" <mflaherty2@earthlink.net>
Re: FAQ 4.14: How can I find the Julian Day? (Larry Rosler)
Re: FAQ 4.14: How can I find the Julian Day? <tchrist@mox.perl.com>
Re: FAQ 4.14: How can I find the Julian Day? <cassell@mail.cor.epa.gov>
Re: FAQ 4.14: How can I find the Julian Day? (Larry Rosler)
Re: FAQ 4.15: How do I find yesterday's date? <dgris@moiraine.dimensional.com>
Re: FAQ 4.15: How do I find yesterday's date? <cassell@mail.cor.epa.gov>
Re: FAQ 4.15: How do I find yesterday's date? (Bernie Cosell)
Re: Generating a unique string for order number <jeff@vpservices.com>
Help: Problem capturing cntl-c signal in perl script <ecastle@nuance.com>
Re: how do you pass hashes to functions? <tchrist@mox.perl.com>
Re: How to check for Null input or spaced input <mhc@Eng.Sun.COM>
How to read the modification date of a file? <howitgolook@my-dejanews.com>
Re: How to read the modification date of a file? (Randal L. Schwartz)
Re: How to read the modification date of a file? (Randal L. Schwartz)
How to run scripts that need to touch system files? <lcalero@gsyc.inf.uc3m.es>
Re: Illegal seek (this makes no sense to me =) <emschwar@rmi.net>
Re: Is it possible to have "..." appear while processin (Larry Rosler)
Re: Is it possible to have "..." appear while processin <vallon@bear.com>
Re: Is there a shorter way? <uri@sysarch.com>
Re: last item in associative array. (Randal L. Schwartz)
Re: last item in associative array. (Andrew Allen)
Re: last item in associative array. <tchrist@mox.perl.com>
Re: last item in associative array. (Larry Rosler)
Re: last item in associative array. (Randal L. Schwartz)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 22 Apr 1999 11:19:45 -0700
From: "Robert Long" <rgl34@hotmail.com>
Subject: cookie being shown in browser
Message-Id: <7fnp9d$9t8@masters0.InterNex.Net>
I have a rather complicated CGI that uses "plug-ins", that is it passes the
parsed information from a form on to a small script. I have a "plug-in" that
delivers a cookie, however, the cookie is displayed in the browser window.
I am using CGI.pm to do this, but I'm afraid I am not using it
correctly....below is the code that is delivering the cookie.
use CGI qw(:standard);
$debug=0;
print header if $debug;
print "Testing<br>" if $debug;
$query = new CGI;
%destination = qw(RAuth
http://www.rlong.com/legal/trademarp/pusage_logo/download_instr.html
rlongDALAN http://support.rlong.com/nav/license.htm
rlongDADMI http://support.rlong.com/nav/license.htm
rlongDAMBA ftp://ftp.rlong.com/pub/nic/bw98util.exe
rlongDAMPC
http://www.rlong.com/client/mcd/technology/damobile/software.html
);
foreach $cookie (keys %destination) {
print "\$cookie is $cookie\n" if $debug;
$dest = param('Dest');
if ($cookie eq $dest){
if ($cookie = $query->cookie($cookie)) {
print "\$cookie is now $cookie\n" if $debug;
$gotit = $destination{$cookie};
print "<H1>got it $gotit</H1><H1>destination $destination{$cookie}</H1>"
if $debug;
}
}
}
if ($gotit ne "") {
print "Location: $gotit\n\n";
exit;
} else {
print "Error";
}
------------------------------
Date: 22 Apr 1999 18:50:47 GMT
From: "Mike Flaherty" <mflaherty2@earthlink.net>
Subject: Error 2 during "make install"
Message-Id: <7fnr27$mrt$14@newsread.f.de.uu.net>
I tried installing perl 5.005_03 on Solaris 2.6.
I did...
1) rm -f config.sh Policy.sh (weren't there to begin with)
2) sh .Configure
3) make
4) make test
5) make install - then I got the following error...
sparky# make install
AutoSplitting perl library
./miniperl -Ilib -e 'use AutoSplit; \
autosplit_lib_modules(@ARGV)' lib/*.pm lib/*/*.pm
Making DynaLoader (static)
make[1]: Entering directory `/scratch/perl5.005_03/ext/DynaLoader'
make[1]: Leaving directory `/scratch/perl5.005_03/ext/DynaLoader'
make[1]: Entering directory `/scratch/perl5.005_03/ext/DynaLoader'
rm -rf ../../lib/auto/DynaLoader/DynaLoader.a
ar cr ../../lib/auto/DynaLoader/DynaLoader.a DynaLoader.o && :
../../lib/auto/DynaLoader/DynaLoader.a
/bin/sh: ar: not found
make[1]: *** [../../lib/auto/DynaLoader/DynaLoader.a] Error 1
make[1]: Leaving directory `/scratch/perl5.005_03/ext/DynaLoader'
make: *** [lib/auto/DynaLoader/DynaLoader.a] Error 2
sparky#
Thanks in Advance,
Mike Flaherty
Westwood, MA
------------------------------
Date: Thu, 22 Apr 1999 11:12:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.14: How can I find the Julian Day?
Message-Id: <MPG.1189065de351e8f7989913@nntp.hpl.hp.com>
In article <371F5A2F.D514AE6E@mail.cor.epa.gov> on Thu, 22 Apr 1999
10:19:43 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
> Tom Christiansen wrote:
...
> > How can I find the Julian Day?
> >
> > Neither Date::Manip nor Date::Calc deal with Julian days. Instead,
> > there is an example of Julian date calculation that should help you
> > in
> > http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time/J
> > ulianDay.pm.gz .
>
> Okay, I've seen this request several times in this newsgroup since,
> say, February. Are these people *really* interested in this, or do
> you think the problem is that they don't understand what the Julian Day
> really is?
>
> Are they really just interested in a way of getting serial days so
> that they can do date arithmetic? If so, then are we doing them a
> disservice by not pointing out the issue? Something like:
>
> If you are interested in performing date arithmetic, this can
> be done using either Date::Manip or Date::Calc, without
> converting to Julian Day first.
Another possible source of confusion is that the term 'Julian day' is
often (mis)used to refer to the serial number of the day of the year.
(The strftime() format for this is '%j'. Derrr...)
So maybe the FAQ should also explain this and point to the $yday output
((gm|local)time)[7]. Taking into account leap-year complexities when
the years of two dates are different, day intervals can be calculated
just by subtracting two such values if they are in the same year.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Apr 1999 12:48:47 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 4.14: How can I find the Julian Day?
Message-Id: <371f6f0f@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
:Another possible source of confusion is that the term 'Julian day' is
:often (mis)used to refer to the serial number of the day of the year.
:(The strftime() format for this is '%j'. Derrr...)
That's ok. On many platforms, strftime %C is equivalently idiotic.
Whoever did strftime() was, er, underresearched.
--tom
--
If you take Fred Cohen's definition of virus, then Unix itself is
one of the most successful viruses ever written, since it tends to
result in the creation of modified versions of itself on other
computer systems! -- Gene Spafford
------------------------------
Date: 22 Apr 1999 18:50:42 GMT
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: FAQ 4.14: How can I find the Julian Day?
Message-Id: <7fnr22$mrt$10@newsread.f.de.uu.net>
Tom Christiansen wrote:
>
> (This excerpt from perlfaq4 - Data Manipulation
> ($Revision: 1.46 $, $Date: 1999/04/20 18:59:53 $)
> part of the standard set of documentation included with every
> valid Perl distribution, like the one on your system.
> See also http://language.perl.com/newdocs/pod/perlfaq4.html
> if your negligent system adminstrator has been remiss in his duties.)
>
> How can I find the Julian Day?
>
> Neither Date::Manip nor Date::Calc deal with Julian days. Instead,
> there is an example of Julian date calculation that should help you
> in
> http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time/J
> ulianDay.pm.gz .
Okay, I've seen this request several times in this newsgroup since,
say, February. Are these people *really* interested in this, or do
you think the problem is that they don't understand what the Julian Day
really is?
Are they really just interested in a way of getting serial days so
that they can do date arithmetic? If so, then are we doing them a
disservice by not pointing out the issue? Something like:
If you are interested in performing date arithmetic, this can
be done using either Date::Manip or Date::Calc, without
converting to Julian Day first.
Just wondering,
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: 22 Apr 1999 18:51:05 GMT
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.14: How can I find the Julian Day?
Message-Id: <7fnr2p$mrt$30@newsread.f.de.uu.net>
In article <371F5A2F.D514AE6E@mail.cor.epa.gov> on Thu, 22 Apr 1999
10:19:43 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
> Tom Christiansen wrote:
...
> > How can I find the Julian Day?
> >
> > Neither Date::Manip nor Date::Calc deal with Julian days. Instead,
> > there is an example of Julian date calculation that should help you
> > in
> > http://www.perl.com/CPAN/authors/David_Muir_Sharnoff/modules/Time/J
> > ulianDay.pm.gz .
>
> Okay, I've seen this request several times in this newsgroup since,
> say, February. Are these people *really* interested in this, or do
> you think the problem is that they don't understand what the Julian Day
> really is?
>
> Are they really just interested in a way of getting serial days so
> that they can do date arithmetic? If so, then are we doing them a
> disservice by not pointing out the issue? Something like:
>
> If you are interested in performing date arithmetic, this can
> be done using either Date::Manip or Date::Calc, without
> converting to Julian Day first.
Another possible source of confusion is that the term 'Julian day' is
often (mis)used to refer to the serial number of the day of the year.
(The strftime() format for this is '%j'. Derrr...)
So maybe the FAQ should also explain this and point to the $yday output
((gm|local)time)[7]. Taking into account leap-year complexities when
the years of two dates are different, day intervals can be calculated
just by subtracting two such values if they are in the same year.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Apr 1999 12:22:56 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: FAQ 4.15: How do I find yesterday's date?
Message-Id: <m390bka51b.fsf@moiraine.dimensional.com>
David Cassell <cassell@mail.cor.epa.gov> writes:
> Perhaps Larry Rosler would like to contribute his DST-safe version
> to the FAQ? I think he already sent a copy to Dan Grisinger's
> script archive...
I've got Russ Allbery's yesterday function.
http://moiraine.dimensional.com/~dgris/cgi-bin/pfr?func=yesterday&type=exact
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 22 Apr 1999 18:50:44 GMT
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: FAQ 4.15: How do I find yesterday's date?
Message-Id: <7fnr24$mrt$12@newsread.f.de.uu.net>
Philip Newton wrote:
>
> Tom Christiansen wrote:
> > [snip]
> > $yesterday = time() - ( 24 * 60 * 60 );
>
> Not daylight saving time safe, if I understand it correctly. At the
> transition to and from DST, days are 23 and 25 hours long.
>
> So you might, possibly, get today's date or the-day-before-yesterday's
> date out of this function.
Perhaps Larry Rosler would like to contribute his DST-safe version
to the FAQ? I think he already sent a copy to Dan Grisinger's
script archive...
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: 22 Apr 1999 18:50:54 GMT
From: bernie@fantasyfarm.com (Bernie Cosell)
Subject: Re: FAQ 4.15: How do I find yesterday's date?
Message-Id: <7fnr2e$mrt$21@newsread.f.de.uu.net>
Tom Christiansen <perlfaq-suggestions@perl.com> wrote:
} How do I find yesterday's date?
}
} The `time()' function returns the current time in seconds since the
} epoch. Take one day off that:
}
} $yesterday = time() - ( 24 * 60 * 60 );
}
} Then you can pass this to `localtime()' and get the individual
} year, month, day, hour, minute, seconds values.
This isn't quite correct. There is an ugly-to-program-around problem
dealing with daylight savings time. The problem is fairly limited: only
arises if you happen to be running your program right after midnight (local
time) of the day after the change *to* daylight savings time (so it is
daylight savings time now, but was *not* daylight savings time yesterday at
this time). In that case, subtracting 24 hrs from the current time will
get you to right after 11PM *two*days*ago*, not -yesterday-. Maybe an
algorithm that only fails for one hour per year is "close enough"...:o)
You have the same problem in the opposite direction if you're trying to
figure out the date for tomorrow at the other DST-time-switch.
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Thu, 22 Apr 1999 10:20:23 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Generating a unique string for order number
Message-Id: <371F5A57.FEB572C6@vpservices.com>
Ronald J Kimball wrote:
>
> Greg McCann <gregm@well.com> wrote:
>> $$ (process id) - May be good concatenated with time.
>
> Another bad idea. The numbers do repeat eventually. Process ids are
> unique, but they have a temporary lifespan. Using them for
> permanently unique numbers doesn't make sense.
Yes, process ids repeat, but (except in science fiction and on horribly
misconfigured machines) time doesn't. Two things may be submitted at
the same time, but then their PID would be different. Two things may be
submitted with the same PID, but then their time would be different. So
concatenating time and process id would give a unique id wouldn't it?
--
Jeff
------------------------------
Date: Thu, 22 Apr 1999 11:13:39 -0700
From: Eric Castle <ecastle@nuance.com>
Subject: Help: Problem capturing cntl-c signal in perl script
Message-Id: <371F66D3.A31EBD06@nuance.com>
I'm trying to add a Control-C interrupt handler to my perl script. I've
looked at verious Perl books and web pages and have not found anything
that describes what I'm seeing.
My script runs a series of executables, some of which are servers and
need to run in the background and the rest are run in the foreground
using the open command.
So the script runs background processes by using the system command
like:
system("program >outfile 2>errfile &")
The script also runs foreground processes by using the open system call
like:
$write_to_child = new FileHandle;
if( open( $write_to_child, | "program >outfile 2>errfile") {
print $write_to_child +(join('\n', @input)) if @input;
close $write_to_child;
}
I send any stdin to the program being run if any input has been given.
So the script spends most of its time running the programs started by
using the open call like above.
I wanted to add a interrupt handler so that if the user presses Cntl-C
at the keyboard the script would then in the Cntl-C signal handler, stop
any background processes that have been started and then exit ( I keep
track of the background processes using ps and their pids and then issue
kill command and already have a subroutine that takes care of all that.
I want to call this subroutine from my signal handler.)
The problem seems to be that when the user hits Cntl-C, my signal
handler in the script doesn't see the Cntl-C, instead it appears the
program being run by the open call gets the signal instead. This causes
that program to exit, but then I don't end up in my signal handler at
all. So the script then goes and runs the next program. Each Cntl-C I
type just ends up killing the current program being run by the open
command. I've even seen the background process I had started earlier get
the Cntl-C's!!! I think in that case though, one of the client programs
is feeding the interrupt signal through to the server its connected to.
What I want to happen is for my script to catch the signal in the signal
handler FIRST, and then it would shut down any running servers and exit
(thereby hopefully ending the program being run by open). Is there some
way for my signal handler to get the Cntl-C signal first and not the
program being run by the open command? Why doesn't the signal go to my
signal handler first?
FYI my signal handler looks like:
sub handle_interrupt {
my $signame = shift;
print "\n received signal SIG$signame\n";
print "\n --- Control-C pressed, cleaning up before exit ------\n";
if( %bg_processes ) {
print "Shutting down background processes....\n";
&stop_all_servers;
}
exit;
}
And of course earlier in the script I have the line:
$SIG{INT} = \&handle_interrupt;
Thanks for any help.
Eric
------------------------------
Date: 22 Apr 1999 12:53:11 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: how do you pass hashes to functions?
Message-Id: <371f7017@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"Dunn One" <obinani@popd.ix.netcom.com> writes:
:I've been trying this and it just doesn't work. Can anyone please help?
I believe that you'll find that if you were to bother to read the fine
perlsub manpage included with every perl distribution, that your answer
is there waiting for you on your very own system.
--tom
--
Pretty printers mechanically produce pretty output that accentuates
irrelevant detail in the program, which is as sensible as putting all
the prepositions in English text in bold font. --Rob Pike
------------------------------
Date: 22 Apr 1999 11:30:28 -0700
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: How to check for Null input or spaced input
Message-Id: <8p6vheo33uj.fsf@Eng.Sun.COM>
JG <gebhardt@erinet.com> writes:
> I am struggling to find a way to ensure when a user is prompted for
> input that the input is not just a bunch of spaces or null input. The
> tricky part is that valid input can contain spaces. Any suggestions?
>
> JG
$prompt = "> ";
$input = "";
while ($input =~ /^\s*$/) {
print $prompt;
$input = <STDIN>;
}
-mike
------------------------------
Date: 22 Apr 1999 18:50:47 GMT
From: howitgolook <howitgolook@my-dejanews.com>
Subject: How to read the modification date of a file?
Message-Id: <7fnr27$mrt$15@newsread.f.de.uu.net>
How can I determine the modification date of a file on a remote server?
I am indexing a web site for use in a search engine, and I need to be able to
check if a page has been modified before updating its record in the database.
Thanks in advance.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Apr 1999 10:51:18 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How to read the modification date of a file?
Message-Id: <m1emlc5ysp.fsf@halfdome.holdit.com>
>>>>> "howitgolook" == howitgolook <howitgolook@my-dejanews.com> writes:
howitgolook> How can I determine the modification date of a file on a
howitgolook> remote server? I am indexing a web site for use in a
howitgolook> search engine, and I need to be able to check if a page
howitgolook> has been modified before updating its record in the
howitgolook> database.
Perhaps you can share what protocol you are using to talk to the
remote "server" site? HTTP? FTP? telnet? rlogin? SSH? TFTP? NFS? AFS?
SMB? Kermit? UUCP? XMODEM? Kerberos? Sneaker-net? Psychic-powers?
<sigh>
If you're using HTTP (just a guess, but probably the most likely
guess), and doing it the right way with LWP, you can add an
"if-modified-since" header to the request, and the server will return
with a 304 error if the file hasn't changed. Examples of that can be
found in my WT columns, online at:
http://www.stonehenge.com/merlyn/WebTechniques/
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 22 Apr 1999 18:51:04 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How to read the modification date of a file?
Message-Id: <7fnr2o$mrt$29@newsread.f.de.uu.net>
>>>>> "howitgolook" == howitgolook <howitgolook@my-dejanews.com> writes:
howitgolook> How can I determine the modification date of a file on a
howitgolook> remote server? I am indexing a web site for use in a
howitgolook> search engine, and I need to be able to check if a page
howitgolook> has been modified before updating its record in the
howitgolook> database.
Perhaps you can share what protocol you are using to talk to the
remote "server" site? HTTP? FTP? telnet? rlogin? SSH? TFTP? NFS? AFS?
SMB? Kermit? UUCP? XMODEM? Kerberos? Sneaker-net? Psychic-powers?
<sigh>
If you're using HTTP (just a guess, but probably the most likely
guess), and doing it the right way with LWP, you can add an
"if-modified-since" header to the request, and the server will return
with a 304 error if the file hasn't changed. Examples of that can be
found in my WT columns, online at:
http://www.stonehenge.com/merlyn/WebTechniques/
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 22 Apr 1999 18:50:49 GMT
From: Luis Calero Munoz <lcalero@gsyc.inf.uc3m.es>
Subject: How to run scripts that need to touch system files?
Message-Id: <7fnr29$mrt$17@newsread.f.de.uu.net>
Hi!
I'm writing a CGI that needs to write to system files but the thing
is that I don't want to make it 4755 because it seems it too
insecure. I've read that suidperl could be a solution, but I haven't
found info about it ( man suidperl doesn't help ) and don't know how
to set it up... anyone knows how to run it?
Besides, any help about how to do this thing without being so
dangerous??
Thanx in advance...
--
Luis Calero Mu~noz lcalero@gsyc.inf.uc3m.es
Grupo de Sistemas y Comunicaciones a01-unix.gsyc.inf.uc3m.es/~lcalero
GSyC - Univ. Carlos III de Madrid PGP public key available @ web
------------------------------
Date: 22 Apr 1999 12:52:07 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Illegal seek (this makes no sense to me =)
Message-Id: <xkfemlcij3c.fsf@valdemar.col.hp.com>
phukit@enteract.com writes:
> It doesn't outright fail, but when it closes <SENDMAIL> /usr/sbin/sendmail
> never gets run. That "Illegal Seek" error is the only indication I have
> that something happens between the open and close.
But that's the wrong place to look. Haven't you read the documentation
that comes with perl?
perldoc perlipc, "Using open() for IPC"
-=Eric
------------------------------
Date: Thu, 22 Apr 1999 11:43:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Is it possible to have "..." appear while processing?
Message-Id: <MPG.11890dbbf3d53ff5989914@nntp.hpl.hp.com>
In article <x6eyajkwnsj.fsf@pearl.bear.com> on Thu, 22 Apr 1999 17:46:52
GMT, Justin Vallon <vallon@bear.com> says...
...
> Gee. These threads really do wander.
You are right, as the Subject shows. To wrap up this subthread:
I, at least, am convinced that -- absent a locale-dependent method -- an
affirmative response should be tested as:
/^\s*[^\W\d_Nn]/
(i.e., any letter other than 'N' or 'n') which is essentially what I
posted two days ago, rather than:
/^\s*[Yy]/
which one of the responders chose to comment on, thereby starting this
subthread. He should have changed the Subject when he was changing the
subject. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Apr 1999 18:50:52 GMT
From: Justin Vallon <vallon@bear.com>
Subject: Re: Is it possible to have "..." appear while processing?
Message-Id: <7fnr2c$mrt$20@newsread.f.de.uu.net>
Tom Christiansen <tchrist@mox.perl.com> writes:
> Actually, the French answer to positive questions in "oui", but to
> negatives is "si". So, "Shall I delete your file?" (rendered into French,
> of course) gets "oui" or "non", but "Shall I not delete your file?"
> gets "si" or "non".
French aside, I believe this question would be poorly phrased. Such a
question is typically presented as a confirmation of an action to be
performed. The question should ask "Do blah-blah?" with a "Go" and
"Stop" type of answer.
Put another way, "No" would result in an implicit double negative "No,
you should not not delete my file", which may be technically correct
English, but would definately be bad style.
Of course, strict translation would require si/non.
Gee. These threads really do wander.
--
-Justin
vallon@bear.com
------------------------------
Date: 22 Apr 1999 18:50:41 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Is there a shorter way?
Message-Id: <7fnr21$mrt$9@newsread.f.de.uu.net>
>>>>> "p" == pingouino <pingouino@my-dejanews.com> writes:
p> Some friends of mine at work accidentally got into a little "challenge";
p> we implemented the same piece of code in different ways, then started
p> seeing who could do it in fewest characters. The task was to print out
p> an environment variable (in this case, USER) padded out to a minimum of
p> six characters with "x", or not modified if it was six characters or more.
p> So, "foo" becomes "fooxxx", "foos" becomes "foosxx", "foobar" remains
p> "foobar" and "foobars" remains "foobars" (note how the 7-letter word is
p> not truncated).
p> The best we came up with (with all unnnecessary spaces removed) was:
p> perl -e'$_=$ENV{USER};print$_."x"x(6-split//)'
you don't mention any rules about counting option letters or shell
tricks.
so this perl code is 2 perl chars shorter. if i could find a way to close <>
without the echo i would do that. also it assumes no spaces in a
username which is reasonable.
echo '' | perl -pe '$_=sprintf"%-6s",$ENV{USER};y/ /x/'
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 22 Apr 1999 10:39:07 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: last item in associative array.
Message-Id: <m1n2005zd0.fsf@halfdome.holdit.com>
>>>>> "J|rgen" == J|rgen Exner <juex@my-dejanews.com> writes:
J|rgen> To get the last element of a hash "myhash" using the
J|rgen> ordering function "mysort" use
J|rgen> %myhash{pop(sort (mysort, (keys %myhash)))}
J|rgen> (not sure if the syntax is accurate, but you got the idea).
It's not even very close, it's so off. :)
Perhaps you wanted $myhash{(sort mysort keys %myhash)[-1]}?
Otherwise... %foo{} is wrong, you can't pop a list (only an array),
and sort doesn't want a comma after the sort function.
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 22 Apr 1999 18:34:23 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: last item in associative array.
Message-Id: <7fnq3f$5jv$2@fcnews.fc.hp.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: Whether or not that is the 'last' element is debatable, as you say. I
: interpreted it as the last value added to the hash.
While we're on the subject of "what the poster _didn't_ want", here's
one idea:
${[%myhash]}[-1];
It certainly is "the last item in [an] associative array [when interpreted
as a list]" ;)
<ducks for cover>
Andrew
------------------------------
Date: 22 Apr 1999 12:45:16 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: last item in associative array.
Message-Id: <371f6e3c@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "J|rgen Exner" <juex@my-dejanews.com> writes:
:Therefore we imply that the first element of an array is the element
I half suspect that you confuse "infer" with "imply", but perhaps
you really meant what you wrote. See the happy dictionary.
--tom
--
#else /* !STDSTDIO */ /* The big, slow, and stupid way */
--Larry Wall in str.c from the 4.0 perl source code
------------------------------
Date: 22 Apr 1999 18:50:57 GMT
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: last item in associative array.
Message-Id: <7fnr2h$mrt$23@newsread.f.de.uu.net>
[Posted and a courtesy copy mailed.]
In article <7fnkl7$b6i@news.dns.microsoft.com> on Thu, 22 Apr 1999
10:02:52 -0700, J|rgen Exner <juex@my-dejanews.com> says...
...
> To get the last element of a hash "myhash" using the ordering function
> "mysort" use
>
> %myhash{pop(sort (mysort, (keys %myhash)))}
>
> (not sure if the syntax is accurate, but you got the idea).
pop() works on arrays, not lists. And an element of a hash is a scalar.
So:
$myhash{(sort mysort keys %myhash)[-1]}
produces the 'largest' element in the hash according to some criterion.
Whether or not that is the 'last' element is debatable, as you say. I
interpreted it as the last value added to the hash.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Apr 1999 18:51:03 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: last item in associative array.
Message-Id: <7fnr2n$mrt$28@newsread.f.de.uu.net>
>>>>> "J|rgen" == J|rgen Exner <juex@my-dejanews.com> writes:
J|rgen> To get the last element of a hash "myhash" using the
J|rgen> ordering function "mysort" use
J|rgen> %myhash{pop(sort (mysort, (keys %myhash)))}
J|rgen> (not sure if the syntax is accurate, but you got the idea).
It's not even very close, it's so off. :)
Perhaps you wanted $myhash{(sort mysort keys %myhash)[-1]}?
Otherwise... %foo{} is wrong, you can't pop a list (only an array),
and sort doesn't want a comma after the sort function.
print "Just another Perl hacker,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5455
**************************************