[9661] in Perl-Users-Digest
Perl-Users Digest, Issue: 3255 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 25 23:07:18 1998
Date: Sat, 25 Jul 98 20:00:58 -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 Sat, 25 Jul 1998 Volume: 8 Number: 3255
Today's topics:
ARGV darrensw@pacbell.net
Re: ARGV darrensw@pacbell.net
Re: Can't Get hello.pl to work <gprasad@ti.com>
Re: Can't Get hello.pl to work (Abigail)
Re: chomp or other command to eliminate LF and or CR fr (Abigail)
Re: Date Question... (Abigail)
Re: Detecting Countries <sdh1@anchor.hotmail.com>
Re: Detecting Countries (Abigail)
Re: Help Reading a directory structure (brian d foy)
Re: Help Reading a directory structure <ahaas@neosoft.com>
Re: Help Reading a directory structure (Abigail)
IGNORE Re: forking processes in proxy script schnibitz@my-dejanews.com
newbie string questions. <rainkid@rainkid.com>
Re: newbie string questions. <sdh1@anchor.hotmail.com>
Re: perl as pseudocode (brian d foy)
Re: perl as pseudocode <ghira@mistral.co.uk>
Re: perl as pseudocode <ghira@mistral.co.uk>
Re: perl as pseudocode <ghira@mistral.co.uk>
Re: Personality testing (Shawn O'Donnell)
problem undefining hash (Sweth Chandramouli)
Re: problem undefining hash (Larry Rosler)
Re: problem undefining hash <uri@sysarch.com>
Re: Same code, diff machines, diff results (hymie!)
Re: subs in separate files? <melinda@acm.org>
Re: Tcl is better than Perl <tchrist@mox.perl.com>
Timeout, Socket, Windows (-)
win32 embedding perl in c (Jonathan Dude)
Re: Y2K problem in PERL with localtime() (Dr. Werner Eberl)
Re: Y2K problem in PERL with localtime() (Larry Rosler)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 26 Jul 1998 00:32:03 GMT
From: darrensw@pacbell.net
Subject: ARGV
Message-Id: <35ba76ee.19281957@news.pacbell.net>
Hi all
I am using an argument vector to transfer info between subroutines ...
pretty standard.
I am using the following HTML line as a client would like to review
history of their clients.
<A HREF=\"$ENV{'SCRIPT_NAME'}\?viewseller&$lastsale[0]\">Click to see
all sales for this client</A>
$lastsale[0] being the first field in an array.
The script then goes and searches all files for the clints name,
$lastsale[0].
so:
'http://mydomain.com/cgi-bin/sales.cgi?viewseller&Darren
is the command line.
The search works OK but I cannot get the client name to print.
I am trying to print:
All sales for - $ARGV[1]
I am struggling to understand how the script recognises the $ARGV[1]
to be able to conduct the search yet cannot print it.
Any ideas??
All help appreciated
Darren
------------------------------
Date: Sun, 26 Jul 1998 01:13:44 GMT
From: darrensw@pacbell.net
Subject: Re: ARGV
Message-Id: <35ba827e.22242248@news.pacbell.net>
On Sun, 26 Jul 1998 00:32:03 GMT, darrensw@pacbell.net wrote:
Hi again
I have been researching and think I have found the answer but don't
fully understand how.
Can anyone fully explain the next two lines to me please?:
$ARGV[0] =~ s/\W//g;
$ARGV[1] =~ s/\D//g;
Thanks again
Darren
------------------------------
Date: Sat, 25 Jul 1998 17:29:23 -0500
From: "Prasad Gandluri" <gprasad@ti.com>
Subject: Re: Can't Get hello.pl to work
Message-Id: <6pdlhv$g2g$1@tilde.csc.ti.com>
stan zylowski wrote in message <35B93E81.6616@en.com>...
>Can someone please offer advice..as to why this may not work
>on UNIX server. it goes okay on a Windows server.
>stan
>
>http://www.prymetime.com/cgi-bin/hello.pl
>
check if this perl script has executable permissions.
if not chmod 755 hello.pl
>code is
>#!/usr/bin/perl
>
check if this is /usr/local/bin/perl or some other location on your UNIX
server.
>print "Content-type: text/html\n\n";
>
>print "Hello, world!\n";
------------------------------
Date: 26 Jul 1998 02:13:25 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Can't Get hello.pl to work
Message-Id: <6pe3c5$a49$3@client3.news.psi.net>
stan zylowski (stanz@en.com) wrote on MDCCLXXXIX September MCMXCIII in
<URL: news:35B93E81.6616@en.com>:
++ Can someone please offer advice..as to why this may not work
++ on UNIX server. it goes okay on a Windows server.
++ stan
Give it more peanuts, perl programs do anything for them.
Abigail
--
Sometimes it helps to be a little less vague than "does not work".
------------------------------
Date: 26 Jul 1998 02:02:53 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: chomp or other command to eliminate LF and or CR from lines
Message-Id: <6pe2od$a49$1@client3.news.psi.net>
Craig Berry (cberry@cinenet.net) wrote on MDCCLXXXIX September MCMXCIII
in <URL: news:6pc2lq$hut$3@marina.cinenet.net>:
++ Abigail (abigail@fnx.com) wrote:
++ : Mark Thompson (mark-lists@webstylists.com) wrote on MDCCLXXXVIII
++ : September MCMXCIII in <URL: news:35b91eba.4916101@news.supernews.com>:
++ : ++
++ : ++ I know chomp will only get rid of the EOL character that's in $/ which varies
++ : ++ from time to time. Is there an easy way to get rid of all LF and CR (and
++ : ++ regular spaces for that matter)? It can't get rid of tabs though (the last
++ : ++ field might be blank but I need to differentiate that condition from the
++ : ++ condition of not having the right number of fields.)
++ :
++ : s/[\r\n ]+//;
++
++ That only gets rid of the first string of such chars found (though /g
++ would fix that), and it's more work than is needed. The tr solution
++ suggested by several other folks on this thread is the way to go.
Yes, I actually meant:
s/[\r\n ]+$//;
as I was under the impression he only wants to remove at the end.
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: 26 Jul 1998 02:22:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Date Question...
Message-Id: <6pe3s8$a49$4@client3.news.psi.net>
Larry Rosler (lr@hpl.hp.com) wrote on MDCCLXXXIX September MCMXCIII in
<URL: news:MPG.10239b16cb5cea78989788@nntp.hpl.hp.com>:
++ [Posted to comp.lang.perl.misc and copy mailed.]
++
++ In article <6pb4he$2jh$1@pegasus.csx.cam.ac.uk> on 24 Jul 1998 23:14:54
++ GMT, M.J.T. Guy <mjtg@cus.cam.ac.uk> says...
++ >
++ > You may well get away with that in practice, if you only use it during
++ > working hours. But not all days are 24 hours long. Think about
++ > daylight saving changes.
++
++ OK, lets! The following should be bulletproof, in the sense that it
++ prints "yesterdays's date" (as requested by the original poster) together
++ with the current local time (even if that was 23 or 25 hours ago). It
++ relies on the property that the date 24 hours before local midnight is
++ always the previous date, regardless of Daylight Savings Time transitions
++ (which never happen near midnight, to avoid this very confusion). The
++ scalar localtime function still does the heavy work of figuring out what
++ year/month/day that date is.
Ah, but leap seconds happen at midnight!
$ perl -MTime::JulianDay -wle '$, = ", ";
print inverse_julian_day (local_julian_day (time) - 1)'
1998, 7, 24
$
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Sat, 25 Jul 1998 22:02:38 -0400
From: "Scott" <sdh1@anchor.hotmail.com>
Subject: Re: Detecting Countries
Message-Id: <6pe2r1$of1$1@camel29.mindspring.com>
You could sell a dongle with it that has a GPS receiver. :-)
I'd look at the domain, and if it ends with one of the myriad of USA or the
Canadian postfix, you could not let it run.
Of course, Boris and Natasha would probably catch on to your scheme and
foil your attempt.
Chris wrote in message <6pb16o$5ps$1@news1.epix.net>...
>Hello,
>
>I have an encryption program that may not be exported except to Canada. It
>may only be sold in the US and Canada.
>
>I want the perl script to check if the user is the US or Canada, and if
they
>are not - tell them that they must be from the US or Canada.
>
>So far I have written a perl script that checks by using
>$ENV{'HTTP_ACCEPT_LANGUAGE'}. I looks for a the match "en-us". Is this the
>best way to do this? Can someone point me to a list of
>'HTTP_ACCEPT_LANGUAGE' so I can find all the ones for US and Canada?
>
>Thanks for your help
>- Chris
>
>
>
------------------------------
Date: 26 Jul 1998 02:06:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Detecting Countries
Message-Id: <6pe2vl$a49$2@client3.news.psi.net>
file (file@job.to) wrote on MDCCLXXXIX September MCMXCIII in
<URL: news:6pd2oc$m7f$1@usenet36.supernews.com>:
++ according to altavista they can detect from which country people are coming
++ and then show them the appropriate ad... that is what they told me when I
++ asked about advertising there...
++ If you do find a way please do let me know
But Alta-vista can afford it to be right 90% of the time.
(BTW, did I mention proxy services?)
What does this all have to do with Perl anyway?
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=>()'
------------------------------
Date: Sat, 25 Jul 1998 16:36:51 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Help Reading a directory structure
Message-Id: <comdog-2507981636510001@news.panix.com>
Keywords: just another new york perl hacker
In article <6pd9s2$dl8@news-central.tiac.net>, "The Needham's" <needcrew@tiac.net> posted:
> I am trying to pass a script the name of a directory and have the script
> read all the entries below that directory name. If there are any sub
> What can I do to read all of the directories and files and tell the
> difference between them.
write a subroutine to read the directory contents, and use that
subroutine recursively.
good luck :)
--
brian d foy <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: Sun, 26 Jul 1998 09:50:16 +0000
From: Art Haas <ahaas@neosoft.com>
Subject: Re: Help Reading a directory structure
Message-Id: <35BAFBD8.D30D85EF@neosoft.com>
The Needham's wrote:
>
> HI,
>
> I am trying to pass a script the name of a directory and have the script
> read all the entries below that directory name. If there are any sub
> directories then I want it to look in there to. a sample directory
> structure is like this
>
> Images - directory
> image1.jpg - file
> image2.jpg - file
> Misc - subdirectory
> Image 3.jpg -file
> Other - subdirectory
> image 4.jpg -file
>
> I have tried using
>
> opendir(DIR, $ARGV[0]) || die "Cannot open $ARGV[0]\n";
> @dirs = readdir(DIR);
> foreach $item (@dirs) {
> if (-d $item) {
> push @newDirs, $item;
> }
> }
> to seperate the directories, but all I get is the "." and ".." directories.
>
> What can I do to read all of the directories and files and tell the
> difference between them.
>
> Thanks in advance
>
> Mike Needham
You could try using 'File::Find' and see if it gives you
the functionality you're looking for. If you want to
roll your own directory searcher, try this:
@dirs = ();
die "\nPass a directory!\n\n" unless ($ARGV[0] ne '');
$dir = shift(@ARGV);
die "\n'$dir' is not a directory!\n" unless (-d $dir);
push(@dirs,$dir);
while(defined($dir = pop(@dirs))) {
opendir(DIR,$dir) || die "\nCan't open directory '$dir'!\n\n";
@files = grep(!/^\.\.?$/,readdir(DIR)); # skip '.' and '..'
while(defined($file = pop(@files))) {
$fname = join('/',$dir,$file);
if (-d $fname) {
push(@dirs,$fname);
} else {
print "file is '$fname'.\n"; # process it somehow ...
}
}
}
Good luck.
Art Haas
------------------------------
Date: 26 Jul 1998 02:23:51 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help Reading a directory structure
Message-Id: <6pe3vn$a49$5@client3.news.psi.net>
The Needham's (needcrew@tiac.net) wrote on MDCCLXXXIX September MCMXCIII
in <URL: news:6pd9s2$dl8@news-central.tiac.net>:
++ HI,
++
++ I am trying to pass a script the name of a directory and have the script
++ read all the entries below that directory name. If there are any sub
++ directories then I want it to look in there to. a sample directory
++ structure is like this
And the reason you aren't using "find" or "File::Find" is?
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: Sat, 25 Jul 1998 22:25:49 GMT
From: schnibitz@my-dejanews.com
Subject: IGNORE Re: forking processes in proxy script
Message-Id: <6pdm1d$6uh$1@nnrp1.dejanews.com>
Mr. Schwartz, I figured out the problem with my script. I still could not
get yours to work, but I learned a lot from it. All I did with mine, is that
I split the "handle_response" and "handle_request" into subroutines and used
the:
my $pid = fork;
if ($pid) {
blah blah blah
exit 0 if defined $pid;
}
that you used in one of the processes in your proxy server code(not sure if I
worded that right). Anyhow, it handles as requests and responses like mad,
and it also solved another problem I had: I could not download. Now I can.
Anyhow, had I not studied your code, none of this would have been possible.
Thanx! ~Prime
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Sat, 25 Jul 1998 20:56:24 -0400
From: "rainkid" <rainkid@rainkid.com>
Subject: newbie string questions.
Message-Id: <6pdv2a$18h@bgtnsc02.worldnet.att.net>
Ok, i have avariable, say $para, that contains a whole paragraph of text.
what is the command that would cut $para so i stops when it sees a certain
character?
for example... let say i want ¶ to be the first sentence and not the
whole paragraph so how would i set $para so i contains all the characters
from the first to the first period?
thanks for your help guys.
------------------------------
Date: Sat, 25 Jul 1998 21:51:45 -0400
From: "Scott" <sdh1@anchor.hotmail.com>
Subject: Re: newbie string questions.
Message-Id: <6pe26k$jca$1@camel29.mindspring.com>
Well, to get to you before the RTFM crowd.
$para = "See Dick run. See Jane run. Run Dick run. Run Jane Run";
$para =~ s/^(.*\.).*$/$1\./;
However, if $para = "Rob Peter to pay St. Paul. The dog ate the cat."
you will end up with "Rob Peter to pay St.".
Get a good book on regular expressions. Or, at least get a good perl book
with a chapter on the subject. If you are on some flavor of Unix, print out
the
man page for regexp and read through it.
rainkid wrote in message <6pdv2a$18h@bgtnsc02.worldnet.att.net>...
>Ok, i have avariable, say $para, that contains a whole paragraph of text.
>what is the command that would cut $para so i stops when it sees a certain
>character?
>for example... let say i want ¶ to be the first sentence and not the
>whole paragraph so how would i set $para so i contains all the characters
>from the first to the first period?
>
>thanks for your help guys.
>
>
>
------------------------------
Date: Sat, 25 Jul 1998 16:31:10 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl as pseudocode
Message-Id: <comdog-2507981631100001@news.panix.com>
Keywords: just another new york perl hacker
In article <599.510T248T9222629@mistral.co.uk>, "Adam Atkinson" <ghira@mistral.co.uk> posted:
> On 25-Jul-98 00:20:05, Ronald J Kimball said:
>
> >> while ($j!=undef) {
>
> >This is exactly equivalent to ($j != 0), except one of them will give a
> >warning under -w, and one won't. I'll let you figure out which is
> >which. ;-)
>
> Hmm. I don't want to check whether things are 0 because in some of the
> examples I used "0" was an available symbol, and is certainly an
> array subscript in use. So I definitely DO need
> to check for undefinedness.
but did you try what chipmunk said?
observe the output of:
#!/usr/bin/perl
sub tests
{
my $j = shift;
print "--- j = [$j] ------\n";
print "j != undef\n" if $j != undef;
print "j != 0\n" if $j != 0;
print "j ne undef\n" if $j ne undef;
print "j ne 0\n" if $j ne 0;
}
foreach ( undef, 0, '0', 1 ) { tests $_ }
__END__
good luck :)
--
brian d foy <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: 25 Jul 98 22:53:13 +0000
From: "Adam Atkinson" <ghira@mistral.co.uk>
Subject: Re: perl as pseudocode
Message-Id: <565.510T653T13732898@mistral.co.uk>
On 25-Jul-98 15:44:56, you said:
>> Hmm. I don't want to check whether things are 0 because in some of the
>> examples I used "0" was an available symbol, and is certainly an
>> array subscript in use. So I definitely DO need
>> to check for undefinedness.
>Then use the function that Perl provides for this purpose. `perldoc -f
>defined`
Ok, fair enough. Guilty as charged - I'll get that right in future... But
this isn't what I was asking about.
--
Adam Atkinson (ghira@mistral.co.uk)
#include <disclaimer.h>
------------------------------
Date: 25 Jul 98 22:59:17 +0000
From: "Adam Atkinson" <ghira@mistral.co.uk>
Subject: Re: perl as pseudocode
Message-Id: <786.510T895T13793000@mistral.co.uk>
On 25-Jul-98 21:31:10, brian d foy said:
>> Hmm. I don't want to check whether things are 0 because in some of the
>> examples I used "0" was an available symbol, and is certainly an
>> array subscript in use. So I definitely DO need
>> to check for undefinedness.
>but did you try what chipmunk said?
>good luck :)
Ok, ok... as I've just said, twice, "guilty as charged". (actually
the script USED to do a lot of awful messing about with arrays - the
business with the hash was a late addition... just after I read
the chapter on hashes and thought "ah, yes")
Whilst this is valuable info, and merits an "oops", it's not
really what I was asking about.
--
Adam Atkinson (ghira@mistral.co.uk)
I never could get the hang of Thursdays
------------------------------
Date: 25 Jul 98 22:57:10 +0000
From: "Adam Atkinson" <ghira@mistral.co.uk>
Subject: Re: perl as pseudocode
Message-Id: <488.510T502T13773463@mistral.co.uk>
On 25-Jul-98 18:47:08, Craig Berry said:
>But the point is that doing '$j != undef' does *not* check that $j is
>defined, but rather that it is not equal to zero.
>To see whether $j is
>defined, the rather transparent syntax is 'defined $j'.
Right. Ok. I'll get this right in future.
this is clearly useful to learn, but isn't really why
I posted my message
--
Adam Atkinson (ghira@mistral.co.uk)
I never could get the hang of Thursdays
------------------------------
Date: Sat, 25 Jul 1998 16:50:51 -0400
From: shawn@ultranet.com (Shawn O'Donnell)
Subject: Re: Personality testing
Message-Id: <shawn-2507981650510001@d170.dial-1.cmb.ma.ultra.net>
In article <Pine.GSO.4.02.9807242037160.25503-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
> On Tue, 21 Jul 1998, Clinton Gormley wrote:
>
> > Do you know of a personality test written in perl that i could
> > incorporate into a web site?
>
>There are many freeware and shareware archives which you can find by
>searching Yahoo or a similar service. Hope this helps!
My Altavista search for:
Scientology AND perl
yielded 625 results.
On ever-so-slightly less shaky ground, see
http://www.oise.utoronto.ca/~ggay/lstests.htm
wait for the birdies to land, and then look at the bottom of the page.
Follow the links to the source code.
--Shawn
------------------------------
Date: Sat, 25 Jul 1998 20:58:59 GMT
From: sweth-usenet@astaroth.nit.gwu.edu (Sweth Chandramouli)
Subject: problem undefining hash
Message-Id: <sweth-usenet-2507981659010001@alex-va-n013c081.moon.jic.com>
this is definitely something simple that i'm missing. i have the
following block of code in a script of mine, designed to read key,value
pairs from a file (opened elsewhere) and pump them into a hash:
sub init_hash {
if (keys %id_hash) {undef %id_hash} || die 'undef failed';
while (<INPUT_FILE>) {
@tmp_array = split(/,/);
$id_hash{$tmp_array[0]} = $tmp_array[1];
};
};
since this block is called multiple times, i originally had the first
line as just:
undef %id_hash || die 'undef failed';
this returned 'undef failed'. i assumed that the undef didn't succeed
because the first time through, %id_hash isn't defined (couldn't find
anywhere in the faq or the camel book whether undef would choke on
something already undef-ed, though it doing so doesn't make much sense to
me), so i put in if statement to check first; now i get a syntax error on
that line, instead. what am i doing wrong here?
tia,
sweth.
--
Sweth Chandramouli
IS Coordinator, The George Washington University
<sweth@gwu.edu> / (202) 994 - 8521 (V) / (202) 994 - 0458 (F)
<a href="http://astaroth.nit.gwu.edu/~sweth/disc.html">*</a>
------------------------------
Date: Sat, 25 Jul 1998 14:57:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: problem undefining hash
Message-Id: <MPG.1023f49447e796b098978c@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <sweth-usenet-2507981659010001@alex-va-n013c081.moon.jic.com>
on Sat, 25 Jul 1998 20:58:59 GMT, Sweth Chandramouli <sweth-
usenet@astaroth.nit.gwu.edu> says...
...
> undef %id_hash || die 'undef failed';
>
> this returned 'undef failed'. i assumed that the undef didn't succeed
> because the first time through, %id_hash isn't defined (couldn't find
> anywhere in the faq or the camel book whether undef would choke on
> something already undef-ed, though it doing so doesn't make much sense to
> me), so i put in if statement to check first; now i get a syntax error on
> that line, instead. what am i doing wrong here?
RTFM. `perldoc -f undef` tells us:
undef ... Always returns the undefined value. ...
Does that help?
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 Jul 1998 22:24:25 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: problem undefining hash
Message-Id: <x7g1fpl57q.fsf@sysarch.com>
>>>>> "SC" == Sweth Chandramouli <sweth-usenet@astaroth.nit.gwu.edu> writes:
SC> this is definitely something simple that i'm missing. i have the
SC> following block of code in a script of mine, designed to read key,value
SC> pairs from a file (opened elsewhere) and pump them into a hash:
SC> sub init_hash {
SC> if (keys %id_hash) {undef %id_hash} || die 'undef failed';
SC> while (<INPUT_FILE>) {
SC> @tmp_array = split(/,/);
SC> $id_hash{$tmp_array[0]} = $tmp_array[1];
SC> };
SC> };
SC> since this block is called multiple times, i originally had the first
SC> line as just:
SC> undef %id_hash || die 'undef failed';
beside what larry wrote about undef always returning undef,
this line is a syntax error:
SC> if (keys %id_hash) {undef %id_hash} || die 'undef failed';
if statements are not expressions and you can't check their nonexistant
result.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 25 Jul 1998 20:13:49 GMT
From: hymie@lactose.smart.net (hymie!)
Subject: Re: Same code, diff machines, diff results
Message-Id: <6pde9t$8tb$1@news.smart.net>
In our last episode, the evil Dr. Lacto had captured our hero,
chhahar@charlie.cns.iit.edu (Harshal S. Chhaya), who said:
> $date = `/bin/date`;
> $ENV{"TZ"} = "Asia/Calcutta";
> $date1 = `/bin/date`;
> print $date, $date1;
Try doing these three commands on the same two machines outside of perl
and see if you get the same results. In this way, you might determine
that perl is not the problem.
..hymie! http://www.smart.net/~hymowitz hymie@lactose.smart.net
I knew a man, his brain so small, he couldn't think of nothing at all. He's not
the same as you and me. He doesn't dig poetry. He's so unhip that when you say
Dylan, he thinks you're talking about Dylan Thomas, whoever he was. The man
ain't got no culture. --Paul Simon
------------------------------
Date: Sat, 25 Jul 1998 19:52:20 -0500
From: "Quinn,M" <melinda@acm.org>
Subject: Re: subs in separate files?
Message-Id: <35BA7DC4.10A6D1F8@acm.org>
Thanks for the replies. I think maybe I need to
modify my question. How do I get "use" and/or
"require" to search the CURRENT DIRECTORY for the
subroutine. I get messages about not being able
to find the subroutine in one of the libraries
provided with perl. It would be a tremendous help
if someone would actually provide a simple example.
Thanks,
Melinda Quinn melinda@acm.org
Quinn,M wrote:
> Novice question:
> How do I put subrouotines (functions) into
> separate files? I have learned to call functions
> (subs) that are in the SAME file, but I cannot
> figure out how to put subs in separate files.
> I've tried "use", "require", etc. No luck.
> The following works in the SAME file - how can I
> make the subroutine work if it is in a SEPARATE FILE
> IN THE SAME DIRECTORY?
> ==== file: subtry ========
> #!/usr/bin/perl -w
> print ("=== subtry BEFORE calling subtry2 ==\n);
> $MVAR = "SOMETHING";
> subtry2($MVAR);
> print ("=== subtry AFTER calling subtry2 ==\n");
>======== works if in SAME file - not if in DIFFERENT file===
> sub subtry2 {
> my $Stuff = $_[0];
> print ("This stuff is $Stuff \n");}
> ================EOF=============================
> If anyone can refer me to pages in "Learning Perl" or
> "Programming Perl" or on-line Perl documentation,
> I'd be grateful.
> Please also reply by e-mail. Thank you.
> Melinda Quinn melinda@acm.org
>
> }
------------------------------
Date: 25 Jul 1998 19:59:02 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Tcl is better than Perl
Message-Id: <6pdde6$5b2$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
jkirving@mosquitonet.com (Ken Irving) writes:
:On 25 Jul 1998 13:57:09 GMT, Tom Christiansen <tchrist@mox.perl.com>
:Presumably I'm missing something, but I get an error:
:
: Odd number of elements in hash list at C:\PERL\lib/IO/Socket.pm line
:130.
:
:when running this script under 5.004_02 on winnt, and 5.004_01 on
:linux.
% perl -v
This is perl, version 5.004_04 built for i686-linux
% perl -MIO::Socket -le 'print IO::Socket->VERSION'
1.1603
--tom
--
"Your reality is lies and balderdash, and I'm glad to say that I have no
grasp of it." --Baron Munchausen
------------------------------
Date: Sat, 25 Jul 1998 23:50:50 GMT
From: d@d.cmm (-)
Subject: Timeout, Socket, Windows
Message-Id: <ubuu1.1238$DI5.9026379@news.rdc1.az.home.com>
Greetings all,
I'm doing it again, trying to use a UNIX language on Windows.
I have written a variaty of small servers and clients to do many things, but I
can't controll the timeouts on read() and write(). I would gladly use a fork()
and an alarm, but Windoz doesn't support the fork(), surprise.
I understand that the socket has this option available, and that many folks
have handled this succefully with things like vec(), but I can't seem to find
clear documentation on what vec() does or how to actually set or get socket
options. ie; getsockopt() or setsockopt().
I don't neccasarily need an answer on what to do, although it would be nice.
What I do need is a source of learning.
Thanks in advance,
Rodney Broom
------------------------------
Date: Sat, 25 Jul 1998 17:55:09 GMT
From: samuri@clara.fish.net (Jonathan Dude)
Subject: win32 embedding perl in c
Message-Id: <35ba1ab3.12659112@news.clara.net>
I got the latest perl for win32 from activestate and am trying to
embed perl in a C program. I have read various FAQs and doc pages
including a win32 faq from activestate which tells me I need all the
include files for perl and various libs including perl100.lib. Also I
need the perlmain.cpp source for reference in creating the relevant
class etc. My version of perl doesn't seem to have these bits with it.
(In fact my version seems very sparse compared to my linux version.)
My linux perl does have the includes but nothing else. Apparently
embedding perl in C on win32 is very different to unix flavours, Is
this correct?
Help!
Bikes, Beer and B.......Young Ladies. What else is there?
Remove the fish to email me.
------------------------------
Date: 25 Jul 1998 11:21:07 GMT
From: werner@ip.cubenet.de (Dr. Werner Eberl)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6pcf33$l19@ip.ip.cubenet.de>
EOZSARUH@nsf.gov (Erdem Ozsaruhan) wrote:
>
>When I run the following perl program:
>
>#! /usr/local/bin/perl
>
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
> chop($date = sprintf ("%02d-%02d-%02d\n",$mon+1,$mday,$year));
>
> print "Date: $date\n";
> exit;
>
>
>I get:
>
>Date: 02-29-100
>
This is because perl _is_ Y2K-safe.
You just have to use $year+1900 and always get the right year.
Maybe you want to use substr($year+1900,2,2)
Regards,
Werner
------------------------------
Date: Sat, 25 Jul 1998 16:34:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <MPG.10240b58ac083f6398978d@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <6pcf33$l19@ip.ip.cubenet.de> on 25 Jul 1998 11:21:07 GMT, Dr.
Werner Eberl <werner@ip.cubenet.de> says...
> EOZSARUH@nsf.gov (Erdem Ozsaruhan) wrote:
> >
> >When I run the following perl program:
> >
> >#! /usr/local/bin/perl
> >
> > ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
> > chop($date = sprintf ("%02d-%02d-%02d\n",$mon+1,$mday,$year));
> >
> > print "Date: $date\n";
> > exit;
> >
> >
> >I get:
> >
> >Date: 02-29-100
> >
> This is because perl _is_ Y2K-safe.
> You just have to use $year+1900 and always get the right year.
> Maybe you want to use substr($year+1900,2,2)
That's a bit roundabout. $year % 100 will do fine. (sprintf will supply
the leading 0 for years 2000 through 2009.)
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3255
**************************************