[10452] in Perl-Users-Digest
Perl-Users Digest, Issue: 4044 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 22 11:04:07 1998
Date: Thu, 22 Oct 98 08:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 22 Oct 1998 Volume: 8 Number: 4044
Today's topics:
Re: "Can't locate auto/Getopt/Long/autosplit.ix" (Johan Vromans)
Re: Access to a DLL with PERL ?? <Pierre.Laplante@intellia.com>
Re: CGI quandaries (Hugh Dixon)
CGI.pm and $query->self_url problems <cgormley@netcomuk.co.uk>
Re: Count files in a dir SSI or CGI (David Alan Black)
Re: Exporter issues (Greg Bacon)
Re: Exporter issues <merlyn@stonehenge.com>
Re: flock() win32 <jdf@pobox.com>
Re: Help: CGI.pm basic (Joergen W. Lang)
Re: Help:Tried installing PERL under WIN3.11, it simply <charon@eastky.net>
Re: I digress... (Michael J Gebis)
Re: lack of flock() for Win95/98? fix? <gtermars@home.com>
NT binary for PerlMagick? webmuse@my-dejanews.com
Re: Perl & Y2K - booby trap code (Abigail)
Re: Perl & Y2K - booby trap code (Abigail)
Re: Perl & Y2K - booby trap code (Matt Knecht)
Re: Perl & Y2K - booby trap code <merlyn@stonehenge.com>
Re: Perl & Y2K - booby trap code <merlyn@stonehenge.com>
Re: Pink? Blue? What color _is_ it??? (Clinton Pierce)
Re: Problem with perl scripts... droby@copyright.com
Q:Array of Lists stefan_007@my-dejanews.com
Re: Q:Array of Lists (Kevin Reid)
Real Blocking Reads (named pipes) - *a* Solution d__m__g@my-dejanews.com
Script error <marx@idiom.com>
Re: Script error (Matt Knecht)
Re: Script error (Tad McClellan)
sequential line count <marx@idiom.com>
sort <foxindustries@worldnet.att.net>
Re: sorting (Andrew M. Langmead)
Re: split() works not as expected dave@mag-sol.com
Re: split() works not as expected (Joergen W. Lang)
Re: Still confused with pattern matching (Michael J Gebis)
Re: Still confused with pattern matching (Larry Rosler)
Re: Still confused with pattern matching (Patrick Timmins)
Re: The story of WinNT & the almost-written data... (Clinton Pierce)
Re: What's the "best" way to call one Perl script from (Greg Bacon)
Re: Windows NT and Perl - File Structure - opendir & re <sbeam@acunet.net>
Re: Windows NT and Perl - File Structure - opendir & re <msergeant@ndirect.co.uk_NOSPAM>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Oct 1998 13:53:33 +0200
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Re: "Can't locate auto/Getopt/Long/autosplit.ix"
Message-Id: <wl33e8g4xtu.fsf@plume.nl.compuware.com>
Larry Granroth <larry-granroth@NOSPAM.uiowa.edu> writes:
> This may well be a dumb question:
No, the only dumb questions are the ones that you want to ask, but do
not.
> Can't locate auto/Getopt/Long/autosplit.ix in @INC
It looks like something went wrong during your installation.
Fetch ftp://ftp.perl.com/pub/CPAN/authors/id/JV/GetoptLong-2.17.tar.gz,
and install it the usual way.
I hope this helps.
-- Johan
------------------------------
Date: Thu, 22 Oct 1998 12:41:25 GMT
From: Pierre Laplante <Pierre.Laplante@intellia.com>
Subject: Re: Access to a DLL with PERL ??
Message-Id: <362F2732.A7495885@intellia.com>
This is a multi-part message in MIME format.
--------------01AFE4E53626DE4DE3446E47
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
use Win32::OLE;
$obj = Win32::OLE->new("PL.usagers") ||
die "Can't create object: " . Win32::OLE->LastError() . "\n";
--------------01AFE4E53626DE4DE3446E47
Content-Type: text/x-vcard; charset=us-ascii;
name="Pierre.Laplante.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Pierre Laplante
Content-Disposition: attachment;
filename="Pierre.Laplante.vcf"
begin:vcard
n:Laplante;Pierre
x-mozilla-html:TRUE
org:Intellia Inc.
adr:;;;Montreal;Quibec;H3C 1X6;Canada
version:2.1
email;internet:pierre.laplante@intellia.com
title:Conseiller principal
tel;fax:514.392.0911
tel;work:514.392.1292
note:Pierre.Laplante@altavista.net
x-mozilla-cpt:;0
fn:Pierre Laplante
end:vcard
--------------01AFE4E53626DE4DE3446E47--
------------------------------
Date: Thu, 22 Oct 1998 11:52:29 GMT
From: glhjd@zeus.bris.ac.uk (Hugh Dixon)
Subject: Re: CGI quandaries
Message-Id: <F188zI.Lv6@fsa.bris.ac.uk>
Tom Phoenix (rootbeer@teleport.com) wrote:
<stuff>
I think, if I read your question rightly, you've come up against something I
encountered a while back - passing args to SSI scripts is totally different from
doing it through the webserver - it's being executed directly by the server and
hence the query_string to @ARGV translation doesn't happen -
Your code needs to be this:
<!--#exec cmd="script.cgi arg1 arg2 arg3"--> ie. just like you would type it in
at the command line. Then it should work.
HTH
Hugh
------------------------------
Date: Thu, 22 Oct 1998 14:04:22 +0100
From: "Clinton Gormley" <cgormley@netcomuk.co.uk>
Subject: CGI.pm and $query->self_url problems
Message-Id: <70nafu$scc$1@taliesin.netcom.net.uk>
I am using CGI.pm in a script built to take details on a form. This same
script performs error checking and then moves on to the next of several
screens of details to be filled out. ( eg contact details -> banking
details -> etc ->etc)
So the script is called recursively. in order to preserve state, I am using
the CGI method self_url to generate URL + query string as a redirection.
(running on NT 4 + IIS).
The problem is (if the URL is http://www.foo.com/cgi-bin/bar.pl?a=1&b=2),
self_url is generating url's life
http://www.foo.com/cgi-bin/bar.pl/www.foo.com/cgi-bin/bar.pl/www.foo.com/cgi
-bin/bar.pl?a=1&b=2)
Obviously, it is putting in the URL as many times as the script has been
called. I've got around this by redirecting to
$query->url.'?'.$query->query_string.
Is this a problem with CGI.pm, or IIS, or something I'm doing.
Thanks
Clint
------------------------------
Date: 22 Oct 1998 09:36:43 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Count files in a dir SSI or CGI
Message-Id: <70ncdb$kj1$1@pilot.njin.net>
Hello -
"DuhK" <keithlol@nospammindspring.com> writes:
>. and .. are files like any other. If the directory were really empty, it
>wouldn't exist to begin with. So I started with "1", so at least the answer
>stimulated YOUR thought.
The convention is to describe a directory as "empty" when it contains only
itself and its parent directory. Observe:
orpheus:~/perl$ mkdir fillme
orpheus:~/perl$ touch fillme/thing
orpheus:~/perl$ rmdir fillme
rmdir: fillme: Directory not empty
orpheus:~/perl$ rm fillme/thing
orpheus:~/perl$ rmdir fillme # no complaint; "not empty" is now false
orpheus:~/perl$ ls fillme
/bin/ls: fillme: No such file or directory
. and .. do have a special status. It's useful to understand that directories
are files, but it isn't helpful to suggest that there are no meaningful
distinctions among different types of file.
In any case, I've never known anyone to mean "including directories" when asking
how to count files in a directory. Of course, they could mean that. But they
never do. At the very least, they certainly never mean . and .. .
(Interesting typographical challenge, the end of that last sentence.)
And I don't see how ending up with a count of 3 for an empty directory
makes sense. 0 or 2 would be plausible candidates, depending on exactly
what you're trying/claiming to be counting.
>Every question deserves an answer. Guess you learned by never asking?
>Shezzz...
I'm not going to hang my head and say, "Gee, yeah, I guess it's OK to
treat clpm as a CGI program exchange bulletin board, 'cause I've made
mistakes too," if that's what you're wondering. I don't think it's OK
to do that.
David Black
dblack@pilot.njin.net
------------------------------
Date: 22 Oct 1998 14:27:22 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Exporter issues
Message-Id: <70nfca$rmh$2@info.uah.edu>
In article <362ED121.7C0ED3FB@creative.net>,
Farhad Farzaneh <ff@creative.net> writes:
: I'm trying to use exporter to export from a sub-module. That is,
: assume the module a.pm that lives in direcotry A.
:
: Here is file a.pm:
:
: package a;
There's your problem. A/a.pm should have
package A::a;
Greg
--
Would somebody please explain to me those signs that say, "No animals allowed
except for Seeing Eye Dogs?" Who is that sign for? Is it for the dog, or the
blind person?
-- Jerry Seinfeld
------------------------------
Date: Thu, 22 Oct 1998 14:49:33 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Exporter issues
Message-Id: <8cvhlcps7d.fsf@gadget.cscaper.com>
>>>>> "Farhad" == Farhad Farzaneh <ff@creative.net> writes:
Farhad> I'm trying to use exporter to export from a sub-module. That is,
Farhad> assume the module a.pm that lives in direcotry A.
Farhad> Here is file a.pm:
Farhad> package a;
This needs to be "package A::a;"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 22 Oct 1998 15:42:12 +0200
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: flock() win32
Message-Id: <m3u30wzpaj.fsf@joshua.panix.com>
mgjv@comdyn.com.au (Martien Verbruggen) writes:
> But i seem to recall that win95/98 don't have flock. Not a perl
> problem, just s systems problem. Nt does have it, I believe. Not too
> sure.
NT supports flock().
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Thu, 22 Oct 1998 16:35:42 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: Help: CGI.pm basic
Message-Id: <1dhb48j.1cycjmq8tb7z6N@host033-210.seicom.net>
Tungyat Wong <g8winter@cdf.toronto.edu> wrote:
> Hi,
>
> I created a very simple script:
>
> use CGI;
> $query = new CGI;
>
> if ($query->param('mo')) {
> $mode=$query->param('mo')
> }
# You forgot to print a "Content-type" header
# CGI.pm does that for you:
print $query->header('text/plain');
> print "$mode";
>
> which works just fine in consolde. But it doesn't work when I point my
> browser to
> http://localhost/cgi-bin/test.pl?mo=tutor
>
>
> Other program without using CGI.pm module work just fine..
>
> Any help is appreciate..
hth,
Joergen
--
To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
"Everything is possible - even sometimes the impossible"
HOELDERLIN EXPRESS - "Touch the void"
------------------------------
Date: Thu, 22 Oct 1998 08:01:43 -0400
From: "Charon" <charon@eastky.net>
Subject: Re: Help:Tried installing PERL under WIN3.11, it simply gave me an error 2 on bat. installation
Message-Id: <70n6ce$pb9$1@nd.eastky.net>
Please read the first 5 lines of what you typed.
PERLW32...WIN32...WIN3.11...
Which one of those doesn't belong.
WIN3.11 is a 16 bit architechture. Not 32 bit.
G. North <aufempen@dyson.brisnet.org.au> wrote in message
70mb11$8ga$1@bunyip.cc.uq.edu.au...
>Help:Tried installing PERL under WIN3.11, it simply gave me an error 2 on
>bat. installation
>I downloaded PW321316.exe from Active.
>Unzipped 252 files perfectly well.
>Then when I am trying to run PERLW32-Install.bat, I
>am receiving an error 2.
>I have read a lot of FAQ about WIN32 but there is
>nothing specific about the installation under WIN3.11
>or MSDOS 6.22.
>If anyone can help.
>Please email direct if you wish
>aufempen@dyson.brisnet.org.au
>Cheers Guy North
>
>
------------------------------
Date: 22 Oct 1998 06:25:08 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: I digress...
Message-Id: <70mj44$2ci@mozo.cc.purdue.edu>
jwilde@openskies.com (Justin Wilde) writes:
} Is there a condensed/simpler/cleaner/more-efficent way to do the
}following? Sure seems like a lot of code to do something so
}straightforward.
}if ( length ( $intMonth ) eq 1 ) {
} $intMonth = "0$intMonth";
}}
# The sprintf way:
$intMonth = sprintf "%02d",$intMonth;
# The regexp way
"0$intMonth" =~ m/(\d\d)$/;
$intMonth = $1;
# The substr way
$intMonth = substr("0$intMonth",-2,2);
# You've already covered the length way. (Although you should probably
# be using '==' instead of 'eq'. And by probably, I mean definitely)
# Yet another way, aka the length way on one line.
$intMonth = (($intMonth =~ m/^\d$/) ? '0' : '') . $intMonth;
# I'd probably argue that since you're formating a string to be
# printed, the string print formating function known as sprintf is
# the right solution.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Thu, 22 Oct 1998 14:58:33 GMT
From: Graham TerMarsch <gtermars@home.com>
Subject: Re: lack of flock() for Win95/98? fix?
Message-Id: <362F4819.472C77DA@home.com>
Jan VanderStoel wrote:
> I attempted to run a Perl script using the flock() function on a Win 98
> platform using Perl 5.005. The script failed giving an error message saying
> that the flock() function is not implemented on this platform. The docs do
> not indicate that flock() is not implemented. This script does work on Win
> NT 4. Is there a fix for the Win 95/98 platform?
If I remember correctly, there isn't much of a fix for this on Win95/98,
neither is there one for NT if running on a FAT partition. Sorry.
--
Graham TerMarsch
// -----------------------------------------------------------------
// Live in a world of your own, but always welcome visitors.
// -----------------------------------------------------------------
------------------------------
Date: Thu, 22 Oct 1998 14:35:56 GMT
From: webmuse@my-dejanews.com
Subject: NT binary for PerlMagick?
Message-Id: <70nfsc$u42$1@nnrp1.dejanews.com>
I have the NT binary for ImageMagick, but in order to use the
PerlMagick interface I need to compile it. Does anyone know of
an already-made NT binary for PerlMagick?
Regards,
Thomas
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Oct 1998 14:08:55 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <70ne9n$t18$1@client3.news.psi.net>
Jim Brewer (jimbo@soundimages.co.uk) wrote on MDCCCLXXVIII September
MCMXCIII in <URL:news:ud87lge9o.fsf@jimbosntserver.soundimages.co.uk>:
++ mjd@op.net (Mark-Jason Dominus) writes:
++
++ >
++ > If someone trips on a banana peel, it's partly their fault for not
++ > looking where they were going, but it's also partly the fault of
++ > whoever left the banana peel in the way. This is a banana peel.
++ >
++
++ Only in civil litigation mad America would such a perverted concept be
++ uttered. Who the hell will you blame when you fall off the unstable
++ sea cliff because you were standing too near the edge? God?
++ Geologists? The city government?
++
++ And if a sign were posted, then what? Would you still sue God?
++ Geologists? The city government?
++
++ Perl has a cliff. Perl has a sign. Read it. Stand back away from the
++ edge. Never fall off.
Cliffs are made by nature. Perl is man made. If someone falls off an
unstable, man made building, the builder certainly takes part of the
blame.
++ Illiterate? Don't program. Can read? RTFM. Put responsibility squarely
++ back on the shoulders that bear the burden. The Perl user. If one uses
++ Perl, use it correctly. If one does not know how to use Perl
++ correctly, RTFM.
Just because it's documented doesn't make a language free of pitfalls.
Abigail
--
perl -wlpe '}{$_=$.' file # Count the number of lines.
------------------------------
Date: 22 Oct 1998 14:13:08 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <70nehk$t18$2@client3.news.psi.net>
Steve Monson (monson@tri.sbc.com) wrote on MDCCCLXXVII September MCMXCIII
in <URL:news:70ljq5$f5c@euphony.tri.sbc.com>:
++ See ye here Abigail's writings:
++ >Craig Berry (cberry@cinenet.net) wrote on MDCCCLXXVII September MCMXCIII
++ >++ 'Fix' is the wrong term. Perl's localtime() is just a wrapper for C/Unix
++ >++ localtime(), which has, throughout history, returned year-1900.
++ >
++ >I agree with Gisle. The person who decided the tm struct should contain
++ >the year - 1900 made a very bad decision, and it would have great if
++ >Larry had "fixed" it for Perl.
++
++ I see nothing wrong with year-1900. To get the proper year, just always
++ add 1900. Not even a problem when comparing dates, unless you go back
++ before 1900.
There isn't any problem having localtime return numbers in base 17. Or the
number of years since 1666 squared, minus 1024.
It doesn't make it easy for the programmer though.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Thu, 22 Oct 1998 14:29:07 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <TiHX1.101$6J3.1599027@news2.voicenet.com>
Abigail <abigail@fnx.com> wrote:
>There isn't any problem having localtime return numbers in base 17. Or the
>number of years since 1666 squared, minus 1024.
>
>It doesn't make it easy for the programmer though.
It makes it easy for the C programmer migrating to Perl.
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Thu, 22 Oct 1998 14:38:56 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <8c4sswr79i.fsf@gadget.cscaper.com>
>>>>> "finsol" == finsol <finsol@ts.co.nz> writes:
finsol> In your expert opinion: Would you recommend that Perl
finsol> applications be checked for Year 2000 problems?
Only in the same sense that *all* applications be check for such
problems. Do not single out "Perl" being the fault. There is *no*
language that is immune from potential Y2K problems.
So, delete the word "Perl" there, and I'll agree with you.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 22 Oct 1998 14:43:31 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <8czpaopshe.fsf@gadget.cscaper.com>
>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes:
Russ> Randal Schwartz <merlyn@stonehenge.com> writes:
>> In the same way, it'll make perfect sense past the millennium (or even
>> now) to talk about years like 11/22/03 (to mean my birthday in the year
>> 2003) and 11/22/98 (to mean my birthday this year).
Russ> I think you need to read Tom's rant about Y2K again. :)
No, I'm quite settled on my opinion. :)
There is *always* a context for any data. It's important to keep the
context in mind when creating *and* interpreting the data, and to
ensure that there's an agreement at both ends. If the context is
"late 20th, early 21st century", then 11/22/03 has a perfectly sane
interpretation.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 22 Oct 1998 13:23:49 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Pink? Blue? What color _is_ it???
Message-Id: <70nbl5$4501@eccws1.dearborn.ford.com>
In article <8ck91tr4fc.fsf@gadget.cscaper.com>,
Randal Schwartz <merlyn@stonehenge.com> writes:
>>>>>> "John" == John G Dobnick <jgd@alpha3.csd.uwm.edu> writes:
>
>John> Now, we all know what the "pink" camel is.
>
>John> But what's this "blue" thing? Since when did "teal" become "blue"?
>John> Have I missed something
>
>Of the colors: red, orange, yellow, green, blue, purple, white, and
>black, the second edition camel is closest to "blue". Therefore, I
>call it "blue". I'm sorry if you find this confusing. :)
>
By this logic, the First Edition Camel would be the "red" Camel, not
pink. :-)
--
+------------------------------------------------------------------------+
| Clinton A. Pierce | "If you rush a Miracle Man, | http://www. |
| cpierce1@ford.com | you get rotten miracles" | dcicorp.com/ |
| fubar@ameritech.net |--Miracle Max, The Princess Bride| ~clintp |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*
------------------------------
Date: Thu, 22 Oct 1998 13:30:36 GMT
From: droby@copyright.com
Subject: Re: Problem with perl scripts...
Message-Id: <70nc1s$qbg$1@nnrp1.dejanews.com>
In article <MPG.1097f9c0f470d56198969c@news.supernews.com>,
danbeck@eudoramail.com (Daniel Beckham) wrote:
> Oh, I forgot this... Two major errors here. Variable substitution, etc.
> doesn't take place inside of '', so in order for you newlines to work,
> you should use double qotes. e.g. "Hello World.\n\n";
>
> Also, /n isn't a new line. It should be \n
>
Another error: This being imbedded in HTML without <PRE> and </PRE>, the
newlines are quite irrelevant.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Oct 1998 14:05:25 GMT
From: stefan_007@my-dejanews.com
Subject: Q:Array of Lists
Message-Id: <70ne37$scu$1@nnrp1.dejanews.com>
Hi,
sorry about this question (I'm not familiar with perl), but why doesn't this
work ?
@Data[0] = ( "red", "green", "blue" );
@Data[1] = ( "Apple", "Orange", "Peanuts" );
print "First: ",$Data[0][0],"\n";
print "Second: ",$Data[0][1],"\n";
Thanks for your answer,
Stefan.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Oct 1998 10:49:04 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Q:Array of Lists
Message-Id: <1dhaqh8.4nsedgr8oikgN@slip166-72-108-10.ny.us.ibm.net>
<stefan_007@my-dejanews.com> wrote:
> Hi,
>
> sorry about this question (I'm not familiar with perl), but why doesn't
> this work ?
>
> @Data[0] = ( "red", "green", "blue" );
> @Data[1] = ( "Apple", "Orange", "Peanuts" );
> print "First: ",$Data[0][0],"\n";
> print "Second: ",$Data[0][1],"\n";
Arrays can contain only scalar values. You should store a reference to
the array instead; one way of doing this is to use the anonymous* array
constructor, which creates an array and returns a reference to it:
$Data[0] = [ "red", "green", "blue" ];
$Data[1] = [ "Apple", "Orange", "Peanuts" ];
print "First: ",$Data[0][0],"\n";
print "Second: ",$Data[0][1],"\n";
(Also, you should use $, not @, when referring to an element of an
array.)
Array values can be directly interpolated into strings:
$Data[0] = [ "red", "green", "blue" ];
$Data[1] = [ "Apple", "Orange", "Peanuts" ];
print "First: $Data[0][0]\n";
print "Second: $Data[0][1]\n";
You can use qw() to construct lists of strings:
$Data[0] = [qw(red green blue)];
$Data[1] = [qw(Apple Orange Peanuts)];
print "First: $Data[0][0]\n";
print "Second: $Data[0][1]\n";
You can build an array in one statement:
@Data = (
[qw(red green blue)],
[qw(Apple Orange Peanuts)],
);
print "First: $Data[0][0]\n";
print "Second: $Data[0][1]\n";
---
* anonymous: not in the symbol table (i.e. it has no name).
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: Thu, 22 Oct 1998 13:17:23 GMT
From: d__m__g@my-dejanews.com
Subject: Real Blocking Reads (named pipes) - *a* Solution
Message-Id: <70nb92$plc$1@nnrp1.dejanews.com>
I've been trying to do a blocking read on a named pipe.
The problem was that, unfortunately, the read didn't seem to block properly.
The code was like:
...
open IN, "<../pipes/in" or die;
...
This blocked a bit but later, my <IN> would return when I knew there was
nothing to read. I played with select() and sysread... The select() indicated
that the file was available to read.
But I knew the writing process had finished and the next hadn't started yet...
Then I saw a post about select() from Randal Schwartz (1998/04/15):
>>>>> "David" == David Boyce <David.Boyce@fmr.com> writes:
David> In the following sample code, trimmed down from a program which
David> monitors a set of logfiles, the intent is to use 4-arg select
David> (via the IO::Select module) to block until output is ready.
>Files are *always* "ready to read". Even if there are 0 bytes to
>read. You'll need to rethink your strategy.
Which lead to me thinking 'of course, if the writer goes away, there's no
point in blocking - you need to have a writer there all the time - open the
pipe for read *AND* write' - even though I never write...
changing < to +
...
open IN, "+../pipes/in" or die;
...
meant that the <IN> *always* blocks - of course I don't lock the pipe for
writing so the *real* writer can still get to it...
(This was 5.005001 on a Linux system)
Hope this helps someone...
David
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 22 Oct 1998 08:32:46 -0500
From: "Marcus J. Foody" <marx@idiom.com>
Subject: Script error
Message-Id: <362F33FE.CD0@idiom.com>
Hello, I have developed a perl parsing script on a windows platform and
it works great. When I ported it over to Unix(AIX) and ran the script I
got an error. If anyone has any ideas, they would be most appreciated.
Here is the error:
"Use of uninitialized value at arload.pl line 124, <OUTFILE> chunk 5"
At line 124 is a variable:$sum = $data[14] + $data[15] + $data[16];
Here is the whole routine
while (<OUTFILE>){
@data = split(/\|/);
$rec_amt1 = $data[14];
$rec_amt2 = $data[15];
$rec_amt3 = $data[16];
#
#Below is line 124
$sum = $data[14] + $data[15] + $data[16];
if(/REC HEAD/){
$count++}
print FH_REC_HEAD "$field|".join('|',@data[4,5,2,3,18,10]),"|$sum|"
.join('|',@data[16,14,15]),"|$count|"
.join('|',@data[11,7,9,8,17,13,19,12,20,21,22,23,24,25,26]),"\n"
if(/REC HEAD/);
}
------------------------------
Date: Thu, 22 Oct 1998 13:50:47 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Script error
Message-Id: <XKGX1.98$6J3.1579906@news2.voicenet.com>
Marcus J. Foody <marx@idiom.com> wrote:
>"Use of uninitialized value at arload.pl line 124, <OUTFILE> chunk 5"
>
> @data = split(/\|/);
>$rec_amt1 = $data[14];
>$rec_amt2 = $data[15];
>$rec_amt3 = $data[16];
>#Below is line 124
>$sum = $data[14] + $data[15] + $data[16];
Assuming you haven't changed the value of $/, it would seem that the
fifth line of OUTFILE does not have at least 17 elements.
Of course, we'll never know for sure, since you didn't post your data
(Or at least line 5).
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Thu, 22 Oct 1998 09:17:57 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Script error
Message-Id: <lqen07.5em.ln@flash.net>
Marcus J. Foody (marx@idiom.com) wrote:
: Hello, I have developed a perl parsing script on a windows platform and
: it works great. When I ported it over to Unix(AIX) and ran the script I
^^^^^^^^^^^^^^^^^^
Did you run it against the same data as on windows?
: got an error. If anyone has any ideas, they would be most appreciated.
: Here is the error:
: "Use of uninitialized value at arload.pl line 124, <OUTFILE> chunk 5"
^^^^^^^
I would look closely at line 5 from wherever <OUTFILE> is reading.
: At line 124 is a variable:$sum = $data[14] + $data[15] + $data[16];
: Here is the whole routine
: while (<OUTFILE>){
# add a debugging statement and run it again
warn "Ack! not enough fields on the line below\n$_" unless tr/|/|/ >= 16;
: @data = split(/\|/);
: $rec_amt1 = $data[14];
: $rec_amt2 = $data[15];
: $rec_amt3 = $data[16];
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 22 Oct 1998 07:17:54 -0500
From: "Marcus J. Foody" <marx@idiom.com>
Subject: sequential line count
Message-Id: <362F2272.6412@idiom.com>
Hello, I'm trying to get a sequential count or sub count with not much
luck. If anyone has any suggestions they would be much appreciated.
This is what I have, everytime $data[2] changes I would like to restart
the count. Basically, I havetwo if statments(see bottom), the first if
statement holds the field $data[2].
Below is what I'm getting now.
$data[2] Count
|709 216:05:09| 016967 |1|1|PRODUCT 1
|709 216:05:09| 016968 |2|1|PRODUCT 2
|709 216:05:09| 016968 |2|2|PRODUCT 2
|709 216:05:09| 016969 |3|1|PRODUCT 3
Below is the count desired
$data[2] Count
|709 216:05:09| 016967 |1|1|PRODUCT 1 "$data[2] does not change"
|709 216:05:09| 016968 |2|1|PRODUCT 1 "$data[2] restart count"
|709 216:05:09| 016968 |2|2|PRODUCT 2 "$data[2] does not change"
|709 216:05:09| 016969 |3|1|PRODUCT 1 "$data[2] restart count"
Here is my code
if ($line =~ /REC HEAD/) {
@data = split(/\|/, $line);
$sub_cnt++ = $data[2];
$sum = $data[14] + $data[15] + $data[16];
$header = "|$data[4] $field|$data[2]|$cnt|";
}
if ($line =~ /REC ITEMS/) {
@records = split(/\|/, $line);
$item =
"$records[2]|$records[9]|$records[4]|$records[8]|$records[3]|";
push(@final, "$header$item$sub_cnt\n")
}
------------------------------
Date: 22 Oct 1998 14:43:22 GMT
From: Carl Fox <foxindustries@worldnet.att.net>
Subject: sort
Message-Id: <362F5D32.5989@worldnet.att.net>
I am blue in the face with this problem. Please help. I am sorting and
searching a flat database file field, numerically, and am having
problems. For example: when I searcch for 50, any record with 5000,
500, 50, and 5 pops up. Is there any way to get an EXACT match instead
of a greater than, less than, or equal to? None of the operators, so
far, are returning the proper match, so please don't just refer me to
some apparently "textbook" solution.
Thanks,
Carl Fox
------------------------------
Date: Thu, 22 Oct 1998 14:27:09 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: sorting
Message-Id: <F18G5A.DrK@world.std.com>
mjd@op.net (Mark-Jason Dominus) writes:
>In article <sar7ly0p7z9.fsf@camel.fastserv.com>,
>Uri Guttman <uri@camel.fastserv.com> wrote:
>> i think you should just be able to use the sub ref directly.
>I asked Chip about this a couple of days ago, and he agreed.
Its documented that way in the camel too. I remember when the book
came out, I assumed it was a "pre-announced feature" (even
accidentally. The same way that many new functions now take $_ as an
argument because they were documented in the camel.) Then I saw some
discussion about in in perl5porters, but I guess nothing ever came of
it.
--
Andrew Langmead
------------------------------
Date: Thu, 22 Oct 1998 13:02:31 GMT
From: dave@mag-sol.com
Subject: Re: split() works not as expected
Message-Id: <70nad7$osu$1@nnrp1.dejanews.com>
In article <70n2a8$id7$1@nnrp1.dejanews.com>,
raimund_kessler@my-dejanews.com wrote:
> What I want to do is to increment an ip address. I tried to split the address
> in the 4 parts then increment the last one and finally join the parts
> together. To split I used the line @pip = split(/\./,$ip[0]); After that the
> value of @pip was 4. Whats wrong? Can anybody help me?
Depends what you mean by the 'value' of @pip. A list evaluated in a scalar
context returns the number of elements. I would guess that's what you're doing
as the number of elements in your list is probably four.
Try adding the following code to your program and see what you get:
$pip[-1]++;
print join('.', @pip);
hth,
Dave...
--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 22 Oct 1998 16:36:03 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: split() works not as expected
Message-Id: <1dhb4q3.1vfrqdwnggfaeN@host033-210.seicom.net>
<raimund_kessler@my-dejanews.com> wrote:
> What I want to do is to increment an ip address. I tried to split the address
> in the 4 parts then increment the last one and finally join the parts
> together. To split I used the line @pip = split(/\./,$ip[0]); After that the
> value of @pip was 4. Whats wrong? Can anybody help me?
>
> Thanks in advance
> Raiund Kessler
It looks like you evaluated @pip in a scalar context, which gave you the
number of elements @pip contains, not the elements themselves.
But without any code exmaples it's very hard to say, what's really going
on.
Does this do, what you want ?
#!/usr/bin/perl -w
$ip[0] = "123.45.255.9"; # the first element of @ip
@pip = split /\./, $ip[0]; # @pip is filled by splitting $ip on the dot.
$pip[3]++; # increment fourth element of @pip by 1
$new_ip = join ".", @pip; # join the elements back together.
print $new_ip;
__END__
Joergen
--
To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
"Everything is possible - even sometimes the impossible"
HOELDERLIN EXPRESS - "Touch the void"
------------------------------
Date: 22 Oct 1998 06:34:33 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Still confused with pattern matching
Message-Id: <70mjlp$2gj@mozo.cc.purdue.edu>
Chi Yu <chi@cybie.com> writes:
}Hi All,
}I'm baffled with this bit of code. I'm expecting to pattern match on
}digits 0-9 or fail the edit, but a value of "X" matches!
}$mls = "X";
}if ($mls =~ /[0-9]*/) {
Whoa. You used a "*". That means match zero or more. You matched
zero times, so it succeeded.
You probably wanted something like:
m/^\d$/; # To match EXACTLY one digit, perhaps with a trailing newline.
m/^\d+$/; # To match something composed of only digits (+ maybe newline)
m/\d+/; # To match a group of digits anywhere (no anchors)
}I expect the code to not match but it does match! What's wrong with the
}code?
Remember: a "*" ALWAYS succeeds. You can always match zero of
something.
ObMentionOfTheBookMasteringRegularExpressions: by Freidl.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Thu, 22 Oct 1998 06:59:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Still confused with pattern matching
Message-Id: <MPG.1098da287baa41c99898d8@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <u24n07.shk.ln@flash.net> on Thu, 22 Oct 1998 06:14:38 -0500,
Tad McClellan <tadmc@flash.net> says...
> Martien Verbruggen (mgjv@comdyn.com.au) wrote:
> : In article <362ED1BE.14AEABE1@creative.net>,
> : Farhad Farzaneh <ff@creative.net> writes:
>
> : > if ($mls =~ /[0-9]+/) {
>
> : You realise that this does the same as
>
> : if ($mls =~ /\d/)
> ^^^^
> ^^^^
>
> /\d+/ is the same as /[0-9]+/ (was a typo, I'm sure)
As Martien is probably still sleeping, I'll venture to answer for him.
No, it wasn't a typo. Note the absence of capturing parentheses.
/\d/ is TRUE if /\d+/ is TRUE, and it is also faster.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Oct 1998 14:28:42 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Still confused with pattern matching
Message-Id: <70nfeq$tht$1@nnrp1.dejanews.com>
In article <u24n07.shk.ln@flash.net>,
tadmc@flash.net (Tad McClellan) wrote:
> Martien Verbruggen (mgjv@comdyn.com.au) wrote:
> : In article <362ED1BE.14AEABE1@creative.net>,
> : Farhad Farzaneh <ff@creative.net> writes:
>
> : > if ($mls =~ /[0-9]+/) {
>
> : You realise that this does the same as
>
> : if ($mls =~ /\d/)
> ^^^^
> ^^^^
>
> /\d+/ is the same as /[0-9]+/ (was a typo, I'm sure)
Literally, true. But functionally, the return on the conditional
using /\d/ will always be the same as that for /\d+/ or /[0-9]+/ .
Of course, it *will* change the $&, $', etc,. It would also not be
at all the same if the regex were part of a split, or if there
were anchors in the regex, capturing parentheses, etc.
You know I know you know this, Tad :) ... I just wanted to point this
out for regex newbies ... this sort of thing always used to catch me
when I was starting out (an occasionally still does, if I'm sleepy :)
Patrick Timmins
$monger{Omaha}[0]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Oct 1998 13:26:56 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: "R. King" <rking@duke-energy.com>
Subject: Re: The story of WinNT & the almost-written data...
Message-Id: <70nbr0$4502@eccws1.dearborn.ford.com>
In article <70lm04$gp9$1@news3.infoave.net>,
"R. King" <rking@duke-energy.com> writes:
>When I run the script below with ActivePerl (5.002 w/ perl 5.005_2) on
>NT4.0, STDOUT gets the whole thing, but the script only writes about 3/4 of
>the web page to the file...
>
>Can anyone help?
>
>=====================================================
>
>use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->agent("DukeZilla/0.1 " .
>$ua->agent);
>my $req = new HTTP::Request GET => 'http://bigbird.stockmaster.com/c/duke/';
>
>print "Requesting StockQts. on [", scalar localtime, "]";
>
>my $res = $ua->request($req);
>
>if ($res->is_success)
>{
> $my_stock_html=$res->content;
>
> open(STOCK_HTML,">J:\\www\\info\\stock_quotes.htm") or die $!;
> print $res->content;
> print STOCK_HTML $res->content;
> print "\t Success(!)\n";
>}
Not to be pedantic, and a good Operating System wouldn't care,
but where's the close() of the filehandle STOCK_HTML?
--
+------------------------------------------------------------------------+
| Clinton A. Pierce | "If you rush a Miracle Man, | http://www. |
| cpierce1@ford.com | you get rotten miracles" | dcicorp.com/ |
| fubar@ameritech.net |--Miracle Max, The Princess Bride| ~clintp |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*
------------------------------
Date: 22 Oct 1998 14:19:53 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: What's the "best" way to call one Perl script from another?
Message-Id: <70neua$rmh$1@info.uah.edu>
In article <70m2dm$3ks@transfer.stratus.com>,
alfred@hw.stratus.com (Alfred von Campe) writes:
: But using system() to call another Perl script doesn't feel very
: perlish - is there a better (more elegant) way to do it?
Why not? Is a command less of a command just because it isn't written
in C?
Greg
--
Beauty is in the eye of the beer holder...
------------------------------
Date: Thu, 22 Oct 1998 09:21:16 -0400
From: Sam Beam <sbeam@acunet.net>
Subject: Re: Windows NT and Perl - File Structure - opendir & readdir
Message-Id: <362F314C.74035B40@acunet.net>
Yes, opendir is totally broken in the AS build - my favorite workaround is
globs -
ie
my @textfiles = <$somepath/*.txt>;
or
my @logfiles = glob("$somepath\\*.log");
which is way quicker and dirtier than the opendir function and its brethern
anyway. Works in PerlScript too. The docs have more details.
My only question is - this is so easy, there must be some
mystical/political/metaphysical reason why we should not do this. If so, Id
like to know because I am now globbing at the drop of a hat, even on UNIX.
Also suggest you might go to activestate.com and subscribe to the
perl-win32-announce listserv, this kind of stuff gets discussed all the time
there :) ---
SZ Beam
Just another Technical Consultant...
momus wrote:
> I'm moving a set of perl scripts I wrote on Mac, and originally ran on Mac
> an UNIX, over to an NT server.
> The problem, which has become the bane of my existence, is that the
> functions 'readdir' and 'opendir' don't seem to function. They don't
> create errors, but they also don't open the directory, or read its
> contents.
> I've tried using absolute and relative addresses.
> I've also tried using colon, forward-slash, back-slash, and double
> back-slash delimiters.
> I also tried using the 'cat' function, which also doesn't seem to work.
>
> Does NT implement these functions in its version of PERL?
> My thanks in advance for any help that can be offered.
>
> Adam
> aswan@eudoramail.com
------------------------------
Date: Thu, 22 Oct 1998 15:16:01 +0100
From: Matt Sergeant <msergeant@ndirect.co.uk_NOSPAM>
Subject: Re: Windows NT and Perl - File Structure - opendir & readdir
Message-Id: <362F3E21.EC60981F@ndirect.co.uk_NOSPAM>
Sam Beam wrote:
>
> Yes, opendir is totally broken in the AS build - my favorite workaround is
> globs -
[snip]
Correction - was broken. Build 504 is out (use their ftp server as it's
not shown on their web site) which fixes the problem (which was in their
ISAPI/PerlScript code, not in perl itself).
--
<Matt/>
| Fastnet Software Ltd | Perl in Active Server Pages |
| Perl Consultancy, Web Development | Database Design | XML |
| http://come.to/fastnet | Information Consolidation |
------------------------------
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 4044
**************************************