[11617] in Perl-Users-Digest
Perl-Users Digest, Issue: 5217 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 24 15:07:37 1999
Date: Wed, 24 Mar 99 12:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 24 Mar 1999 Volume: 8 Number: 5217
Today's topics:
accessing class specific variables in inherited classes <liechti@dial.eunet.ch>
Re: ANNOUNCE: Boston.pm Social Meeting, Thurs Mar 25 (brian d foy)
Re: choping off whitespace <Philip.Newton@datenrevision.de>
Re: choping off whitespace (Larry Rosler)
Re: Date/Time calculation: % through current month? <cassell@mail.cor.epa.gov>
Re: Encryption Problem <Philip.Newton@datenrevision.de>
Re: Extreme Newbie here needs help <jbc@shell2.la.best.com>
Re: flock() && win95 #HELP! <toddl@SiTera.com>
Re: flock() on Alpha/VMS (M.J.T. Guy)
Re: Getting the return value <sdatta@lucent.com>
Re: Getting the return value <dwatanab@uci.edu>
Re: Help Needed Please!!! <support@onlineauctions.co.uk>
HELP: Confused about Hash Table. (KEhlar)
Re: initialization (Tad McClellan)
Re: Keeping place in a file <gala@sonic.net>
Re: Keeping place in a file (Larry Rosler)
Re: Make Perl handle white space in a path <Philip.Newton@datenrevision.de>
Module Install Problem, Float in #IF ???????? (Jim Teunas)
Re: MSQL problem with select <heinlein@cse.ogi.edu>
Re: Need username in Perl script (Bill Moseley)
Re: Newbie to Perl <kenmar@ihug.co.nz>
Re: Newbie-prints source code <jbc@shell2.la.best.com>
Re: Odd/Even (brian d foy)
Re: protecting perl scripts <cassell@mail.cor.epa.gov>
Re: randomizing an array order <jglascoe@giss.nasa.gov>
replicator <asva@usa.net>
Re: return codes in Win32 Perl <camerond@mail.uca.edu>
Simple Program <ophir@saifun.com>
Re: Simple Program <uri@home.sysarch.com>
Using Win32::Perms keydet89@yahoo.com
utime issue <danieloc@xilinx.com>
Values of 'true' and 'false'? <Philip.Newton@datenrevision.de>
Re: Values of 'true' and 'false'? <tchrist@mox.perl.com>
Re: what is wrong w/ this sorting code? <Philip.Newton@datenrevision.de>
What is wrong with this code? (Lou M)
Re: What to use instead of rename <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 24 Mar 1999 19:48:18 +0100
From: Herbie Liechti <liechti@dial.eunet.ch>
Subject: accessing class specific variables in inherited classes
Message-Id: <36F93372.3A246BB6@thinx.ch>
I wondering if there is a simpler way to access class
specific variables in a real polymorphic manner.
------------------MAIN ------------------
#!/usr/bin/perl -w
use lib(".");
use strict;
use A;
use B;
my $a= A->new();
my $b= B->new();
print $a->printhash();
print $b->printhash();
------------------CLASS A---------------------
package A;
use strict;
%A::hash = (
valA => 1,
valB => 2,
);
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
}
sub printhash {
my $self = shift;
my $pkg = ref($self);
return join("\n", (keys %{"${pkg}::hash"}));
##################here is the problem
}
1;
---------------INHERITED CLASS B FROM A-
package B;
@B::ISA = ("A");
use strict;
%B::hash = (
valx => 1,
valy => 2,
);
1;
The real tricky thing is to access the %B::hash variables
when calling the printhash method in context of a B object.
I think this is called polymorphic ;-).
(keys %{"${pkg}::hash"}) does not look very readable. Any
hints how to do this in an easier way without accessing the
symbol table directly? - Or - Am I wrong with this
design?
Greetings
Herbie
------------------------------
Date: Wed, 24 Mar 1999 14:40:06 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: ANNOUNCE: Boston.pm Social Meeting, Thurs Mar 25
Message-Id: <comdog-ya02408000R2403991440060001@news.panix.com>
In article <36F863DF.90C9BBE5@cts.wustl.edu>, Elaine Ashton <elaine@cts.wustl.edu> posted:
> Ronald J Kimball wrote:
>
> > In addition to the usual socializing, there will be a brainstorming
> > session on ideas for the Boston Perl Mongers party at next month's
> > O'Reilly Perl Tutorials.
> This should be quite fun to ponder and plot but I am still left
> wondering where ORAs support for the Monger YAPC conference is. Where is
> the quid pro quo? Addison-Wesley is supporting YAPC.
not everything you see if everything there is. O'Reilly is supporting
Perl Mongers at the tutorials because Perl Mongers would do it without
O'Reilly's support just like we did at the Perl Conference. that, along
with my politicking behind the scenes is making this happen. there is
actually a lot of work that goes into this.
someone for YAPC simply needs to ask O'Reilly to do something. They
have already committed to doing *something*, but you don't get something
without asking for it. O'Reilly is ready to help. Not everyone wants
O'Reilly's help, though, and that is not their fault.
my guess is that Kevin is swamped with arranging all of the details,
and that he would greatly appreciate help. send him some mail at
<lenzo@cs.cmu.edu> to volunteer. :)
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Wed, 24 Mar 1999 13:55:56 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: choping off whitespace
Message-Id: <36F8E0DC.3C84D91E@datenrevision.de>
Larry Rosler wrote:
>
> my $s = 'x' x 50;
Just for fun, I tried your script out with some whitespace (spaces and
tabs, FWIW) in front of and after the row of x's. Plus still was about
five times as fast as Star/Bad/Or (which were all roughly the same).
Cheers,
Philip
------------------------------
Date: Wed, 24 Mar 1999 11:40:30 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: choping off whitespace
Message-Id: <MPG.1162df8da9baf3c89897b5@nntp.hpl.hp.com>
In article <36F8E0DC.3C84D91E@datenrevision.de> on Wed, 24 Mar 1999
13:55:56 +0100, Philip Newton <Philip.Newton@datenrevision.de> says...
> Larry Rosler wrote:
> >
> > my $s = 'x' x 50;
>
> Just for fun, I tried your script out with some whitespace (spaces and
> tabs, FWIW) in front of and after the row of x's. Plus still was about
> five times as fast as Star/Bad/Or (which were all roughly the same).
That is no surprise. If you copied the benchmark exactly, whatever
whitespace is in the string is deleted on the first iteration. To
actually make a change in the measurement, you must copy the base string
(with whitespace) into the operand being modified, on every iteration.
#!/usr/local/bin/perl -w
use Benchmark;
my $s = ' ' x 10 . 'x' x 50 . ' ' x 10;
timethese(1 << (shift || 0), {
Bad => sub { (my $x = $s) =~ s/^\s*(.*?)\s*$/$1/ },
Or => sub { (my $x = $s) =~ s/^\s+|\s+$//g },
Plus => sub { (my $x = $s) =~ s/^\s+//; $x =~ s/\s+$//; },
Star => sub { (my $x = $s) =~ s/^\s*//; $x =~ s/\s*$//; },
});
__END__
Benchmark: timing 65536 iterations of Bad, Or, Plus, Star...
Bad: 8 wallclock secs ( 7.91 usr + 0.00 sys = 7.91 CPU)
Or: 7 wallclock secs ( 6.38 usr + 0.00 sys = 6.38 CPU)
Plus: 2 wallclock secs ( 1.38 usr + 0.00 sys = 1.38 CPU)
Star: 5 wallclock secs ( 4.47 usr + 0.00 sys = 4.47 CPU)
Now I am quite surprised by this result. I expected that with both
leading and trailing whitespace on the string being trimmed, that the
regex engine would work the same for Plus and for Star. But this
doesn't seem to be the case. Ilya or anyone, help???
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 24 Mar 1999 10:18:45 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Date/Time calculation: % through current month?
Message-Id: <36F92C85.1287825A@mail.cor.epa.gov>
Tony Bowden wrote:
> I've been trying to produce some pretty basic stats, whereby knowing how
> many times an event has happened so far this month, I want to estimate
> how many times it's likely to happen in the month.
> [snip of rest]
This was answered yesterday, with a very nice piece of code. I'm going to
assume this re-post a day later is a glitch with your news software, and
that you have already checked that thread for the answer. If not, here's
a hint: localtime in scalar context returns all the info you need.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 24 Mar 1999 12:26:41 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: Encryption Problem
Message-Id: <36F8CBF1.AD46FE8C@datenrevision.de>
Tobias C. Wilhelm wrote:
>
> Because the Department of Commerce prohibits export of 128-bit
> encryption software, and getting a licence takes between 1 and 3
> months... :(
So use a version of PGP that was produced outside the USA.
http://www.pgpi.com/ .
Cheers,
Philip
------------------------------
Date: 24 Mar 1999 18:55:45 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Extreme Newbie here needs help
Message-Id: <36f93531$0$217@nntp1.ba.best.com>
Besides endorsing all the other great advice you've received here, I
wanted to give a few more pointers to information specific to your
situation.
Spencer <mgb23@vci.net> wrote:
> First question, do I have to have a program or something to write with
> the perl language.
As said by others, nope, any text editor will do. I've recently fallen
deeply in love with a free Notepad replacement for Windows called
"EditPad". It doesn't do fancy syntax highlighting, but everything else
I want it to do it does really well (including being simple and
uncluttered enough to keep out of my way).
http://www.jgsoft.com/editpad.shtml
> Second question is, I am using windows 95, is perl only for unix and
> servers and stuff.
Again, as mentioned by others, you can go to:
http://www.activestate.com/
and get a recent build of ActivePerl that will run under Win95.
Two Web-based tutorials that may help you are my own "Beginner's Guide
to CGI Scripting with Perl" at:
http://www.lies.com/begperl/
and "Robert's Perl Tutorial" at:
http://www.netcat.co.uk/rob/perl/win32perltut.html
Mine is relatively short, and focuses on getting your first CGI scripts
running on a Unix Web server. Robert's is relatively long, and covers
just about everything a beginner would want to know about Perl,
including how to run Perl under Windows.
Both tutorials are written for someone who's not afraid of the
computer, but who doesn't necessarily have any prior programming
experience. After going through them, the Llama will probably make more
sense.
My own advice on Perl books would be to get the Llama book (Learning
Perl), the Camel book (Programming Perl), and the Ram book (Perl
Cookbook). All are from O'Reilly; all are excellent, and useful for
beginners, though in slightly different ways.
I recently figured out that I have something of an addiction to
O'Reilly books. At latest count I'm up to about 30 of them, with no
signs of slowing down, but if (God forbid) I was going to be stuck on a
desert island with only three of them, those three might be the ones.
Actually, I'd probably drop the Llama so I could bring Unix Power
Tools, but only because I've managed to crawl up out of the primordial
nonprogrammer ooze just far enough to be able to dispense with it (as
long as I've got the Camel and Ram handy).
It's a sign of the depth of my addiction that these probably are the
three books I'd bring even if this hypothetical island didn't feature a
computer or net access. I just like reading them. As *literature*.
Scary. Don't tell my English-major coworkers.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Wed, 24 Mar 1999 12:45:28 -0700
From: Todd LaWall <toddl@SiTera.com>
Subject: Re: flock() && win95 #HELP!
Message-Id: <36F940D8.462E3F2C@SiTera.com>
John Cosby wrote:
>
> I'm new to perl and may be mussing it up, but am I correct in assuming
> that flock() is not available to win95 coders? I tried it in my code and
> tried the ex. in PerlFAQ5 and the error was fatal. I'm thinking about
> renaming the file between * and *.lock to show a locked state. Has
> anyone tried this, and if so, how well did it work for you?
>
> I've got about a month's exp. w/perl and am using build 509. ANY
> comments would be appreciated.
The perlport doc states that flock() still doesn't work on Win95.
I can testify that it does work on NT. I don't think they're
going to put any effort into getting it to work on 95, correct me
if I'm wrong guys.
There is support for locking files in the Win32 api for 95, but I
think if you try to use that you're looking for some serious
daimbramige. You would be better off doing something like the
lock file method you mentioned. Of course, you could do much better
by moving to Linux! ;)
Todd
#---------------------
use Disclaimer::Todds qw(Dont blame my company any opinion is all mine);
------------------------------
Date: 24 Mar 1999 18:04:09 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: flock() on Alpha/VMS
Message-Id: <7db9ep$k1i$1@pegasus.csx.cam.ac.uk>
Dan Sugalski <sugalskd@netserve.ous.edu> wrote:
>In comp.lang.perl.misc M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
>
>: Wouldn't it be politer, and assist portability, if flock() was implemented
>: as a no-op on this platform, since that is what it effectively is with
>: mandatory locking?
>
>It'd be politer, but it'd also be wrong.
For some value of wrong. My point really is that currently, perl's
flock() is only approximately portable. And the current state is
"wrong". I'm suggesting a different "wrong", which I hope would be
a better approximation.
> If you open a file
>read-regardless (which doesn't place any locks on the file), flock(LOCKEX)
>(or whatever the constant is) would return true even though it failed. And
>flock(UNLOCK) on a file opened for write would return true even though it
>didn't do that. The only really good way to handle it would be to have
>flock check the current open mode and return true or false if it matched
>what's being asked for. (Maybe for 5.006....)
That would be a much better approximation. But it also needs a lot
more tuits.
Mike Guy
------------------------------
Date: Wed, 24 Mar 1999 12:25:42 -0600
From: Sujay Datta <sdatta@lucent.com>
Subject: Re: Getting the return value
Message-Id: <36F92E26.BC65FB2C@lucent.com>
This works fine if you are providing a corrrect
command. =
Let us suppose that there is NO file called "junk"
and you give =
$output =3D `ls junk`;
$return =3D $?;
print $output,"\t",$return;
I want to control the error case too.
Sujay
d=E1na watanabe wrote:
> =
> chomp (my $output =3D `date`);
> my $return =3D $?;
> print "output=3D$output\n";
> print "return=3D$return\n";
> =
> prints
> =
> output=3DWed Mar 24 09:19:48 PST 1999
> return=3D0
> =
> "$? The status returned by the last `...` command, pipe clo=
se or system
> operator "
> =
> (Perl 5 Desktop Reference)
> =
> Sujay Datta wrote:
> >
> > I want to get the output of a shell command
> > as well as the return value. How do I get both.
> > Help is appreciated.
> > Sujay
------------------------------
Date: Wed, 24 Mar 1999 11:40:01 -0800
From: =?iso-8859-1?Q?d=E1na?= watanabe <dwatanab@uci.edu>
Subject: Re: Getting the return value
Message-Id: <36F93ECE.5CA11C43@uci.edu>
I think i might have misunderstood. You want to catch the error message
into $output as well right?
Then
$output = `ls junk 2>&1`; #sends STDERR to STDOUT
$return = $?;
print $output,"\t",$return;
Sujay Datta wrote:
>
> This works fine if you are providing a corrrect
> command.
> Let us suppose that there is NO file called "junk"
> and you give
> $output = `ls junk`;
> $return = $?;
> print $output,"\t",$return;
> I want to control the error case too.
------------------------------
Date: Wed, 24 Mar 1999 18:26:16 +0000
From: On Line Auctions UK <support@onlineauctions.co.uk>
Subject: Re: Help Needed Please!!!
Message-Id: <36F92E47.25C070B3@onlineauctions.co.uk>
Thanks for the reply but unfortunately I have tried that and nothing is
coming through for some strange reason.
Cheers
Gary Mayor
leonandrews@my-dejanews.com wrote:
> mate,
>
> have you tried printing out your variables such as $buffer, ie
>
> print "Content-type: text/html\n\n";
> print "buffer is $buffer\n";
>
> etc
>
> ...to see whether the data is getting across the CGI?
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 24 Mar 1999 12:22:43 -0500
From: KEhlarQUASH@SPAMMERtheglobe.com (KEhlar)
Subject: HELP: Confused about Hash Table.
Message-Id: <MPG.1162e96bbc6ebca3989792@nntpd.bb.dec.com>
Hi all,
I can create a hash table with code like this one:
$index = 0;
foreach $element (@list1) {
$hash1{$index} = $element;
$index++;
}
OR like this one:
%hash1 = ('1', 'element1', '2', 'element2'....so on);
In the latter, I can actually split the hash using the "," as the delimiter.
How about the first method? Is there a delimiter that I can use?
I'm writing a script that uses smtp to send email. I used the first method to
have the recipients stored in a hashtable with (name, emailaddress) as the
keys/values. For some reason, the email that's sent omits the message body and
the time that it was sent. However if I used the second method to create the
hash table, then it works!
Here is the code to send email to the recipients:
foreach (keys %hash1) {
if (send_mail ($hash1{$_}, "novey@mail.com", $message) == 0) {
print "FAILED!!";
}
}
.
.
sub send_mail {
use Socket;
$smtp_server = 'mailserver.com';
$smtp_port = 25;
my( $to, $from, $message ) = @_;
$proto = getprotobyname( 'tcp' ) or return 0;
socket( SOCK, PF_INET, SOCK_STREAM, $proto ) or return 0;
$port = getservbyname('smtp', 'tcp') or return 0;
$sin = sockaddr_in($port,inet_aton($smtp_server)) or return 0;
connect(SOCK,$sin) or return 0;
receive( \*SOCK ) or return 0;
send( \*SOCK, "MAIL FROM: <$from>") or return 0;
receive( \*SOCK ) or return 0;
send( \*SOCK, "RCPT TO: <$to>" ) or return 0;
receive( \*SOCK ) or return 0;
send( \*SOCK, "DATA" ) or return 0;
receive( \*SOCK ) or return 0;
send( \*SOCK, "$message\n." ) or return 0;
receive( \*SOCK ) or return 0;
send( \*SOCK, "QUIT" ) or return 0;
receive( \*SOCK ) or return 0;
close( SOCK ) or return 0;
return 1;
}
I can't use the second method because the number of recipients is not constant,
neither are the recipients themselves.
Thanks for any input.
Novey Chou
--
remove QUASH SPAMMER from email address.
------------------------------
Date: Wed, 24 Mar 1999 08:51:06 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: initialization
Message-Id: <akqad7.943.ln@magna.metronet.com>
Zhiliang Hu (zlhu@iastate.edu) wrote:
: Thanks to all who took time to solve my confusion!
: Here is another confusion, probably a better one :)
: I have a few working CGI scripts. They are working, but I always
: observe complains in the error log:
: "Use of uninitialized value at" lines such as:
You should never get that warning.
If you do, you should chase it down, find out why it is
warning you, and fix it.
Because it means that you are using a variable
*that has never been given a value*. Doesn't make
sense to use a variable unless it has first been
given some value.
Ignoring warnings is dangerous, and not recommended unless
you are truly expert and are sure it is OK to ignore it.
The first thing that you need to do is to determine _which_
variable the warning is about.
You can do this by examining variable contents in the debugger
or adding print statements.
: 1. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
print "\$buffer '$buffer'\n"; # can't be this one though, because
# its value is not being used, it
# is being _set_
print "\$ENV{'CONTENT_LENGTH'} '$ENV{'CONTENT_LENGTH'}'\n";
are you certain that CONTENT_LENGTH is defined in your environment?
: 2. $ENV{REMOTE_HOST};
: 3. ($name,$value)=split(/:/,$pair);
Somehow or another, you got to this point in your code without
ever putting anything into $pair.
That may have a negative influence on the results of splitting
the unknown value...
: 4. ($term1, $term2, $term3, $term4, $term5) = split(/\s+/,
: $FORM{terms});
: and so on. I wonder is it a standard requirement in perl to
: "initialize" them such as:
: $buffer = $buffer;
: $ENV{'CONTENT_LENGTH'} = $ENV{'CONTENT_LENGTH'};
: $ENV{REMOTE_HOST} =$ENV{REMOTE_HOST};
That won't do it.
: Well, then how should I initialize "$name", $value", "term1 .... term5"
: in the above example?
You don't have to, because you are not _using_ their values,
you are _assigning_ their values.
A variable does not need to have a value in order to be assigned
a new value.
Using a variable that has never been given a value is highly
suspect, hence the warning...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 24 Mar 1999 11:11:09 -0800
From: "Gala Grant" <gala@sonic.net>
Subject: Re: Keeping place in a file
Message-Id: <7dbd8k$hh6$1@ultra.sonic.net>
Thanks for your help, one more question though, I got out my camel book and
did this, but it keeps returning me to the same place so I have an endless
loop. Is there a way to start right after? I included the code I wrote.
Thank again.
Gala Grant
if ($link =~ /^#(.*)/)
{
$anchor = $1;
$place = tell;
while (defined ($line = <FILEIN>) )
{
if ($line =~ /<A\s*name="$anchor">/i)
{
seek FILEIN, $place, 0;
last;
}
print $link;
seek FILEIN, $place, 0;
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote in message
news:1dp57jx.185c450dovhulN@[207.60.170.219]...
> Gala Grant <gala@sonic.net> wrote:
>
> > My question
> > is, is there a way to return to the same place within the file after I
test
> > for the anchor tag? I know about using seek to rewind the file to where
I
> > need to go, but how would I know exactly where I had been. Actually, I
> > would need to be right after the last thing I checked.
>
> seek()'s partner is tell(), which tells you the current file position.
>
> Refer to perlfunc for more info.
>
>
> --
> _ / ' _ / - aka -
> ( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
> / http://www.tiac.net/users/chipmunk/
> "It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 24 Mar 1999 11:50:01 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Keeping place in a file
Message-Id: <MPG.1162e1c39d2a83209897b6@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7dbd8k$hh6$1@ultra.sonic.net> on Wed, 24 Mar 1999 11:11:09 -
0800, Gala Grant <gala@sonic.net> says...
> Thanks for your help, one more question though, I got out my camel book and
> did this, but it keeps returning me to the same place so I have an endless
> loop. Is there a way to start right after? I included the code I wrote.
>
> if ($link =~ /^#(.*)/)
> {
> $anchor = $1;
> $place = tell;
> while (defined ($line = <FILEIN>) )
> {
> if ($line =~ /<A\s*name="$anchor">/i)
> {
> seek FILEIN, $place, 0;
> last;
> }
> print $link;
> seek FILEIN, $place, 0;
If you want to seek to the position 'right after' you have read a line,
then do the 'tell' *after* you have read the line, not before you have
read it.
Depending on your program logic (which is not clear from the snippet),
you may have to do a 'tell' both before and after, and choose whichever
you want depending on the test. Another possibility (depending on your
needs) is to do a 'redo;' in the loop to process the same line again
without reading a new one.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 24 Mar 1999 12:43:25 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: Make Perl handle white space in a path
Message-Id: <36F8CFDD.A656826A@datenrevision.de>
mchoueir@geocan.nrcan.gc.ca wrote:
>
> As you can see, if the variable directory is given a path with no
> spaces, it works just fine but if like this example, it wouldn't !
You may have to use opendir ... readdir ... closedir instead of glob.
perldoc -f opendir, perldoc -f readdir, and perldoc -f closedir.
Basically,
my $file;
# using / instead of \\ looks nicer IMHO; both work fine
opendir DIR, "C:/Program Files/Windows NT/Pinball"
or die "Error opening directory: $!;
foreach $file (readdir DIRHANDLE) {
print "I found a file called $file.\n";
}
closedir DIR or die "Error closing directory: $!";
should work.
while( $file = readdir DIRHANDLE ) { ... }
should work, too.
Cheers,
Philip
------------------------------
Date: Wed, 24 Mar 1999 13:25:49 -0500
From: jat@mitre.org (Jim Teunas)
Subject: Module Install Problem, Float in #IF ????????
Message-Id: <jat-2403991326040001@teunas.mitre.org>
Help!!!!!
I am getting the same error in several modules I am trying to install.
The perl is a new build of 5.005.2 using gcc. All the defaults in the
build were chosen except the install location. There were no errros
reported in the build process
The problem is in found when I try to install Bundle::libnet and several
other modules. As shown below I get an error saying that gcc will not
compile.
I am using gcc version 2.8.1
------------------------------------------------------------------------
einstein[52] cd Data-Dumper-2.10
cd Data-Dumper-2.10
einstein[53] perl Makefile.PL
perl Makefile.PL
Writing Makefile for Data::Dumper
einstein[54] make
make
gcc -B/usr/ccs/bin/ -c -I/usr/local/include -O -DVERSION=\"2.10\"
-DXS_VERSION=\"2.10\" -fPIC
-I/mtc/mtc2/mmictools/lang/perl/lib/5.00502/sun4-solaris/CORE Dumper.c
Dumper.xs:7: Floating point numbers not allowed in #if expressions
gcc: file path prefix `/usr/ccs/bin/' never used
*** Error code 1
make: Fatal error: Command failed for target `Dumper.o'
-----------------------------------------------------------------------------
einstein[55] perl -V
perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
Platform:
osname=solaris, osvers=2.5.1, archname=sun4-solaris
uname='sunos einstein 5.5.1 generic sun4u sparc sunw,ultra-2 '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='gcc -B/usr/ccs/bin/', optimize='-O', gccversion=2.8.1
cppflags='-I/usr/local/include'
ccflags ='-I/usr/local/include'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
alignbytes=8, usemymalloc=y, prototype=define
Linker and Libraries:
ld='gcc -B/usr/ccs/bin/', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under solaris
Compiled at Mar 24 1999 08:54:09
@INC:
/mtc/mtc2/mmictools/lang/perl/lib/5.00502/sun4-solaris
/mtc/mtc2/mmictools/lang/perl/lib/5.00502
/mtc/mtc2/mmictools/lang/perl/lib/site_perl/5.005/sun4-solaris
/mtc/mtc2/mmictools/lang/perl/lib/site_perl/5.005
.
einstein[56]
------------------------------
Date: Wed, 24 Mar 1999 10:14:25 -0800
From: Paul Heinlein <heinlein@cse.ogi.edu>
To: Clifford Meece <cliff@scs.uiuc.edu>
Subject: Re: MSQL problem with select
Message-Id: <Pine.SOL.3.96.990324101211.13169A-100000@church.cse.ogi.edu>
On Wed, 24 Mar 1999, Clifford Meece wrote:
> I have a SELECT statement that I can't seem to get working in msql.
{snip}
> Now when I try to call an equivalent routine from perl:
>
> $acct="1111022";
> $proj="00";
> $sth=$dbh->prepare(q{SELECT * FROM accounts WHERE (acctNum = '$acct'
> AND subAcct = $proj)});
> $sth->execute;
The q{} operator doesn't interpolate variables. Try qq{}.
--
Paul Heinlein
heinlein@cse.ogi.edu
------------------------------
Date: Wed, 24 Mar 1999 10:02:45 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Need username in Perl script
Message-Id: <MPG.1162c89d7e2ec5f29896e9@206.184.139.132>
In article <7d8m89$m9r$3@client2.news.psi.net>, abigail@fnx.com says...
> No. All you get is what the browser sends to the server, and that the
> server puts in the environment.
Yes.
> Browsers stopped sending user names
> about 5 years ago, after many reports of abuse.
> Abigail
That's misleading.
The original poster said:
"I have a PERL script inside a private directory protected with a
.htaccess file. I would like the script to use the login name of the user
accessing that directory."
I do this all the time and it works just fine.
--
Bill Moseley mailto:moseley@best.com
------------------------------
Date: Fri, 26 Mar 1999 03:40:35 +0800
From: Ken Mar <kenmar@ihug.co.nz>
Subject: Re: Newbie to Perl
Message-Id: <36FA9133.71663860@ihug.co.nz>
Larry Rosler wrote:
> RIGHT! They have to do with file locking. flock() is not implemented
> on Windows 95.
I suspect you'r closer to the mark, here. It's seemed reasonable to
want to lock the file to prevent simultaneous access. Is there an
equivalent in Win95 to do that? Maybe can point me to a FAQ of Perl on
Win32. Many thanks in advance.
-Ken
------------------------------
Date: 24 Mar 1999 19:27:08 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Newbie-prints source code
Message-Id: <36f93c8c$0$217@nntp1.ba.best.com>
Chris L Fullilove <flight69@cs.uh.edu> wrote:
> Hi, I am having trouble running a simple CGI script.
I predict that somewhere between 3 and 6 people will feel compelled to
tell you you'd have better luck asking about this sort of thing in
comp.infosystems.www.authoring.cgi. And they'll be right; you will.
> the only output I get is the actual source code in my browser.
> when I run it at the unix prompt, I get the HTML code.
This is something specific to the Web server you're running under.
Possible explanations are that you haven't named the script with the
proper filename extension (like .cgi), you haven't placed the script in
the proper directory (like /cgi or /cgi-bin), or the server has been
configured not to allow users of your particular sort to run CGI
scripts. The definitive answer on this can probably be obtained by
consulting the documentation that describes your Web hosting situation,
or the human being(s) responsible for administering it.
http://computerdog.com/CGI_MetaFAQ.html
is probably a good resource for finding answers to these sorts of
questions quicker than you can be posting to Usenet (or it would be a
good resource if it was reachable, which it appears not to be at the
moment).
Good luck!
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Wed, 24 Mar 1999 14:23:38 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Odd/Even
Message-Id: <comdog-ya02408000R2403991423380001@news.panix.com>
In article <7db5bc$cl0$1@nnrp1.dejanews.com>, Don Roby <droby@copyright.com> posted:
> In article <comdog-ya02408000R2303991340210001@news.panix.com>,
> comdog@computerdog.com (brian d foy) wrote:
> > i don't know if i like that characterization. i don't think that
> > knowing the number's native representation represents a more
> > advanced thinking. the % operator should work despite the
> > underlying representation, and as such is a more abstract way of
> > thinking, which puts it at the "university" level, perhaps ;)
> >
>
> No no no! Fields and rings are "university" level.
that was my point (i was thinking groups, not rings), although i
didn't want to say those words. that's why i would rather use the
% rather than thinking about the "thingy"'s representation.
i'm pretty sure that Perl couldn't be a ring though. there are too
many ways (more than one) to have identity (or either sort) ;)
this is just a hold-over from my physics days though.
i prefer to separate the way that i store things and the way that i
interact with them. physics groups are notorious for having local data
formats, so moving from one lab to another meant different storage
formats.
> We learn what numbers basically mean abstractly long before we learn about
> internal computer representations. But then, we abstract in ever-more obtuse
> ways afterward, eventually talking about things like "sheaves of germs of
> holomorphic functions on an analytic variety", and completely losing touch
> with anything resembling the visible world.
sounds like Perl :)
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Wed, 24 Mar 1999 10:47:57 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: protecting perl scripts
Message-Id: <36F9335D.22294A52@mail.cor.epa.gov>
Greg Bacon wrote:
> In article <7dalf4$jmh$1@malgudi.oar.net>,
> "Mr.unix" <Mr.unix@mail.excite.com> writes:
> : Is there anyway to protect my scripts from being copied, such as
> : compiling to an executable form for distribution?
>
> <URL:http://www.cs.uah.edu/~gbacon/perl/encrypt>
>
> : I have worked hard on a socket program here at work that will allow
> : real time information to be passed from our mainframe to a Unix or
> : wintel system. Now that some have caught wind of its future potential,
> : they want to use it, forgetting about who made it all possible in
> : the first place. They want to take credit for the entire endeavor,
> : not just the glossy candy coat they may have applied to the surface.
>
> Your best bet is to assert copyright. See they Copyright FAQ at
> <URL:http://www.aimnet.com/~carroll/copyright/faq-home.html> and
> especially question 3.1 (because it seems to apply to your case).
And also bear in mind that many businesses have documents which
all employees sign, making the business the legal owner of inventions,
software, or something similar. If you have signed such a form, your
code may already be the legal property of your company. I am not
a lawyer, so I can't specualte on how the Perl copyleft interacts with
that.
> Greg
> --
> Politically Correct term: 'G(g)od(dess)(es)'
> -- The Bruns
Hey Greg, nice sig. I would have thought you would have turned that into
a regex though... :-)
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 24 Mar 1999 13:22:36 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: dwatanab@uci.edu
Subject: Re: randomizing an array order
Message-Id: <36F92D6C.D9F093EA@giss.nasa.gov>
[courtesy copy of post sent to cited author]
dana watanabe wrote:
>
> the task is basically to deal a shuffled deck of cards
see perlfaq4: "How do I shuffle an array randomly?"
Jay Glascoe
--
"Soup on all fours?"
"Of course. Whaddaya think, Soup is a biped?" - mst3k
------------------------------
Date: Thu, 25 Mar 1999 00:54:44 -0800
From: Angela <asva@usa.net>
Subject: replicator
Message-Id: <36F9F9D3.3F107002@usa.net>
anyone have replicator script?
------------------------------
Date: Wed, 24 Mar 1999 13:37:59 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: return codes in Win32 Perl
Message-Id: <36F93F17.F7DC81E9@mail.uca.edu>
I haven't gotten the original post from this thread, so I may be
sticking my foot into my mouth, but I always use $! instead of $? for
getting error messages from this type of situation, such as:
unlink $filename or die "Could not delete file: $!";
This at least gives me something in English, and (after I figure it out
in context) it makes sense.
Cameron
camerond@mail.uca.edu
> Phil Mak schrieb:
> >
> > Hi,
> >
> > I've set up a Perl program to delete certain files from a directory
> > running under Windows NT. For some reason, it is not doing it. When I
> > check the $? variable to find out the return code, it gives me the value
> > '65280'. Does anyone know what this means? Or can somebody direct me
> > to a web page that would contain a list of all the return codes and
> > their meanings? Just need someone to point me in the right direction.
> >
> > Thanks,
> > Phil
------------------------------
Date: Wed, 24 Mar 1999 19:02:15 +0200
From: Ophir Marko <ophir@saifun.com>
Subject: Simple Program
Message-Id: <36F91A97.36D5AC21@saifun.com>
#! /local/perl/bin/perl -w
$index=0;
$ophir = 123;
while(<>){
$i=0;
#split;
while ($i <= $#_){
$array[$i+$index]=$_[$i];
$i++;
}
$index=$index+$#_+1;
}
$t=0;
open(FILE2, ">new");
if ($array[$t] eq $ophir){
print FILE2 $array[$t];
$t++;
}
close(FILE2);
------------------------------
Date: 24 Mar 1999 14:09:51 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Simple Program
Message-Id: <x7vhfqaem8.fsf@home.sysarch.com>
>>>>> "TR" == Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de> writes:
>> What's wrong?
TR> Additionally to the mistakes mentioned by others:
TR> i++;
TR> should be
TR> ++$i;
you are correct in adding the $ but the pre or post nature of ++ is
irrelevent here.
TR> $index=$index+$#_+1;
TR> the $#_+1 also looks strange to me.
that is the last index of @_ + 1
his using @_ as the implied output of split is very obscure and highly
deprecated. what is amazing is how many bugs he crammed into this tiny
script. and how many bad shortcuts like split to @_ he used while how
many long ways he used to do the logic.
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: Wed, 24 Mar 1999 19:32:33 GMT
From: keydet89@yahoo.com
Subject: Using Win32::Perms
Message-Id: <7dbekh$lmq$1@nnrp1.dejanews.com>
Has anyone got any experience using Dave Roth's Win32::Perms? I tried
emailing 'roth@roth.net' and got a 'user unknown' error message...
Anyway, I am using ActivePerl build 509, and Dave's Win32::Perms module.
I have no trouble creating a Perms object, and can get the array of hashes
that describe the ACEs. However, I need to know the specific Index,
Account, Mask, Type, etc...the same stuff that's displayed by the Dump
method, but I don't want it sent to STDOUT...
Any help would be greatly appreciated...
Carv
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 24 Mar 1999 18:24:24 +0000
From: Daniel O'Connell <danieloc@xilinx.com>
Subject: utime issue
Message-Id: <36F92DD8.5824875@xilinx.com>
Hello,
I'm trying to *touch* a load of files at once. I've checked some references and
don't understand why the following doesn't work ...
@vFiles = grep /\.v/, readdir X if (opendir X, "$main::XPATH");
my $now = gmtime();
utime $now, $now, @vFiles or die; #always dies here ...
Thanks
Dan
------------------------------
Date: Wed, 24 Mar 1999 12:13:40 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Values of 'true' and 'false'?
Message-Id: <36F8C8E4.FADE31E2@datenrevision.de>
What are the values returned by relational operators? perlop only say
"returns true if ...", but not how true and false are represented. Trial
and error[0] seems to imply 'true' is '1' and false is '' (an empty, but
defined, string). Is this true? Or where in the documentation does it
cover true and false?
Cheers,
Philip
[0] such as perl -wle '$a=(1==1);print "[$a]";$a=(1==0);print
"[$a]";print length $a;print(defined $a?"defined":"undef");'
------------------------------
Date: 24 Mar 1999 11:34:55 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Values of 'true' and 'false'?
Message-Id: <36f9304f@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Philip Newton <Philip.Newton@datenrevision.de> writes:
:What are the values returned by relational operators? perlop only say
:"returns true if ...", but not how true and false are represented. Trial
:and error[0] seems to imply 'true' is '1' and false is '' (an empty, but
:defined, string).
You are correct, but you should rely on the docs. Do not compare
with true and false.
There are several false values, and virtually innumerable true ones.
You should not be testing true or false using == or eq or whatnot,
as this will get you into trouble. If the docs say "true" or "false",
then all you are about is the logical (Boolean) truth, and that's all
you should look at.
Here's how to test for whether something is true:
if ($VALUE) { ... }
$VALUE && do { ... };
$VALUE && f();
f() if $VALUE;
Here's how to test for whether something is false:
unless ($VALUE) { ... }
$VALUE || do { ... };
$VALUE || f();
f() unless $VALUE;
Less readable variations involving "!" also exist.
--tom
--
"I think there's a world market for about 5 computers."
- Thomas J. Watson, Chairman of the Board, IBM (around 1948)
------------------------------
Date: Wed, 24 Mar 1999 12:48:41 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: what is wrong w/ this sorting code?
Message-Id: <36F8D119.2FBDFE7F@datenrevision.de>
nkaiser@my-dejanews.com wrote:
>
> @sortedarray = @unsortedarray[ sort { $idx[$a] < $idx[$b] } 0 .. $#idx ];
the < in the sort should be <=>
Cheers,
Philip
------------------------------
Date: Wed, 24 Mar 1999 19:49:35 GMT
From: lmoran@wtsg.com (Lou M)
Subject: What is wrong with this code?
Message-Id: <36f94084.1500954@news.remarq.com>
I copied it from O'reilly Perl for Win32 (as I am trying to learn it)
but this doesn't let anyone but Andrei finish the program...
ie no matter what answer you give "What is the secret word?" it
answers "Wrong, try again. What is the secret code?"
@words = qw(camel gecko alpaca);
print "What is your name? ";
$name = <STDIN>;
chomp $name;
if ($name eq "Andrei") {
print "Hello, Andrei. How good of you to be here.\n";
} else {
print "Hello, $name!\n"; #regular greeting
print "What is the secret word? ";
$guess = <STDIN>;
chomp $guess;
$i = 0; #try this word first
$correct = "maybe"; #is the guess correct or not?
while ($correct eq "maybe") { #keep checking until we know
if ($word[$i] eq $guess) { #right?
$correct ="yes"; #yes!
} elsif ($i < 2) { #more words to look at
$i = $i + 1; #look at the next word next time
} else { #no more words, must be bad
print "Wrong, try again. What is the secret word? ";
$guess = <STDIN>;
chomp ($guess);
$i = 0; #start checking the first word again
}
} #end of while not correct
} #end of "not Andrei"
Any ideas? email me at lmoran@wtsg.com
...the clouds are filled with dread and forced to flee..
------------------------------
Date: Wed, 24 Mar 1999 11:08:09 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: What to use instead of rename
Message-Id: <36F93819.102C3076@mail.cor.epa.gov>
Eric Williams wrote:
> Using Solaris, perl version 5
Which one? 5.004_04? 5.005_02? 5.001_03? The details matter,
since there are bugs in the earlier versions.
> I am writing a script that sorts files based on part of the filename,
> and moves the file across filesystems. rename doesn't seem to work
> across filesystems.
Of course not. The documentation says specifically [and I quote
from the Camel book]: "It will not work across filesystem
boundaries."
> Any suggestions?
>
> I did try File::copy but that didn't seem to work either, and I would
> have to unlink the file after the copy.
Without posted code, I can't tell why not. And I would personally
*prefer* to do the unlink after the copy, so I could check the
error codes and make sure the copy worked right before I trashed
my valuable files.
If you don't want to use File::Copy [note the capitalization -
it really matters], you can always use system() to mv the file
yourself. Just remember that when you mv across filesystems
on Slowlaris, the system copies the file, unlinks the original,
and squashes any links to other files. So if you need to keep
those links...
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
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 5217
**************************************