[9587] in Perl-Users-Digest
Perl-Users Digest, Issue: 3181 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 17 05:58:02 1998
Date: Thu, 16 Jul 98 19:00:38 -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, 16 Jul 1998 Volume: 8 Number: 3181
Today's topics:
Re: ***Can no one answer this question????*** (James Mcpherson)
Re: Bug in Date::Format? (week number) (Mark Daku)
Re: Bug in Date::Format? (week number) <rpsavage@ozemail.com.au>
Re: Bug in Date::Format? (week number) (Craig Berry)
Re: Bug in Date::Format? (week number) <tchrist@mox.perl.com>
clp.moderated <camerond@mail.uca.edu>
Re: die() not calling exit() with ($?>>8) as perlfunc i eryq@zeegee.com
Re: die() not calling exit() with ($?>>8) as perlfunc i (Charles DeRykus)
Re: efficiency: print<<"xxx" vs. print (Larry Rosler)
Re: HELP : Integrating an Access DB with Perl (Jan Dubois)
Re: Indentation (Brandon S. Allbery KF8NH)
Looking for book about OOP with Perl fnantes@my-dejanews.com
Re: m//g strange behaviour ? <rick.delaney@shaw.wave.ca>
Re: m//g strange behaviour ? (Ilya Zakharevich)
Re: Midnight Oil reference in Perl book? ()
Re: Midnight Oil reference in Perl book? (Larry Rosler)
Re: Newbie question (Martien Verbruggen)
Re: Passing null BSTR pointer with Win32::OLE (Jan Dubois)
Re: Perl Beautifier Home Page (Larry Rosler)
PerlScript ASP's BinaryWrite munging GIF data <ken@bridge.com>
Re: Question - push() unique? (Larry Rosler)
Re: Removing the ^M character (Ronald J Kimball)
Results of the inaugural meeting of Dallas.pm (Brand and Karina Hilton)
Re: Telnet Calls (Miguel Cruz)
Re: Timeout on connect (Charles DeRykus)
Re: What is awk better at than perl? (Larry quote) (Brandon S. Allbery KF8NH)
Re: What is awk better at than perl? (Larry quote) (Charles DeRykus)
Re: What is awk better at than perl? (Larry quote) (Ilya Zakharevich)
when i use htaccess to do authentication <dangran@worldnet.att.net>
Re: Win NT Perl 5.0 Y2K compliance (I R A Aggie)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Jul 1998 23:36:19 GMT
From: mljmcphe@mailbox.uq.edu.au (James Mcpherson)
Subject: Re: ***Can no one answer this question????***
Message-Id: <6om2pj$gh4$1@bunyip.cc.uq.edu.au>
Bryan T Hoch (bth@cs.buffalo.edu) spake thusly:
: On Thu, 9 Jul 1998, Bryan T Hoch wrote:
: > In one of my Perl programs, I have a line that calls a system call to see
: > who is on line.
: >
: > if ((system ("rusers -l $hostA | fgrep $personA")) == 0){
: > }
: >
: > Basically it will check to see if $personA is on $hostA and if so, it will
: > place it in an array (somewhere in the if statement). At least that's what
: > I want it to do.
: > Right now, what it does is just spit out every single user on $hostA to
: > the screen (it doesn't take into account it's only looking for $personA.
: > How do I make it so it doesn't print it to the screen (rather to an array
: > or string in the program) and how do I do it so it only checks for
: > $personA, and not everyone on that host?
I think what you want is something akin to the following:
@userlist = `rusers -l $hostA`; # grab the output and place into an array
foreach $name (@userlist) {
if ($name =~ /$personA/) {
push @results, $name;
}
}
this doesn't get around the searching for every person logged on, but
using rusers, you don't get that option anyway.
I think I'm correct in cautioning against the use of system() - it's a
security hole AFAIK if you don't take proper precautions ;)
does this help?
cheers,
jcm
libBofh
--
I do not speak for the University of Queensland or the University Library
J.McPherson@mailbox.uq.edu..au | this space _not_ for rent.
j.mcpherson@library.uq.edu..au | remove erroneous char to reply properly
------------------------------
Date: 16 Jul 1998 17:58:15 -0400
From: daku@nortel.ca (Mark Daku)
Subject: Re: Bug in Date::Format? (week number)
Message-Id: <esq1zrlqwzs.fsf@nortel.ca>
> > Hi,
> >
> > I am using a script to get the week number:
> >
> > The output for Thursday the 09 of July 1998 is:
> > =======================================
> > Day of year: 190
> > Week number starting with Sunday: 27
> > Week number starting with Monday: 27 <=====
> >
> > =======================================
> >
> > Produces the wrong week number when starting with Monday! Week should be
> > 28.
> >
>
> I am not sure I understand why you think the result is wrong. In one
> case the week 'starts' on Sunday; in the second it 'starts' on Monday.
> I would expect that for those two cases the week number would be same
> for tuesday to saturday. I would expect some confusion if the year had
> started with Sunday, but it started with a thursday. Perhaps if you
> choose a date that was closer to the beginning of the year, for example
> thursday jan 8th 1998, you could then demonstrate why you thought the
> count was wrong.
There is no correct answer to the week number question. It has never been
a formal concept when talking about time. It is concept that came about
from having to deal with weekly receipts and payroll and alike. According
to most business models saturday and sunday simply do not exist. Only
monday throught friday. Thus the division of a week based on sat/sun or
sun/mon will always be in dispute.
The week number subroutines should always be replacable by the user. Why?
Well some corperations base week numbers on there finacial year calender.
Which can simply be some arbitrary date reference.
Also some people feel that the first week of the year be labeled
"0". Because it is a partial week. Other think it should be the 53
week of the previous year. Then some feel that the first day of the
year is auto majically in week 1.
I have done quite a bit of work in the past dealing with dates and date
logic. The best way I have found to deal with it in perl is to define two
subs date->weeknum and weeknum->date in such a way that the user can overload
them. This is done via the autoloader.
eg:
sub DEFAULT_weeknum2date {
}
sub DEFAULT_date2weeknum {
}
Then in the autoloader I have this code.
sub AUTOLOAD {
.....
get name of called func -> $func
.....
if ( $func eq "weeknum2date" ) {
goto &DEFAULT_weeknum2date();
}
if ( $func eq "date2weeknum" ) {
goto &DEFAULT_date2weeknum();
}
}
How does this work you ask? Well if the user has not defined there
own subs for weeknum2date date2weeknum then the defaults are used.
It's that simple. I tell the users to use the subs weeknum2date date2weeknum
without ever telling them about the DEFAULT versions of the same thing.
Also all internal date lib functions should reduce all operations to
use these 2 subs as well. Other wise the whole thing blows up in your face.
Note the evil "goto" usage. It's actually quite magical. Read about it
in perl func.
Mark Daku
------------------------------
Date: 16 Jul 1998 23:33:16 GMT
From: "Ron Savage" <rpsavage@ozemail.com.au>
Subject: Re: Bug in Date::Format? (week number)
Message-Id: <01bdb114$2da39740$43ea1286@steelres-pcm657.resmel.bhp.com.au>
With all due respect, is this all crap?
[snip]
The ISO standard for dates specifies that the first week of the year
contains 4 or more days. Simple.
------------------------------
Date: 16 Jul 1998 23:58:11 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Bug in Date::Format? (week number)
Message-Id: <6om42j$gqa$1@marina.cinenet.net>
Ron Savage (rpsavage@ozemail.com.au) wrote:
: With all due respect, is this all crap?
:
: [snip]
:
: The ISO standard for dates specifies that the first week of the year
: contains 4 or more days. Simple.
Yes, but not every organization follows the ISO standard week-numbering
definition. Any week-number calculator should of course use ISO as a
default, but being able to accomodate other definitions is a very useful
feature to provide.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 17 Jul 1998 00:25:00 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Bug in Date::Format? (week number)
Message-Id: <6om5ks$b8s$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Ron Savage" <rpsavage@ozemail.com.au> writes:
:With all due respect, is this all crap?
:
:[snip]
:
:The ISO standard for dates specifies that the first week of the year
:contains 4 or more days. Simple.
With all due respect, ISO standards (ISO 8601, to be precise) are
remarkably irrelevant to the American business community's actual customs
and practices, particular regarding how they go about counting their
work weeks. Business work-week one is, at least at some/many/most/few
companies, always considered to be the first week with a Monday in it.
Now I expect that you'll probably post a retort saying something
unflattering about them, and I have to admit I won't entirely blame
you for that. But that's just how it is here, and you aren't likely to
change them. You'd be only slightly less likely to tell them that because
ISO number frumpity frump-frump requires the Metric system that you'll
get them to toss out the English system, which they're currently using.
They just aren't going to do that, no matter how sane and reasoned the
arguments you make should happen to be. This isn't a perfect world.
Sorry.
--tom
Please see comp.lang.perl.moderated
--
If I allowed "next $label" then I'd also have to allow "goto $label",
and I don't think you really want that... :-) [now works in perl5!]
--Larry Wall in <1991Mar11.230002.27271@jpl-devvax.jpl.nasa.gov>
------------------------------
Date: Thu, 16 Jul 1998 17:05:14 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: clp.moderated
Message-Id: <35AE791A.B4F4332@mail.uca.edu>
When (c.l.p.moderated -e) {
Please announce here, for (voice_of_experience=1) {
I don't trust my newsserver's feed to get the group
to me without a hassle;
}
}
Programmed under the general_kludge artistic license which comes with
every box of perl.
Cameron
camerond@mail.uca.edu
------------------------------
Date: Thu, 16 Jul 1998 23:07:43 GMT
From: eryq@zeegee.com
Subject: Re: die() not calling exit() with ($?>>8) as perlfunc implies?
Message-Id: <6om13v$11f$1@nnrp1.dejanews.com>
In article <35AE2195.2A64@min.net>,
jdporter@min.net wrote:
> eryq@zeegee.com wrote:
> >
> > #!/usr/bin/perl -w
> > # This should pass the exit status to the shell, but doesn't!";
> > open LS, "ls /no/such/dir |" or die "open: $!\n";
> > my @ls = <LS>;
> > close LS;
> > ($? >> 8) and die "ls failed: [$!][",($?>>8),"]\n";
> >
> > It prints 0, even though Perl reports $?>>8 faithfully as 2, and $! is
> > not set! If I explicitly 'exit 2' from Perl I get what you'd
> > expect... $? is set to 2 in the shell.
>
> The $! is only telling you the result of the open(), which, if
> you get past the "open or die", you know $! is OK.
>
> To test the result of the ls, only use $?. $! is not meaningful.
> If you want to propagate the $? to your program's caller, use
> an explicit die:
>
> $? >>= 8;
> if ( $? ) {
> print STDERR "ls failed.\n";
> # that's about as much as you can say, since we
> # don't have strerror.
> exit $?;
> }
But what if this is inside a subroutine, and I want to raise
an exception so that it can be caught... and if it's uncaught,
the program dies with the same exit status as the "ls".
Bottom line: I don't want it to exit()... I want it to die()! [*]
The perlfunc entry on die() really seems to imply that I should
have this, if $! is zero and $? is nonzero. My question is,
is perlfunc wrong?
Eryq.
[*] I concede that if I were in a burning building, I *personally*
would prefer to exit() rather than die().
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 17 Jul 1998 00:54:01 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: die() not calling exit() with ($?>>8) as perlfunc implies?
Message-Id: <Ew7ru1.GG2@news.boeing.com>
In article <35AE2195.2A64@min.net>, John Porter <jdporter@min.net> wrote:
> eryq@zeegee.com wrote:
>>
>> #!/usr/bin/perl -w
>> # This should pass the exit status to the shell, but doesn't!";
>> open LS, "ls /no/such/dir |" or die "open: $!\n";
>> my @ls = <LS>;
>> close LS;
>> ($? >> 8) and die "ls failed: [$!][",($?>>8),"]\n";
>>
>> It prints 0, even though Perl reports $?>>8 faithfully as 2, and $! is
>> not set! If I explicitly 'exit 2' from Perl I get what you'd
>> expect... $? is set to 2 in the shell.
>
> The $! is only telling you the result of the open(), which, if
> you get past the "open or die", you know $! is OK.
>
> To test the result of the ls, only use $?. $! is not meaningful.
> If you want to propagate the $? to your program's caller, use
> an explicit die:
>
> $? >>= 8;
> if ( $? ) {
> print STDERR "ls failed.\n";
> # that's about as much as you can say, since we
> # don't have strerror.
> exit $?;
^^^^
You can 'die' as well as 'exit' :)
Just modify the original problem line:
$? >> 8) and die "ls failed: [$!][",($?>>8),"]\n";
^^^^^^
to something like:
$? >>= 8 and die "ls failed: [$!][$?]\n";
The problem is that only the low order 8 bits will be passed
to the caller. Unless 512 gets bit shifted, the caller sees
only 0. See wait(2), i.e., WEXITSTATUS is defined as the low
order 8 bits of the argument that the child passed to exit or
_exit.
HTH,
--
Charles DeRykus
------------------------------
Date: Thu, 16 Jul 1998 18:19:15 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: efficiency: print<<"xxx" vs. print
Message-Id: <MPG.1018466fc7b2d5bd989752@nntp.hpl.hp.com>
In article <pYqr1.144375$on1.7161739@news2.voicenet.com> on Thu, 16 Jul
...
> ... I make programs that work, and
> I'm always trying to make them look cleaner, and easier to understand
> (Sometimes at the expense of run time). I've always tried to accomplish
> this through use of comments, and taking the clearer (If sometimes more
> wordy) approach.
Real Programmers don't write comments! Seriously, comments should deal
with higher-level function, not with implementation details, which should
speak for themselves (assuming the reader knows the language).
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 17 Jul 1998 00:16:26 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: HELP : Integrating an Access DB with Perl
Message-Id: <35af76f0.3168836@news2.ibm.net>
[mailed & posted]
"Anthony farrow" <a.n.farrow@cranfield.ac.uk> wrote:
>I need to store information in a database that will be generated
>automatically from a perl script. Now, I could write my own database in Perl
>using files and parsing but I think for this I would really like a third
>party database. And I would prefer access.
>
>So, has anybody actually done this? I have had a look at the OLE module but
>I am unaware of the OLE calls needed to add to a jet database.
>
>Is there a primer anywhere, or does anybody have any example code they can
>post/email me?
I'm appending some sample code to create an Access database, add a table
and add some data into the table, all with Win32::OLE. There are myriad
other ways of doing this though. If you want to go the OLE route then
you should become very familiar with the Access online help file (which
documents all this for VB). If you have ADO (ActiveX Data Objects)
available, then I would prefer that over the native Access object model.
-Jan
use strict;
use Win32::OLE qw(with);
use Win32::OLE::Const 'Microsoft Access';
use Win32::OLE::Const 'Microsoft DAO';
my $Filename = 'i:\tmp\access.mdb';
unlink $Filename;
my $Access = Win32::OLE->new('Access.Application', 'Quit');
my $Workspace = $Access->DBEngine->CreateWorkspace('', 'Admin', '');
my $Database = $Workspace->CreateDatabase($Filename, dbLangGeneral);
my $TableDef = $Database->CreateTableDef('Quotes');
my $Field = $TableDef->CreateField('Date', dbDate);
$TableDef->Fields->Append($Field);
foreach my $FieldName (qw(Open High Low Close)) {
my $Field = $TableDef->CreateField($FieldName, dbDouble);
$TableDef->Fields->Append($Field);
}
my $Index = $TableDef->CreateIndex('Date');
with($Index, Primary => 1, Unique => 1);
$Field = $Index->CreateField('Date', dbDate);
$Index->Fields->Append($Field);
$TableDef->Indexes->Append($Index);
$Database->TableDefs->Append($TableDef);
my $Recordset = $Database->OpenRecordset('Quotes', dbOpenTable);
$Recordset->Addnew;
$Recordset->Fields('Date')->{Value} = "16.7.98";
$Recordset->Fields('Close')->{Value} = 42;
$Recordset->Update;
------------------------------
Date: 16 Jul 1998 19:26:28 -0400
From: allbery@kf8nh.apk.net (Brandon S. Allbery KF8NH)
Subject: Re: Indentation
Message-Id: <6om274$r3c$1@rushlight.kf8nh.apk.net>
Also sprach gerlach@netcom.com (Matthew H. Gerlach) (<gerlachEw7372.MI8@netcom.com>):
+-----
| In article <6oiv52$iv@tekka.wwa.com> scribble@pobox.com writes:
| >rra@stanford.edu writes:
| >>Editors really should not insert tabs for anything.
| >I'll take that as the crux of the whole matter. Consider
| >me a convert.
| I'm a convert too, but you better remember to turn tabs back on for
| makefiles or you will have many, many problems.
+--->8
...at least until someone does the sensible thing and replaces make with a
sensible and flexible syntax that's not dependent on magic whitespace.
(If only it were that easy... inertia sucks.)
--
brandon s. allbery [os/2][linux][solaris][japh] allbery@kf8nh.apk.net
system administrator [WAY too many hats] allbery@ece.cmu.edu
electrical and computer engineering
carnegie mellon university (bsa@kf8nh is still valid.)
------------------------------
Date: Thu, 16 Jul 1998 23:47:50 GMT
From: fnantes@my-dejanews.com
Subject: Looking for book about OOP with Perl
Message-Id: <6om3f6$4bj$1@nnrp1.dejanews.com>
Does any one know books about Object Oriented Design/Programming that have
examples in Perl. Or is there a book (OO analysis/design) that is more
indicated for people that want to write applications in Perl?
Thanks,
-Fernando
--
Fernando N. De Souza
Oracle/UNIX Admin
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 17 Jul 1998 00:41:02 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: m//g strange behaviour ?
Message-Id: <35AE9EF5.159F4C7@shaw.wave.ca>
Francois Desarmenien wrote:
>
> > > Could someone tell me why this script:
> > >
> > > --------------------------------------
> > > sub foo {
> > > $_[0] =~ /\G(.)/g;
> > > $1
> > > }
> > > print scalar foo('abcdef'), foo('abcef');
> > > --------------------------------------
> > >
> > > output "af" instead of "aa" that I would have expected ?
> > > Why the list context of second call to foo should modify
> > > the $_[0] =~ /\G(.)/g behaviour ?
> > >
> My real question is *why* is it executed in a list context ?
> The list context (to my understanding) should only apply
> to the returned value(s) of the sub, not to arbitrary statements
> inside of the sub. In fact it is *really* confusing: you write
> your sub which works fine, really clean for reuse, testing for
> wantarray before returning, then three weeks later you reuse it
> or modify one of its call so the scalar context call becomes a
> list context call. Then you loose four hours to debug and isolate
> the problem.
>
> I really wander if its a feature...
>
>
Well, now I get the question; too bad I don't know the answer. I can't
find anything in the docs where it specifically says that the context is
or is not applied only to the last (return) statement of the sub. The
only thing that implies that is isn't is from the entry for 'print' in
perlfunc:
Note that, because print takes a LIST, anything in the LIST is
evaluated in a list context, and any subroutine that you call will
have one or more of its expressions evaluated in a list context.
^^^^^^^
One thing I did notice is that the same thing happens if you use eval:
print scalar eval {'abcdef' =~ /(.)/g;$1},
eval {'abcdef' =~ /(.)/g;$1};
despite the 'eval' entry in perlfunc stating that the _last_ expression
is the one evaluated in scalar/list context.
The value returned is the value of the last expression evaluated,
or a return statement may be used, just as with subroutines. The
last expression is evaluated in scalar or array context, depending
on the context of the eval.
Nowhere does it explicitly state the context *only* applies to the last
statement, but nowhere does it say it doesn't. I would say there's a
bug in the docs, whether this behaviour is a feature or not.
The other thing I noticed is that you do get 'aa' under the older
v5.003.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: 17 Jul 1998 02:03:40 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: m//g strange behaviour ?
Message-Id: <6ombds$5c0$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Francois DESARMENIEN
<desar@club-internet.fr>],
who wrote in article <35ACFEF7.BC33FC8B@club-internet.fr>:
> Could someone tell me why this script:
>
> --------------------------------------
> sub foo {
> $_[0] =~ /\G(.)/g;
> $1
> }
> print scalar foo('abcdef'), foo('abcef');
> --------------------------------------
>
> output "af" instead of "aa" that I would have expected ?
I fyou report this to perlbug *real* quick, it may be even fixed for
5.005.
Ilya
------------------------------
Date: 16 Jul 1998 23:25:00 GMT
From: technik@cyrix.agoron.com ()
Subject: Re: Midnight Oil reference in Perl book?
Message-Id: <slrn6qt35k.a6.technik@cyrix.agoron.com>
In article <MPG.1015f43aaf72a856989744@nntp.hpl.hp.com>, Larry Rosler wrote:
>[This followup was posted to comp.lang.perl.misc and a copy was sent to
>the cited author.]
>
>In article <6ohis7$37d$1@bunyip.cc.uq.edu.au> on 15 Jul 1998 06:40:07
>GMT, Kelly Larnach <s339792@student.uq.edu.au> says...
>> Just reading the second edition of Programming Perl. And on
>> page 189 the line of code: my $country = @_; # right or wrong?
>> seems to resemble the lyrics of a Midnight Oil song quite closely.
>>
>> Is this just coincidence or is Larry, Tom or Randal, fans
>> of Midnight Oil?
>
>We all reveal our age or culture. The following was the favorite toast
>of Commodore Stephen Decatur, Jr. (1779-1820), a hero of the American
>War of 1812 (against England):
>
>"Our Country! In her intercourse with foreign nations, may she always be
>in the right; but our country, right or wrong!"
>
[snip]
Just nitpicking, the quotation is:
"Our Country! In her intercourse with foreign nations, may she always be
in the right and always successful, right or wrong."
Ross
------------------------------
Date: Thu, 16 Jul 1998 18:14:02 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Midnight Oil reference in Perl book?
Message-Id: <MPG.10184537dab21bd8989751@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <slrn6qt35k.a6.technik@cyrix.agoron.com> on 16 Jul 1998
23:25:00 GMT, technik@cyrix.agoron.com <technik@cyrix.agoron.com> says...
...
> >We all reveal our age or culture. The following was the favorite toast
> >of Commodore Stephen Decatur, Jr. (1779-1820), a hero of the American
> >War of 1812 (against England):
> >
> >"Our Country! In her intercourse with foreign nations, may she always be
> >in the right; but our country, right or wrong!"
> >
> [snip]
> Just nitpicking, the quotation is:
> "Our Country! In her intercourse with foreign nations, may she always be
> in the right and always successful, right or wrong."
Authoritative citation, please? I found the version I quoted in several
places on the Web, and it is the way I remembered it from childhood (but
that was a long time ago). The semantics of these two differ
considerably.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Jul 1998 22:59:11 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie question
Message-Id: <6om0jv$5g8$1@nswpull.telstra.net>
In article <6ok7mv$bj7$1@nswpull.telstra.net>,
mgjv@comdyn.com.au (Martien Verbruggen) writes:
[snip]
> # split the string in separate characters, and store in @a
> my @a = split //;
[snip]
[In a followup that I haven't seen here yet, but of which I received
an email copy, Larry Rossler wrote:]
> This retains the input line structure. I think they want one array
> with everything, not line by line.
Ah, a push @all, @a could take care of that. But in that case I would
probably do it differently indeed. Your solution from another post
seems a good one to me.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: Fri, 17 Jul 1998 00:16:28 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Passing null BSTR pointer with Win32::OLE
Message-Id: <35b178f1.3681764@news2.ibm.net>
[mailed & posted]
marc_mims@my-dejanews.com wrote:
>I read Jan Dubois' excellent article, Win32::OLE, in issue #10 of TPJ. I have
Thanks! I wish my own copy would arrive so that I can see how much Jon
had to change to make it readable. :-)
>successfully automated many tasks with Microsoft Visual SourceSafe using the
>techniques described. I am, however, having difficulty with a particular
>method, Get. Its first parameter is prototyped as follows:
>
>[in,out,defaultvalue(0)]BSTR *Local
>
>It behaves differently in each of three cases. 1) Passing a specific string,
>2) passing an empty string, 3) passing NULL.
>
>I need the third option, passing NULL, and can't seem to find the proper
>syntax in Perl. Any assistance would be appreciated.
>
>In C++, I would use the following
>
> BSTR local = NULL;
> HRESULT hr = item->Get(&local);
There is no way (that I know of) with the Win32::OLE module to produce a
VT_BSTR VARIANT containing a NULL pointer. I'm not even sure if that
would be valid (for the IDispatch interface). Did you trying passing a
VT_NULL or VT_EMPTY variant to the function (using Win32::OLE::Variant)?
If this all fails, could you send me a (short) example of what you are
trying to do and/or a pointer to the VSS documentation (I don't use it
myself, but probably have it somewhere in the Visual Studio stuff).
-Jan
------------------------------
Date: Thu, 16 Jul 1998 18:07:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Beautifier Home Page
Message-Id: <MPG.101843a333ff818d989750@nntp.hpl.hp.com>
In article <6olhvg$sbq$1@marina.cinenet.net> on 16 Jul 1998 18:49:20 GMT,
Craig Berry <cberry@cinenet.net> says...
> John Porter (jdporter@min.net) wrote:
> : Larry Rosler wrote:
> : >
> : > That's no excuse! It is trivial to split long quoted strings over more
> : > than one line and unite the fragments by concatenation or by join('',
> : > ...).
> :
> : Oog. You're adding executable code, just (nominally) for convenience
> : whilst editing? Eeeiw.
>
> 'Join does seem to be overkill for this. I tend to use string ' .
> 'concatenation instead, since it is equally easy to read and ' .
> 'does not require an extraneous code snippet after the text.'
I agree, but join() is possible. Strings are concatenated at compile
time, so there is no performance penalty at all. In fact a Benchmark
shows a slight speed *increase* that I can't understand.
> Of course, my favorite solution to this problem is that used by C/C++, in
> which adjacent string literals are folded together during preprocessing;
>
> "Some text "
> "and some more"
>
> becomes
>
> "Some text and some more"
>
> Can't beat that...no extraneous stuff in the source, no runtime overhead.
As I said, there is no runtime overhead for Perl's concatenated strings.
> Could such string-folding work in Perl? Would it break any existing
> elements of the language?
Perhaps not, but perhaps it also shouldn't be.
This syntax was proposed to the Standards Committee (by me, if I remember
right!) and met with some opposition, because implicit concatenation of
two strings simply by abutting them without any operator can lead to
hard-to-spot syntax errors. But it was always possible to join strings
split across lines by ending the first line with a backslash; of course
the continuation line had to start in column 1.
In Perl you don't need the backslash and it is ignored in double-quoted
strings. But an improperly terminated Perl string can run on for a long
long time.
I think the Perl concatenation operator is a fine solution.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Jul 1998 23:11:42 GMT
From: Ken Hardy <ken@bridge.com>
Subject: PerlScript ASP's BinaryWrite munging GIF data
Message-Id: <6om1be$6s3$1@usenet.bridge.com>
I've got a PerlScript ASP trying to send a GIF image to the browser. It
only sends the first few bytes of the data, though. The relevant code
looks like this:
$Response->{ContentType} = "image/gif" ;
$Response->BinaryWrite($img) ;
I've verified that $img does indeed contain a valid GIF image; I've
written it out to an intermidiate file on the server and looked at it.
But when it comes out of the IIS server, it has a null character after
every byte!
Is this a bug in PerlScript, or am I missing something? I'm using
PerlScript from www.activestate.com as an ASP language.
--
KH
------------------------------
Date: Thu, 16 Jul 1998 18:48:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question - push() unique?
Message-Id: <MPG.10184d4c29a34376989753@nntp.hpl.hp.com>
In article <Wstr1.4026$24.23305930@news.itd.umich.edu> on Thu, 16 Jul
1998 20:33:58 GMT, Sean McAfee <mcafee@joust.rs.itd.umich.edu> says...
> In article <35AE07D5.96894181@sjrwmd.state.fl.us>,
> John Paul Hernandez <jph@sjrwmd.state.fl.us> wrote:
> >is there a function or some other elegant way to push a value onto an
> >array IF that value does not already exist in the array?
>
> >something like, push(@a,$v) unless $v exists is @a ?? i looked at
> >exists, and that seems to work only for a hash.
>
> push(@a, $v) unless grep { $_ eq $v } @a;
>
> (Assuming we're dealing with strings; use == instead of eq for numbers,
> or some kind of equals() method if you're dealing with objects, etc.)
>
> As mentioned by others, though, you probably want something hash-like.
No one has bothered to state explicitly the *reason* for using a hash
instead of an array, perhaps because it's too obvious. But for the
unenlightened, it's because using a statement like the one above [in a
loop on $v] has quadratic complexity O(N ** 2), while using a hash has
linear complexity O(N).
So the solution above is appropriate if the array already exists and the
search is being done once only. It also preserves the order of the array
if that is important, whereas to recover the order from the hash is O(N
log N).
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 16 Jul 1998 20:28:52 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Removing the ^M character
Message-Id: <1dc9zk0.1iy8iaa16zaucwN@bay1-534.quincy.ziplink.net>
Dave Duchscher <daved@orion.tamu.edu> wrote:
> > $line=~s/\r\n$//;
>
> These won't work because the '$' matches the end of line before the new
> line (\n).
Not quite....
DB<1> $line = "foo\r\n"
DB<2> x $line
0 "foo\cJ\cM"
DB<3> $line =~ s/\r\n$//
DB<4> x $line
0 'foo'
DB<5>
$ will match either at the end of the string, or before a newline at the
end of the string. Putting \n in the regex before it simply limits it
to the first option.
If this regex isn't working for the original poster, it's for a
different reason.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 17 Jul 1998 01:28:37 GMT
From: bkhilton@netcom.com (Brand and Karina Hilton)
Subject: Results of the inaugural meeting of Dallas.pm
Message-Id: <bkhiltonEw7tFp.7qn@netcom.com>
For those of you keeping track, you'll remember that yesterday
was the first meeting of the Dallas Perl Mongers at Juan's (if you
pronounced that correctly, you have something nasty on your screen
about now) Cantina. Dallas was well-represented, with a total of
nine attendees, and Texas Instruments and Nortel were both well-
represented with three attendees each.
To my great embarrassment, I was the only member of the four-man
ADC contingent who was able to make the meeting. One had to play
rugby, one is on vacation, and a third... a Mr. Kendall Miller...
kmiller@adc.com... failed to show, even after telling me he would
be there. If you have an opinion on Mr. Miller's breach of his
solemn vow, please forward it to: kmiller@adc.com. Oh, and he
loves SPAM, so go ahead and put him on any lists you know of.
For the record, TI outdrank Nortel by one margarita, but I believe
the Nortel contingent successfully consumed more fat grams when
dinner came around. It should be noted that the latter contest
almost didn't take place, as English-speaking employees appeared
to be rather scarce, and requests for "a waiter" repeatedly produced
only pitchers of water. I really felt that Graham (Barr) of the TI
contingent let his team down when he ordered some wimpy chicken
enchilada thing instead of being a leader choking down a full order
of Supreme Nachos.
Graham regailed us with tales of the Perl 5 Porters... what a wacky
bunch of guys THAT is... and in between we discussed nerdy things in
general, largely, but not exclusively, Perl-related.
And then, this being Texas, we all let out a hearty "YEE-HAW", fired
our six-shooters into the air, jumped on our cuttin' horses and rode
off into the sunset. All except Graham. He got a little skittish
when the guns came out, and his "YEE-HAW" sounded more like, "AAAGH!!"
I get the feelin' maybe he's not from around these parts.
We'll be getting together again in about a month. If you want your
very own personalized email announcing this blessed event, just drop
me a line at bkhilton@netcom.com.
Brand
------------------------------
Date: 16 Jul 1998 22:36:00 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Re: Telnet Calls
Message-Id: <6olv8g$524$1@news.ycc.yale.edu>
Kelly Hirano <hirano@Xenon.Stanford.EDU> wrote:
>In article <6olnqk$hu4$1@nnrp1.dejanews.com>,
> <david2020@my-dejanews.com> wrote:
>>Can anybody provide me with a script that can generate hundreds of
>>simultaneous telnet sessions?
>>
>>I tried using fork(), but it seems that it's taking a lot of resources.
>
>of course it's using lots of resources. you said "hundreds of simultaneous
>telnet sessions". each session is a process -- not just a process, a big perl
>process.
But I think his point is that it only needs to be a socket. If he's trying
to load-test a server, then he doesn't need all the overhead on the client
side.
miguel
------------------------------
Date: Fri, 17 Jul 1998 01:08:52 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Timeout on connect
Message-Id: <Ew7sIt.Hqr@news.boeing.com>
In article <35AE18D2.ECA7813B@gv-nmc.unisource.nl>,
Andre van der Lans <andrel@gv-nmc.unisource.nl> wrote:
>Hi,
>
>I want to check if host ports are reachable through a firewall. For this
>reason I want to configure a timeout on the connect function call,
>because the firewall blocks the packages but I don't know how to do it.
>
>Here's the source code:
>
>
>#!/usr/bin/perl -w
>
>use Socket;
>use Getopt::Long;
>
>$proto = getprotobyname( 'tcp' );
>$remote = 'brutus';
>$iaddr = inet_aton( $remote );
>
>for ($port = 0; $port <= 100; $port++ ) {
> print "\nPort $port: ";
> $paddr = sockaddr_in( $port, $iaddr );
> if( !socket( S, PF_INET, SOCK_STREAM, $proto ) ) {
> print "if statement 1 ";
> print "socket: $!";
> }
> if( !connect( S, $paddr ) ) {
> print "if statement 2 ";
> print "$!";
> }
> else {
> print " >>> Connection established <<< ";
> }
> close( S );
>}
>
>Regards, Dre
>
man perlipc and grep for 'eval' for example of timing out
a command or you could use the IO::Socket module with a
built in timeout, e.g.,
use IO::Socket;
$sock = new IO::Socket(
PeerAddr => "123.456.789.012",
PeerPort => "ftp",
Timeout => 10, # seconds
Domain => AF_INET,
Proto => 'tcp'
) or die "$@";
HTH,
--
Charles DeRykus
------------------------------
Date: 16 Jul 1998 20:07:40 -0400
From: allbery@kf8nh.apk.net (Brandon S. Allbery KF8NH)
Subject: Re: What is awk better at than perl? (Larry quote)
Message-Id: <6om4kc$rin$1@rushlight.kf8nh.apk.net>
Also sprach opus@magibox.net (Brock Sides) (<opus-1507981940170001@dave.magibox.net>):
+-----
| I've seen the quote from Larry Wall (at
| http://www.perl.org/lwall-quotes.txt) "Hey, I had to let awk be better at
| *something*... :-)"
|
| So what is it that awk is (or was) better at?
+--->8
IFS can be a regular expression in awk; in Perl, it's a literal string.
--
brandon s. allbery [os/2][linux][solaris][japh] allbery@kf8nh.apk.net
system administrator [WAY too many hats] allbery@ece.cmu.edu
electrical and computer engineering
carnegie mellon university (bsa@kf8nh is still valid.)
------------------------------
Date: Fri, 17 Jul 1998 01:13:52 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: What is awk better at than perl? (Larry quote)
Message-Id: <Ew7sr4.IBx@news.boeing.com>
In article <6olm7v$egu$1@mathserv.mps.ohio-state.edu>,
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to Mark-Jason Dominus
><mjd@op.net>],
>who wrote in article <6olhq7$rg$1@monet.op.net>:
>> In article <opus-1507981940170001@dave.magibox.net>,
>> Brock Sides <opus@magibox.net> wrote:
>> >So what is it that awk is (or was) better at?
>>
>> ... | awk '{print $1}'
>
>I do not know awk, but knowing Perl, I would try
>
> | perl -lane 'print $F[0]'
>
Only a hardened addict will go for extra keystrokes :)
--
Charles DeRykus
------------------------------
Date: 17 Jul 1998 02:00:43 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: What is awk better at than perl? (Larry quote)
Message-Id: <6omb8b$52c$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Charles DeRykus
<ced@bcstec.ca.boeing.com>],
who wrote in article <Ew7sr4.IBx@news.boeing.com>:
> >> >So what is it that awk is (or was) better at?
> >>
> >> ... | awk '{print $1}'
> >
> >I do not know awk, but knowing Perl, I would try
> >
> > | perl -lane 'print $F[0]'
> >
>
> Only a hardened addict will go for extra keystrokes :)
Extra keystrokes - maybe. Knowledge of an extra program to pollute my
memory - no.
Ilya
------------------------------
Date: Thu, 16 Jul 1998 21:07:55 -0700
From: "zhe dang" <dangran@worldnet.att.net>
Subject: when i use htaccess to do authentication
Message-Id: <6om8en$g67@bgtnsc02.worldnet.att.net>
when i use htaccess to do client authentication, how can a server know who
(usrid and passwd)
accesses the protected page?
------------------------------
Date: Thu, 16 Jul 1998 09:45:02 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Win NT Perl 5.0 Y2K compliance
Message-Id: <fl_aggie-1607980945020001@aggie.coaps.fsu.edu>
In article <fl_aggie-1407981741250001@aggie.coaps.fsu.edu>,
fl_aggie@thepentagon.com (I R A Aggie) wrote:
+ Is NT itself Y2K compliant?
Ironically, I just read yesterday that NT (3.51 || 4.0) hasn't been
certified as Y2K compliant...
James
------------------------------
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 3181
**************************************