[19320] in Perl-Users-Digest
Perl-Users Digest, Issue: 1515 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 14 00:05:36 2001
Date: Mon, 13 Aug 2001 21:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <997761909-v10-i1515@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 13 Aug 2001 Volume: 10 Number: 1515
Today's topics:
Re: Can read, but can't write (wade)
case sensitive <jtjohnston@courrier.usherb.ca>
Re: com port usage (Logan Shaw)
Re: Comma's at end of list can break program?? (Logan Shaw)
Re: Comma's at end of list can break program?? (Logan Shaw)
dates <banjo-dave@prodigy.net>
Re: dates <krahnj@acm.org>
Re: Disk usage of file (Logan Shaw)
Re: Excel Function (Logan Shaw)
Re: Expiration dates for cookies <Dave.Stafford@globis.net>
Re: Global hash requires explicit package name?? (Eric Bohlman)
Re: How do I assing an entire array? (Eric Bohlman)
Re: Line counting in a file <joe+usenet@sunstarsys.com>
Re: Module installation problem <ronnie@r-davies.demon.co.uk>
Re: Module installation problem <ronnie@r-davies.demon.co.uk>
Re: Module installation problem <kalinabears@hdc.com.au>
Re: Multiple field seperators with split() <comdog@panix.com>
Re: Multiple field seperators with split() <wyzelli@yahoo.com>
Re: Multiple field seperators with split() <ahamm@sanderson.net.au>
Re: small CGI.pm hack, code review request <shutupsteve@awdang.no.thanks.com>
Re: validate IP address <comdog@panix.com>
Re: VIER/NEUN problem (Greg Bacon)
Re: Way to do database read to disk instead of memory? <projectobjects@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Aug 2001 20:58:12 -0700
From: jjchen@alumni.ice.ntnu.edu.tw (wade)
Subject: Re: Can read, but can't write
Message-Id: <4259465b.0108131958.3dc5bcf6@posting.google.com>
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrn9ng8ps.5vb.tadmc@tadmc26.august.net>...
> sowbug <brianwharris@hotmail.com> wrote:
> >tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrn9nav4n.4nh.tadmc@tadmc26.august.net>...
> >> sowbug <brianwharris@hotmail.com> wrote:
> >> >I'm trying to write to an html file in htdocs with my perl script
> >> >that's in cgi-bin. Using Unix with Apache.
>
>
> >> >The script is executing
> >> >fine. I'm not getting any errors,
> >>
> >>
> >> Then you have already looked at your server logs to make sure
> >> that the die() didn't execute?
>
> >> Didn't I say I'm not GETTING ANY ERRORS??
1. If you not sure what happened, you can run the script under
shell.
2. To sure that the script can access your file because it will run
as "nobody" normally.
3. To rewrite your die subroutine, or called Fail(), is a better
way.
sub Fail
{
my $ERROR_MSG = shift;
$query->print "$ERROR_MSG....\n";
}
Because die output into STDERR not STDOUT.
------------------------------
Date: Tue, 14 Aug 2001 02:30:22 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: case sensitive
Message-Id: <3B788B5F.9CCB9FD0@courrier.usherb.ca>
I have an array (delicious supper :)
@MyArray = (split/\n/,"Spicy Sichuan-style Shrimp
Cashew Chicken
Northern-style Cold Noodles
Peking-style Caramel Walnuts
Stir-fried Mixed Vegetables");
I want to find out if the user inputted, from html, the correct answer,
but using case insensitive. Here is what I have so far. How can I change
this to make it case insenstitive? Here is the code I have so far:
---------snip---------
$user_input = $in{'P2WC3Q4'};
$Return_Value = 0;
foreach $i (0..$#MyArray)
{
if (/$MyArray[$i]/i eq /$user_input/i) #obviously not correct
{
$Return_Value = 1;
}
}
print "$Return_Value <hr>";
---------snip---------
Thanks,
John
(An email post & reply would make my night :)
------------------------------
Date: 13 Aug 2001 22:27:15 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: com port usage
Message-Id: <9la5qj$piv$1@charity.cs.utexas.edu>
In article <VLQd7.51079$ye.2206470@afrodite.telenet-ops.be>,
Showroom <showroom@aarquerepro.be> wrote:
>Is it possible to change the port setting for com1 from within a perl script
>(on WIN NT 40 or WIN 98) by using the dos command (MODE COM1:9600,7,E,1) ?
It's possible to use the Win32::SerialPort module, and it's probably a
better idea. See http://search.cpan.org/search?dist=Win32-SerialPort .
>Can I also use COPY FILE.PRN COM1: in the script ?
Maybe, but once you've got the serial port open in Perl directly, why
not just send the data yourself?
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: 13 Aug 2001 22:09:43 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Comma's at end of list can break program??
Message-Id: <9la4pn$pet$1@charity.cs.utexas.edu>
In article <3b776a45@news.victoria.tc.ca>,
Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
>but if you enumerate all the possible things you could do, and some people
>more qualified than me have enumerated some of the techniques, (like
>always provding positive logic but never double negative logic, etc, )
>then your program will be more maintainable.
:
:
>No, they're going to mess it up in direct proportion to how well you
>shielded them from the problems that you (the supposed expert) understood
>but they didn't.
Actually, I think agree with this idea already. I definitely try to
write my code in such a way that things will be clear to read, rather
than fun to write, and I try not to leave any traps lying around in the
code that would be easy to stumble over. In fact, I sometimes obsess
over it and end up wasting time. :-)
But commas after the last item in lists in Perl are a matter of the
maintainer who forgets Perl syntax either (a) not noticing that
anything happened (if I put them), or (b) getting this error message
(if I don't put them):
String found where operator expected at $FILENAME line $LINE,
near "$LIST_ITEM"
(Missing semicolon on previous line?)
where $FILENAME, $LINE, and $LIST_ITEM are values supplied by the
interpreter.
IMHO, if they can't figure that message out in 9 seconds, they need to
be in another profession.
Of course, if I'm working in an environment where a comma after the
last item is one of the coding conventions, then that's 9 seconds of
time wasted by somebody who shouldn't have had to waste it. But that's
purely convention.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: 13 Aug 2001 22:11:58 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Comma's at end of list can break program??
Message-Id: <9la4tu$pg5$1@charity.cs.utexas.edu>
In article <9l7o26$ln3$1@sloth.swcp.com>, Tramm Hudson <hudson@swcp.com> wrote:
>I've found it handy for diffs since the lines with commas do not
>need to be edited. As an example, if you have the hash:
>
>my %h = (
> foo => 3,
> bar => 12,
>);
>
>and need to add an item, the diff would be very clear:
>
> my %h = (
> foo => 3,
> bar => 12,
>+ baz => 9,
> );
>
>rather than the more muddled:
>
> my %h = (
> foo => 3,
>- bar => 12
>+ bar => 12,
>+ baz => 9
> );
That's the best reason I've seen so far. The increased beauty and
utility of that may even offset the increased ugliness (IMHO) of the
syntactically superfluous comma.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: Tue, 14 Aug 2001 01:45:18 GMT
From: "Dave McLean" <banjo-dave@prodigy.net>
Subject: dates
Message-Id: <Oo%d7.8950$O12.1206884468@newssvr17.news.prodigy.com>
Hi, I'm trying to, given a date, determine the date of the first and last
days of the week that the given date falls in. I've written this and it
works fine for the end of the week but not for the the begining:
given:
$date = "1999-08-13";
if( strftime( "%A", "$date" ) eq 'Sunday' ){
$week_start = $date;
}else{
$week_start = strftime( "%Y-%m-%d", localtime( parsedate( "last sunday", NOW
=> parsedate( $date ) ) ) );
}
if( strftime( "%A", "$date" ) eq 'Saturday' ){
$week_start = $date;
}else{
$week_start = strftime( "%Y-%m-%d", localtime( parsedate( "next saturday",
NOW => parsedate( $date ) ) ) );
}
for some reason, every date yields "Sunday" for week start
any suggestions, thoughts, comments?
thanks,
dave
------------------------------
Date: Tue, 14 Aug 2001 03:33:31 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: dates
Message-Id: <3B789CAF.A609D599@acm.org>
Dave McLean wrote:
>
> Hi, I'm trying to, given a date, determine the date of the first and last
> days of the week that the given date falls in. I've written this and it
> works fine for the end of the week but not for the the begining:
>
> given:
> $date = "1999-08-13";
>
> if( strftime( "%A", "$date" ) eq 'Sunday' ){
> $week_start = $date;
> }else{
> $week_start = strftime( "%Y-%m-%d", localtime( parsedate( "last sunday", NOW
> => parsedate( $date ) ) ) );
> }
>
> if( strftime( "%A", "$date" ) eq 'Saturday' ){
> $week_start = $date;
> }else{
> $week_start = strftime( "%Y-%m-%d", localtime( parsedate( "next saturday",
> NOW => parsedate( $date ) ) ) );
> }
>
> for some reason, every date yields "Sunday" for week start
>
> any suggestions, thoughts, comments?
#!/usr/bin/perl -w
use strict;
use Time::Local;
my $date = '1999-07-03';
my ( $year, $mon, $day ) = $date =~ /(\d+)/g;
my @date_array = ( 0, 0, 0, $day, $mon - 1, $year - 1900 );
print scalar( localtime( timelocal( @date_array ) ) ), "\n";
my $wday = (localtime( timelocal( @date_array ) ))[6];
my @start = my @end = @date_array;
$start[3] -= $wday;
$end[3] += 6 - $wday;
print scalar( localtime( timelocal( @start ) ) ), "\n";
print scalar( localtime( timelocal( @end ) ) ), "\n";
__END__
John
--
use Perl;
program
fulfillment
------------------------------
Date: 13 Aug 2001 22:22:47 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Disk usage of file
Message-Id: <9la5i7$phq$1@charity.cs.utexas.edu>
In article <D3Wd7.39331$uM6.5357359@news1.telusplanet.net>,
Sean Hamilton <sh@planetquake.com> wrote:
>I need to figure out what kind of space people are using so they can be
>charged appropriately.
>
>I don't need to be exact on this stuff, but obviously if somebody fills up
>the drive with 1-byte files, I want to charge them for that drive, not for
>the few megs that amounts to in file length.
Does "quot -v" not work on FreeBSD?
Actually, the problem you describe is pretty difficult to do
correctly. Each file uses space in a directory, and maybe more than
one directory if it's linked into more than one (a "hard link"). On
most Unix filesystems, files also use i-nodes, and those take up disk
space. Just how much space is hard to say, because it will depend on
the design of the individual filesystem.
A decent first approximation is to multiply two of the values returned
by the lstat() function: the one that tells you the block size of the
filesystem, and the one that tells you the number of blocks used. But
that's not really correct on all filesystems, because some filesystems
store things in fragments of blocks, and there is no reason your Perl
program couldn't be running in an environment where there is a
filesystem that doesn't use blocks at all.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: 13 Aug 2001 22:31:19 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Excel Function
Message-Id: <9la627$pk7$1@charity.cs.utexas.edu>
In article <b5a94f5e.0108130602.379bf224@posting.google.com>,
Daniel CARBONERO <d.carbonero@chu.ulg.ac.be> wrote:
>I Would like to know how to use excel function like Array in perl
>script
>
>I want to create a pivot table.
>I use this code but I have an exec error, It seems that array is
>unknown
>
>AddFields({RowFields=>Array("PAY_DATE", "CASHDESK", "DESCRIPTION",
>"ID"),ColumnFields=>array("OPERATION_TYPE",
>"PAY_METHOD"),PageFields=>array("CAMPUS", "GRP")});
I'm not sure exactly what you're trying to do, but I think maybe you're
trying to create a value that can be used like a regular (scalar) value
and can "hold" an array. If that's the case, you probably want this
Perl syntax:
{
a => [ "foo", "bar" ],
b => [ "zippity", "doo-dah"]
}
Basically, when you use the square brackets ("[" and "]"), an array
gets created, the list that's inside the brackets gets put into the
array, and the value of the whole thing is a reference to an array. A
reference is a scalar value somewhat like a pointer that refers to the
array.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: Mon, 13 Aug 2001 20:45:31 GMT
From: "Dave Stafford" <Dave.Stafford@globis.net>
Subject: Re: Expiration dates for cookies
Message-Id: <L%Wd7.411303$XL1.6915962@nlnews00.chello.com>
If you do not set an expiration date, the cookie is held in memory and is
deleted when the browser is closed.
Dave
"A.J. Mieskolainen Titan/SRC x4946" <mieskolaNOSPAM@hfl.tc.faa.gov> wrote in
message news:3B780491.48C6DA74@hfl.tc.faa.gov...
> OK, I have successfully figured out how to set and retrieve cookies, is
> there anyway I can set a cookie to die when the browser it was set on
> dies? Thanks.
>
> AJ
------------------------------
Date: 14 Aug 2001 02:08:27 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Global hash requires explicit package name??
Message-Id: <9la16r$foe$4@bob.news.rcn.net>
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
> sub print_record
> {
> my ($file_hash, $key) = @_;
> my ($value);
> if ($file_hash{$key}) { # <-- ERROR OCCURS HERE
> $value = $file_hash{$key};
> I get the following error:
> Global symbol "%file_hash" requires explicit package name ...
Others have explained how to use references properly, but I just wanted to
mention why you were getting that particular error: "$file_hash{$key}"
means "the $key-th element of the hash %file_hash" and you never declared
a %file_hash.
As I understand it, in Perl 6 you'll use a % for a hash element as well as
for the whole hash, so this source of confusion will be gone.
------------------------------
Date: 14 Aug 2001 01:58:17 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: How do I assing an entire array?
Message-Id: <9la0jp$foe$3@bob.news.rcn.net>
Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:
> Stan Brown wrote:
>> Thaks, I thought of that, but what if @p_keys goes out of scope by the time
>> I need it?
> Why should it do such a nasty thing? ;-)
> Honestly, I can't quite follow you now. You certainly have to take care
> that you don't do something like this:
Actually, it's a perfectly reasonable question for someone who's quite
familiar with programming in general, but less so with Perl, to ask. In,
for example, C, you'd get into a lot of trouble if you stashed a pointer
to a local variable into a data structure that was going to stick around
after you exited the current block; as soon as the local variable went out
of scope, your data structure would be pointing to an arbitrary place on
the stack. Perl is somewhat unusual in that it makes the analogous
operations possible (by mapping variable names to SVs rather than directly
to the storage area; it's amazing just how much indirection can buy you).
------------------------------
Date: 13 Aug 2001 23:42:31 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Line counting in a file
Message-Id: <m3lmkn9ujc.fsf@mumonkan.sunstarsys.com>
Ilmari Karonen <iltzu@sci.invalid> writes:
> In article <m3r8umcpo5.fsf@mumonkan.sunstarsys.com>, Joe Schaefer wrote:
> >WARNING: Usage of \$. should be avoided whenever possible.
> >Of the $. lines it appears in my perl5 tree, most of them are completely
> >inane:
>
> I would disagree with the opinion express on the first line above, and
> claim that the statistics produced by your (admittedly clever) program
> are irrelevant in determining this, for a very simple reason: The main
> utility of $. is generally in shell one-liners, not in the modules and
> full-blown scripts you are counting.
Fair enough, but keep in mind the issue I was addressing was what
Yves Orton wrote:
>> my $lines=0;
>> open (IN,$0) || die $!;
>> while (<IN>) {$lines++};
>> print "$.\t$lines\n";
>>
>> When I run it it prints out the same number twice, so why other with
>> $lines?
It appeared to me that he was looking for some reasons against using $.,
so I tried to oblige. Of course I failed, since he's not on a *nix
system anyway :(
[...]
> > %2d of them are for pod or man documentation (in poor condition),
>
> You wouldn't want $. to be documented?
Close- short of some effort to repair the documentation for $.,
I'd prefer to see it taken out of the language like $# was. The flaws
in perlvar's account of $. are IMO very serious. But fixing pervar isn't
that simple- I find it impossible to avoid discussing implementation
details without some gross oversimplification.
Here's the best I came up with:
$. Current line number for the last filehandle accessed.
Attached to each open filehandle is an internal scalar
that perl uses to keep track of the current line number.
It does so by incrementing the scalar each time a line
is read (via readline() or <>). "$." becomes an alias
for it whenever a line is read, or when "tell" or "seek"
is called on the filehandle. Although rarely necessary,
you also can modify this variable (without affecting the
filehandle's seek pointer) by assigning a new value to "$.".
"$." is reset when the filehandle is closed, except when
an open filehandle is reopened without an intervening close().
For more details, see the section on "I/O Operators" in the
perlop manpage-- in particular, it explains how $. works for
the special null filehandle "<>". Additional examples are
listed in the eof entry of perlfunc.
The value reported by $. may be different from
the actual physical line number in the file, depending on
what notion of "line" is in effect-- see "$/" on how to
change that. Note that localizing "$." will not localize
the filehandle's current line count. Instead, it allows you
to localize Perl's notion of "the last read filehandle".
(Mnemonic: many programs use "." to mean the current
line number.)
That's my understanding of how $. works; please correct any errors
or omissions.
> > %2d are for polite localization (typically the file's sole usage
> > of \$.),
>
> Note that doing this has additional effects beyond just localizing the
> current line number.
Would you elaborate? I have no idea what those effects might be,
nor do I grok what you mean by
"localizing the current line number"
If you are talking about something other than localizing the concept of
*last* in the phrase "last filehandle accessed", I'm lost.
>
> > %2d are for reassigning \$. to a less obscure variable name.
>
> I'd say that the last one isn't really "inane" at all -- you would not
> make that claim about $1 etc., would you? $. is a moderately volatile
> variable, and saving its value for later use is perfectly sensible.
Of course you are right, and I originally planned to make a separate
category for usage like this. However, I had already spent too much
time concoting the script, so I just left it as is. Such usage should
have been listed as examples of "good" usage of $. I apologize for
the oversight.
<postscript>
In my perl5 tree, the file where $. appears most frequently was
ExtUtils/xsubpp; where tracking line numbers is an important part of
that script. Also, lines 858-884 contain a nice application of $.,
one where adding an additional line counter might actually detract
from the script's readability.
However, the author of that script isn't someone that posts questions
to clp.misc (anymore); perhaps because he enjoys using global vars,
and on occasion symrefs, as he sees fit :)
</postscript>
--
Joe Schaefer "The only thing to do with good advice is pass it on; it is
never of any use to oneself."
-- Oscar Wilde
------------------------------
Date: Tue, 14 Aug 2001 02:15:11 +0100
From: Ronnie Davies <ronnie@r-davies.demon.co.uk>
Subject: Re: Module installation problem
Message-Id: <ZvFPYDAfuHe7EwVV@r-davies.demon.co.uk>
In article <6asgnt8fnq6v0jufjt6bsdnpqutlmtmh6c@4ax.com>, Bart Lateur
<bart.lateur@skynet.be> writes
>Ronnie Davies wrote:
>
>>Then, the following message appeared:-
>>
>>Unable to find a perl 5 (by these names: C:\Perl\bin\Perl.exe miniperl
>>perl perl
>>5 perl5.6.1, in these dirs: C:\PERL\BIN C:\Perl\bin)
>>Running '0 -IC:\Perl\lib C:\Perl\lib\ExtUtils\xsubpp -v 2>&1' exits with
>>status
>>16777215 at (eval 26) line 17.
>
>You're not running this on NT, are you?
Nope! Win98.
>
>I remember having encountered the very same problem myself, and the
>problem was with the "2>&1" thing. NT knows the concept, but Win95/98/ME
>do not.
>
>Gee, I currently don't use ActivePerl myself, so I can't really check.
>Perhaps it has been fixed. BTW the file to check is ExtUtils/MM_Win32.pm
You are indeed correct. On line 163 of the above file is the offending
string. Is there anything I can change it to so the problem can by by-
passed?
>
>>I found a file called 'makefile' in the directory.
>>
>>As instructed, I next ran nmake.exe, which I had copied to that
>>directory previously. I got a fatal error U1081: '0' : program not
>>found.
>
>Ah yes. ExtUtils::MakeMaker, upon failure of the above (finding
>perl.exe, that is), uses "0" (zero) as the name for perl.exe. Open the
>makefile, search for the variable PERL, and replace the value "0" with
>"perl", and do the same for FULLPERL, that might be enough to make it
>work. The full path would be better still.
I have done this. I noticed that the offending 2>&1 string is in the
part of the mm_win32.pm file that looks for perl.exe. However, upon
running nmake.exe, I get further errors. The output is as follows:-
Skip blib\lib\Bundle\DBD\InterBase.pm (unchanged)
Skip blib\lib\DBD\InterBase.pm (unchanged)
Skip blib\lib\DBD\InterBase\FAQ.pm (unchanged)
c:\perl\bin\perl.exe -p -e "s/~DRIVER~/InterBase/g" <
C:/Perl/site/lib/a
uto/DBI/Driver.xst > InterBase.xsi
File not found
c:\perl\bin\perl.exe -IC:\Perl\lib -IC:\Perl\lib
C:\Perl\lib\ExtUtils/xs
ubpp -typemap C:\Perl\lib\ExtUtils\typemap InterBase.xs > InterBase.c
Cannot open 'InterBase.xsi': No such file or directory in InterBase.xs,
line 19
NMAKE : fatal error U1077: 'C:\PERL\BIN\PERL.EXE' : return code '0x1'
Stop.
Presumably it goes through the skip routine because I've run nmake more
than once. Anyway, is it likely that it is not finding the file because
makefile.pl does not run properly (a problem that requires modification
of mm_win32.pm to remedy)?
Thank you very much for your help so far - I really do appreciate it.
--
Ronnie Davies
He who laughs last........thinks slowest!
------------------------------
Date: Tue, 14 Aug 2001 02:56:05 +0100
From: Ronnie Davies <ronnie@r-davies.demon.co.uk>
Subject: Re: Module installation problem
Message-Id: <jAvxzBA1UIe7EwhR@r-davies.demon.co.uk>
In article <iltgntco0jj86b8041i4301b3601g17d9a@4ax.com>, Bart Lateur
<bart.lateur@skynet.be> writes
>Bart Lateur wrote:
>
>>>Unable to find a perl 5 (by these names: C:\Perl\bin\Perl.exe miniperl ...
>
>>I remember having encountered the very same problem myself, and the
>>problem was with the "2>&1" thing. NT knows the concept, but Win95/98/ME
>>do not.
>
>Wait a minute. There was yet another problem. It was that $? returned
>non-zero even if the external program was executed properly. You should
>check that. Yes, that implies debugging ExtUtils::MM_Win32. Just keep a
>backup of that file for when you've finished all of your tests.
>
Having done a little further reading on the 2>&1 string, I found some
articles suggesting I remove that string. It no longer complains that
it cannot find perl and indeed, the makefile created does specify the
path correctly. However, I still get the remains of the error message
when I try to run makefile.pl.
Thanks again!
--
Ronnie Davies
He who laughs last........thinks slowest!
------------------------------
Date: Tue, 14 Aug 2001 12:07:57 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Module installation problem
Message-Id: <997791157.969864@clover.origin.net.au>
"Ronnie Davies" <ronnie@r-davies.demon.co.uk> wrote in message
news:Tvpx3EAVCGe7EwFN@r-davies.demon.co.uk...
>
> Unable to find a perl 5 (by these names: C:\Perl\bin\Perl.exe miniperl
> perl perl
> 5 perl5.6.1, in these dirs: C:\PERL\BIN C:\Perl\bin)
You'll have to eradicate the above error, but the 2 below don't matter.
> Running '0 -IC:\Perl\lib C:\Perl\lib\ExtUtils\xsubpp -v 2>&1' exits with
> status
> 16777215 at (eval 26) line 17.
> Running '0 C:\Perl\lib\ExtUtils\xsubpp temp000 2>&1' exits with status
> 16777215
> at (eval 26) line 43.
The workaround that I have used in the past is to open the 'Makefile.pl'
and, in the 'WriteMakefile()' section, insert the following:
PERL => "$^X",
This has always got rid of the 'unable to find....' error for me, and, as I
said above, the other 2 don't matter, though I do have some notes on how to
remove them which I'll post to you offlist.
Most, if not all, of these types of errors come from 'MM_Unix.pm' as Bart
Lateur pointed out.
I'm surprised that it's an issue with the 5.6.1 builds. I know it affected
Active State build 613, but not 623 and 626.
Cheers,
Rob
------------------------------
Date: Mon, 13 Aug 2001 21:06:18 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: Multiple field seperators with split()
Message-Id: <comdog-3E1FAC.21061813082001@news.panix.com>
In article <9l9srs$6ag$1@bob.news.rcn.net>, "noms" <dont@mail.me>
wrote:
> Hey everyone, I'm running into problems when parsing some router
> information. This is mainly because I don't know how to setup multiple
> field seperators in split().
> I'm able to retrieve the router information and store it into an array.
> Then I use the grep() function to pull the statistics information that I
> need and store it into another array. I'm having problems when I try to
> split the fields in members of that array. Here is a sample member:
>
> reliability 255/255, txload 1/255, rxload 1/255
>
> I'd like to be able to pull the numerator fields, in this case 255-1-1. I'm
> trying to get those fields using the following split calls ($foo is the
> sample line):
why wrestle with split?
my @data = m|(\d+)/|g;
or if you need the names too:
my %data = m|(\w+)\s+(\d+)/|g;
--
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Tue, 14 Aug 2001 10:59:01 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Multiple field seperators with split()
Message-Id: <l4%d7.24$1T.95813@wa.nnrp.telstra.net>
"noms" <dont@mail.me> wrote in message news:9l9srs$6ag$1@bob.news.rcn.net...
> Hey everyone, I'm running into problems when parsing some router
> information. This is mainly because I don't know how to setup multiple
> field seperators in split().
>
> I'm able to retrieve the router information and store it into an array.
> Then I use the grep() function to pull the statistics information that I
> need and store it into another array. I'm having problems when I try to
> split the fields in members of that array. Here is a sample member:
>
> reliability 255/255, txload 1/255, rxload 1/255
>
> I'd like to be able to pull the numerator fields, in this case 255-1-1.
I'm
> trying to get those fields using the following split calls ($foo is the
> sample line):
>
> split(/[,\/\s]/, $foo);
> split(/[,\/ ]/, $foo);
>
> This produces all empty values. Then if I just try:
>
> split(/[,\/]/, $foo);
>
> I get values in the array, but the average is combined with the numerator
> (e.g. "reliability 255" or "txload 1"). This is fine for display, but I
> need to be able to pull the numerator specifically so that I can compare
it
> to other routers/statistics. Thanks in advance.
This is a good excuse for a matching regex with the 'g' option to assign the
data to an array.
my $foo = 'reliability 255/255, txload 1/255, rxload 1/255';
my @data = $foo =~ m/(\d+)\//g;
The regex should have different delimiters to avoid the 'leaning toothpick
syndrome' ...
my @data = $foo =~ m|(\d+)/|g;
You could also capture two items (key and value) and auto assign them to a
hash...
my %data = $foo =~ m|(\w+) (\d+)/|g; # change the single space to a \s+ if
the space could be more than one, or something other than a literal space.
Then you have the keys being the names 'reliability', 'txload' and 'rxload'
and the corresponding values.
foreach my $key (sort(keys(%data))){
print "$key\t$data{$key}\n";
}
HTH
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Tue, 14 Aug 2001 11:35:54 +1000
From: "Andrew Hamm" <ahamm@sanderson.net.au>
Subject: Re: Multiple field seperators with split()
Message-Id: <3b7880fd@news.iprimus.com.au>
noms wrote in message <9l9srs$6ag$1@bob.news.rcn.net>...
>[SNIPS everywhere]
>Hey everyone, I'm running into problems when parsing some router
>information. This is mainly because I don't know how to setup multiple
>field seperators in split().
>
> reliability 255/255, txload 1/255, rxload 1/255
>
>I'd like to be able to pull the numerator fields, in this case 255-1-1.
I'm
>trying to get those fields using the following split calls ($foo is the
>sample line):
>
Forget split - you job is too complicated for the poor thing. Try a regular
expression:
@nums = $foo =~ m:(\d+)/\d+:g;
\d+ matches one or more digit. Wrapping the first \d+ in ( ) causes the
regular expression engine to grab that value so it may be collected. the
rest of the pattern matches / and another number with \d+
the /g (in this case, :g) at the end of the pattern says to do it "globally"
on the line - ie make as many matches as possible. Finally, since you've
used ( ) capture inside the expression, the m:: returns all the captured
values as a list which we stuff into @nums.
--
Space Corps Directive #003
By joining Star Corps. each individual tacitly consents to give up his
inalienable rights to life, liberty, and adequate toilet facilities.
-- Red Dwarf
------------------------------
Date: Mon, 13 Aug 2001 20:23:40 -0700
From: "Stephen Deken" <shutupsteve@awdang.no.thanks.com>
Subject: Re: small CGI.pm hack, code review request
Message-Id: <tnh6d9eg91hp2f@corp.supernews.com>
gnari wrote:
> try to avoid the quoted-printable when posting plain text to newsgroups.
I knew I was going to get flak for that. I used it because it allows lines
of any length and I didn't want the patch to get messed up. Ah well.
> this is strange. usually you read the cookies into your data structure
> at the start of the request, then you send the header (optionally with
> cookies) , and then the body of the result page. any cookie dependent
> code in that last phase should not be reading the cookies again, but
> should use your data structure
But that uses unnecessary memory, no? I considered that, but since CGI.pm
is already caching the cookies, it seems silly to duplicate the memory. In
this case, it probably doesn't make a difference either way, but it just
seems awkward to have the cookies stored in more than one place, considering
the (short) lifetime of a CGI request.
> why not let CGI do the header (including cookies) for you?
The header is not output all at once. The cookies (if there are any) are
displayed by one part of the script, and the remainder of the header
(Content-type, etc) is output elsewhere. I actually do let CGI output the
Content-type header, but the way I have things set up, it's not possible for
the header to be output all at once (in most cases).
--sjd;
------------------------------
Date: Mon, 13 Aug 2001 21:37:33 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: validate IP address
Message-Id: <comdog-07B691.21373313082001@news.panix.com>
In article <oy_d7.14788$zg6.1395653@news20.bellglobal.com>, "flash"
<bop@mypad.com> wrote:
> but 324156926 is not an ip address, it is one that has been changed into a
> new form.
are you sure? perhaps you have that backwards. ;)
--
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Tue, 14 Aug 2001 02:35:45 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: VIER/NEUN problem
Message-Id: <tnh3k1oivjjia8@corp.supernews.com>
In article <Xns90FCA3C10E077cberrycinenetnet1@207.126.101.92>,
Craig Berry <cberry@cinenet.net> wrote:
: Borrowing a very cool regex from Greg Bacon,
Thanks. I wish it didn't take up so much space.
: and simplifying a great
: deal, [...]
You misspelled 'oversimplifying'. Reread the problem statement.
Greg
--
Ah, women. They make the highs higher and the lows more frequent.
-- Nietzsche
------------------------------
Date: Tue, 14 Aug 2001 01:18:09 GMT
From: "Dale Henderson" <projectobjects@earthlink.net>
Subject: Re: Way to do database read to disk instead of memory?
Message-Id: <l%_d7.7982$Kl2.763776@newsread1.prod.itd.earthlink.net>
I believe there is an example with the AnyData module for just such a
problem, storing an SQL query in a flat file....
"Jane B." <jbcamel@mediaone.net> wrote in message
news:f1231833.0108131206.8d6bd2@posting.google.com...
> Question:
>
> If I run a 'select' statement from Perl that retrieves thousands of
> rows into an array, that data is stored in memory (correct?).
>
> Is there a variable that can be set to tell Perl to store that data
> temporarily on disk?
>
> I need to query two tables, save the data into two arrays and then
> process the data. This is the only way to get the output that I need.
> However I know that I'm going to have memory problems if all the data
> is saved to memory. The database in Informix. I'm running Perl on a
> Unix platform.
>
> Thanks
>
> Jane
>
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
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.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.
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 V10 Issue 1515
***************************************