[23851] in Perl-Users-Digest
Perl-Users Digest, Issue: 6054 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 30 14:06:03 2004
Date: Fri, 30 Jan 2004 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 30 Jan 2004 Volume: 10 Number: 6054
Today's topics:
Array of hashes and strict refs - help! <noel.sant@ntlworld.com>
Re: Array of hashes and strict refs - help! <ittyspam@yahoo.com>
Re: Array of hashes and strict refs - help! <lallip@dishwasher.cs.rpi.edu>
Re: Array of hashes and strict refs - help! <jwillmore@remove.adelphia.net>
Re: Array of hashes and strict refs - help! <usenet@morrow.me.uk>
Re: Can someone tell me what is wrong with this? <ThomasKratz@REMOVEwebCAPS.de>
Re: Can someone tell me what is wrong with this? <dwall@fastmail.fm>
CPAN & Date::Time (check)
Re: CPAN & Date::Time <jwillmore@remove.adelphia.net>
Re: CPAN & Date::Time <usenet@morrow.me.uk>
Re: CPAN & Date::Time <noreply@gunnar.cc>
Re: CPAN & Date::Time <noreply@gunnar.cc>
First-Class Filehandle Trick in 5.8 <scottlm@visi.com>
Re: Freelance PHP/MySQL developer is looking for job (Trent)
Re: how to check for ip address that falls inside a ran (mike)
Re: HTTP::Request format. <no-mail-here@black.hole.com>
Re: HTTP::Request format. <notpublic@restricted.com>
Re: HTTP::Request format. <notpublic@restricted.com>
perl script to exe <javier@t-online.de>
Perl, DBI, localhost problem (Jonas Andersson)
Re: Perl, DBI, localhost problem <ittyspam@yahoo.com>
Re: printing sub results in heredocs <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 30 Jan 2004 16:43:48 -0000
From: "Noel Sant" <noel.sant@ntlworld.com>
Subject: Array of hashes and strict refs - help!
Message-Id: <9RvSb.35789$OA3.12218692@newsfep2-win.server.ntli.net>
When I run my (test) program below, I get the following error:
Can't use string ("file") as a HASH ref while "strict refs" in use at
D:\Houseke
eping\BackupWithZip\Scripts\hashtest.pl line 28, <INPUT_FILE> line 2.
The camel book says this means only hard references are allowed by "use
strict refs", not symbolic ones. But this is more or less what the camel
book (2nd edition) says to do with arrays of hashes (pp268/9). Why is "file"
a symbolic ref? Where am I going wrong?
TIA
Noel
# Work out how to use an array of hashes with strict refs
#
use strict;
my $input_line; my $folder; my $file;
my @array; my %hash;
my $key; my $i;
# Lines in test.txt have two strings: a folder name and a file name,
# separated by spaces
open INPUT_FILE, "test.txt"
or die "Can't open test.txt\n";
while (!eof INPUT_FILE) {
$folder = "";
$file = "";
chomp($input_line = <INPUT_FILE>);
# Lots of checking of input line for double quotes and spaces,
# but with a simple line ("aaa bbb") ...
($folder, $file) = split (/\s+/, $input_line);
%hash = (
folder => $folder,
file => $file,
);
push @array, %hash;
}
%hash = ();
foreach $i (@array) {
for $key (keys %{$array[$i]}) { # <=== line 28
print "$key name is $array[$i]{$key}\n";
}
}
close INPUT_FILE;
------------------------------
Date: Fri, 30 Jan 2004 11:47:51 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Array of hashes and strict refs - help!
Message-Id: <20040130114559.J483@dishwasher.cs.rpi.edu>
On Fri, 30 Jan 2004, Noel Sant wrote:
> When I run my (test) program below, I get the following error:
>
> Can't use string ("file") as a HASH ref while "strict refs" in use at
> D:\Houseke
> eping\BackupWithZip\Scripts\hashtest.pl line 28, <INPUT_FILE> line 2.
>
> The camel book says this means only hard references are allowed by "use
> strict refs", not symbolic ones. But this is more or less what the camel
> book (2nd edition) says to do with arrays of hashes (pp268/9). Why is "file"
> a symbolic ref? Where am I going wrong?
>
> TIA
>
> Noel
>
> # Work out how to use an array of hashes with strict refs
> #
> use strict;
>
> my $input_line; my $folder; my $file;
> my @array; my %hash;
> my $key; my $i;
>
> # Lines in test.txt have two strings: a folder name and a file name,
> # separated by spaces
> open INPUT_FILE, "test.txt"
> or die "Can't open test.txt\n";
> while (!eof INPUT_FILE) {
> $folder = "";
> $file = "";
> chomp($input_line = <INPUT_FILE>);
> # Lots of checking of input line for double quotes and spaces,
> # but with a simple line ("aaa bbb") ...
> ($folder, $file) = split (/\s+/, $input_line);
> %hash = (
> folder => $folder,
> file => $file,
> );
> push @array, %hash;
^^^^^
You can't push a hash into an array. You want to push a reference to that
hash into the array:
push @array, \%hash;
> }
> %hash = ();
> foreach $i (@array) {
> for $key (keys %{$array[$i]}) { # <=== line 28
> print "$key name is $array[$i]{$key}\n";
> }
> }
> close INPUT_FILE;
>
>
>
What was happening is that the original hash was getting flattened, adding
four new elements to the array. One of those elements was the string
"file", which you then tried to use as a hashref in the foreach loop.
Paul Lalli
------------------------------
Date: Fri, 30 Jan 2004 11:55:39 -0500
From: Paul Lalli <lallip@dishwasher.cs.rpi.edu>
Subject: Re: Array of hashes and strict refs - help!
Message-Id: <20040130115344.R483@dishwasher.cs.rpi.edu>
On Fri, 30 Jan 2004, Paul Lalli wrote:
> On Fri, 30 Jan 2004, Noel Sant wrote:
>
> > use strict;
> >
> > my $input_line; my $folder; my $file;
> > my @array; my %hash;
> > my $key; my $i;
> >
> > # Lines in test.txt have two strings: a folder name and a file name,
> > # separated by spaces
> > open INPUT_FILE, "test.txt"
> > or die "Can't open test.txt\n";
> > while (!eof INPUT_FILE) {
> > $folder = "";
> > $file = "";
> > chomp($input_line = <INPUT_FILE>);
> > # Lots of checking of input line for double quotes and spaces,
> > # but with a simple line ("aaa bbb") ...
> > ($folder, $file) = split (/\s+/, $input_line);
> > %hash = (
> > folder => $folder,
> > file => $file,
> > );
> > push @array, %hash;
> ^^^^^
> You can't push a hash into an array. You want to push a reference to that
> hash into the array:
> push @array, \%hash;
>
Actually, looking again, you're changing the contents of %hash each time
through the loop. That's going to cause problems if you keep adding
references to the same variable. Two solutions - change the scope of my
%hash to be within the while loop only, or instead push an anonymous hash
containing the current contents of %hash:
push @array, { %hash };
Paul Lalli
------------------------------
Date: Fri, 30 Jan 2004 12:21:42 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Array of hashes and strict refs - help!
Message-Id: <pan.2004.01.30.17.21.39.975009@remove.adelphia.net>
On Fri, 30 Jan 2004 16:43:48 +0000, Noel Sant wrote:
> When I run my (test) program below, I get the following error:
>
> Can't use string ("file") as a HASH ref while "strict refs" in use at
> D:\Houseke
> eping\BackupWithZip\Scripts\hashtest.pl line 28, <INPUT_FILE> line 2.
>
> The camel book says this means only hard references are allowed by "use
> strict refs", not symbolic ones. But this is more or less what the camel
> book (2nd edition) says to do with arrays of hashes (pp268/9). Why is
> "file" a symbolic ref? Where am I going wrong?
>
> TIA
>
> Noel
>
> # Work out how to use an array of hashes with strict refs #
> use strict;
>
> my $input_line; my $folder; my $file; my @array; my %hash;
> my $key; my $i;
You have declared global variables ... read on :-)
> # Lines in test.txt have two strings: a folder name and a file name, #
> separated by spaces
> open INPUT_FILE, "test.txt"
> or die "Can't open test.txt\n";
> while (!eof INPUT_FILE) {
Go back and re-read the Camel book. You don't need this. A simple
while(<INPUT_FILE>) {
works ;-)
> $folder = "";
> $file = "";
There really isn't a need to do this either. In fact, to make sure the
variables are empty to begin with, you could do something like ...
my $folder = "";
However, when you first declare a variable, it's going to be 'undef'
anyway, so why bother. Better yet, why not declare the variables within
the block instead of outside the block. Right now, they're global. There
really isn't a point in declaring them globally - since they only "live"
within the block.
> chomp($input_line = <INPUT_FILE>);
> # Lots of checking of input line for double quotes and spaces, # but
> with a simple line ("aaa bbb") ...
> ($folder, $file) = split (/\s+/, $input_line); %hash = (
> folder => $folder,
> file => $file,
> );
> push @array, %hash;
The hash is being flattened. If you want an array of hashes, then use a
reference to the hash ...
push @array, \%hash;
> }
> %hash = ();
Now ... why did you do this? During each loop through the the hash, the
hash values are being replaced. And, again, the life of this variable in
within the block, so why declare it globally? Declare it at the top of
the block and each time through the loop, it will get reinitialized.
> foreach $i (@array) {
> for $key (keys %{$array[$i]}) { # <=== line 28
> print "$key name is $array[$i]{$key}\n";
> }
> }
> close INPUT_FILE;
Just a few general comments. Go back and re-read the Camel book. And
also read perlstyle (unless you're newsreader butchered your code :-) ).
Review some of the posts here and see examples of what I was talking
about.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
"To YOU I'm an atheist; to God, I'm the Loyal Opposition." --
Woody Allen
------------------------------
Date: Fri, 30 Jan 2004 17:45:41 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Array of hashes and strict refs - help!
Message-Id: <bve585$2ep$2@wisteria.csv.warwick.ac.uk>
jwillmore@adelphia.net wrote:
> On Fri, 30 Jan 2004 16:43:48 +0000, Noel Sant wrote:
> > ($folder, $file) = split (/\s+/, $input_line); %hash = (
> > folder => $folder,
> > file => $file,
> > );
> > push @array, %hash;
>
> The hash is being flattened. If you want an array of hashes, then use a
> reference to the hash ...
>
> push @array, \%hash;
Or, perhaps more clearly:
($folder, $file) = split ...;
push @array, {
folder => $folder,
file => $file,
};
No need for a temporary %hash at all.
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
- Heraclitus
ben@morrow.me.uk
------------------------------
Date: Fri, 30 Jan 2004 13:36:53 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: Can someone tell me what is wrong with this?
Message-Id: <401a50d2.0@juno.wiesbaden.netsurf.de>
Glenn Jackman wrote:
> Big Swifty <bigswifty00000@yahoo.com> wrote:
>
>> while (@row = $sth->fetchrow_array ) {
>> push (@documents,"$row[0] $row[1] $row[2] ");
>> }
>
> [...]
>
>>>foreach (@documents) {
>>> ($doc_id,$doc_name,$score) = $documents[$counter+0], $documents
>>> [$counter+1], $documents[$counter+2];
>
>
>
> You probably want:
> while (@row = $sth->fetchrow_array) {
> push @documents, [@row];
> }
> ...
> foreach my $rowref (@documents) {
> my ($doc_id,$doc_name,$score) = @$rowref;
> ...
Or even better because you can access the values by name nad DBI does
everything for you as long as the columns are named:
sub select {
...
my $docs = $sth->fetchall_arrayref({});
return($docs);
}
and later
my $selected = select();
foreach my $doc ( @$selected ) {
... do something with $doc->{doc_id}, $doc->{doc_name} and
$doc->{score}
}
It looks so much clearer, than referring to the result by column number,
although it has to be somewhat slower (never benchmarked this, never mattered)
Thomas
--
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</ #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..
------------------------------
Date: Fri, 30 Jan 2004 16:34:13 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Can someone tell me what is wrong with this?
Message-Id: <Xns948075B356566dkwwashere@216.168.3.30>
Big Swifty <bigswifty00000@yahoo.com> wrote:
> "David K. Wall" <dwall@fastmail.fm> wrote in
> news:Xns947FAE44C390Adkwwashere@216.168.3.30:
>
> print $q->checkbox (-name =>$doc_name,-value => "YES", -label =>
> $doc_name);
>>
>> Is that your actual code? There's a space after checkbox and an extra
>> >, so it won't even compile.
>>
>
> I think the > got added from copy/paste but it seems that it works with
> checkbox and space.
Oh, duh. Sorry about that. Bug in *my* test code.
--
David Wall
------------------------------
Date: 30 Jan 2004 08:30:49 -0800
From: check152@hotmail.com (check)
Subject: CPAN & Date::Time
Message-Id: <3703cf5d.0401300830.41b23228@posting.google.com>
Hi,
Can't find anything similar to this problem in these groups, so I'm
hoping someone can help me...
I'm trying to install the Date::Time module and it dependencies via
CPAN.
When I enter:
# perl -MCPAN -e 'install Date::Time'
I get the message:
The module Date::Time isn't available on CPAN.
So, in a CPAN shell I then enter:
i /Date::Time/
...and the module is listed correctly. What am I doing wrong?
TIA,
check.
------------------------------
Date: Fri, 30 Jan 2004 12:22:30 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: CPAN & Date::Time
Message-Id: <pan.2004.01.30.17.22.29.517986@remove.adelphia.net>
On Fri, 30 Jan 2004 08:30:49 -0800, check wrote:
> Hi,
>
> Can't find anything similar to this problem in these groups, so I'm
> hoping someone can help me...
>
> I'm trying to install the Date::Time module and it dependencies via
> CPAN.
>
> When I enter:
>
> # perl -MCPAN -e 'install Date::Time'
>
> I get the message:
>
> The module Date::Time isn't available on CPAN.
>
> So, in a CPAN shell I then enter:
>
> i /Date::Time/
>
> ...and the module is listed correctly. What am I doing wrong?
>
> TIA,
>
> check.
DateTime, instead of Date::Time ... I think ;-)
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Whenever you find that you are on the side of the majority, it is
time to reform. -- Mark Twain
------------------------------
Date: Fri, 30 Jan 2004 17:41:24 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: CPAN & Date::Time
Message-Id: <bve504$2ep$1@wisteria.csv.warwick.ac.uk>
check152@hotmail.com (check) wrote:
> I'm trying to install the Date::Time module and it dependencies via
> CPAN.
>
> When I enter:
>
> # perl -MCPAN -e 'install Date::Time'
>
> I get the message:
>
> The module Date::Time isn't available on CPAN.
>
> So, in a CPAN shell I then enter:
>
> i /Date::Time/
>
> ...and the module is listed correctly. What am I doing wrong?
cpan> i /Date::Time/
Module id = Date::Time
DESCRIPTION Lightweight normalised datetime data type
CPAN_USERID TOBIX (Tobias Brox <tobix@irctos.org>)
CPAN_VERSION undef
CPAN_FILE Contact Author Tobias Brox <tobix@irctos.org>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DSLI_STATUS idpO (idea,developer,perl,object-oriented)
^^^^
INST_FILE (not installed)
So, as it said, the module is not available via CPAN.
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: Fri, 30 Jan 2004 18:57:39 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CPAN & Date::Time
Message-Id: <bve5rb$reeu2$1@ID-184292.news.uni-berlin.de>
Ben Morrow wrote:
> So, as it said, the module is not available via CPAN.
But it can of course be downloaded from CPAN...
http://search.cpan.org/~tobix/OO-DateTime-0.01/
This is the top of the Time.pm file:
package Date::Time::UnixTime;
# Some methods dealing with Unix timestamps are to be
# implemented here.
1;
package Date::Time;
Maybe that explains the failure to download it using CPAN.pm?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 30 Jan 2004 19:10:17 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CPAN & Date::Time
Message-Id: <bve6j3$r0t78$1@ID-184292.news.uni-berlin.de>
Gunnar Hjalmarsson wrote:
> Ben Morrow wrote:
>> So, as it said, the module is not available via CPAN.
>
> But it can of course be downloaded from CPAN...
>
> http://search.cpan.org/~tobix/OO-DateTime-0.01/
On the other hand, the module does not do anything. When it was
uploaded at 2 March 2000, it was said to be "at the idea/design stage"...
So OP should better find some other module, anyway. :)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 30 Jan 2004 18:23:20 GMT
From: Scott McGerik <scottlm@visi.com>
Subject: First-Class Filehandle Trick in 5.8
Message-Id: <401aa118$0$41296$a1866201@newsreader.visi.com>
I am using the First-Class Filehandle Trick, described at
http://perl.plover.com/local.html#3_The_First_Class_Filehandle_Tr.
In a particular program, I had this line:
$INFILE = do { local *FH }; $OUTFILE = do { local *FH };
I then proceed to open $INFILE for reading and $OUTFILE for writing with
unless ( open $INFILE, '<', $infile ) {
and
unless ( open $OUTFILE, '>', $outfile ) {
This worked in 5.6.1, but when I do the same under 5.8.0, I get the
following error message:
Filehandle FH opened only for output at ...
I find this confusing because I thought that
do { local *FH }
would return an unnamed glob. But from the error message, it appears
that it returned the glob for FH.
I looked through the perldelta file, at
http://www.perldoc.com/perl5.8.0/pod/perldelta.html, for 5.8, but I did
not find any hints. Pointers and explanations are appreciated.
Scott McGerik
------------------------------
Date: 30 Jan 2004 04:20:17 -0800
From: spacerook@marx7.org (Trent)
Subject: Re: Freelance PHP/MySQL developer is looking for job
Message-Id: <221fd1f2.0401300420.fe04cbf@posting.google.com>
vorxion@knockingshopofthemind.com (Vorxion) wrote in message news:<4019decc_1@news.iglou.com>...
> In article <rVfSb.6$%W.528@nnrp1.ozemail.com.au>, David VB wrote:
> >Alex C. wrote:
> >
> >> http://www.flitejobs.com/
> >
> >Looks quite nice but you have work to do in the HTML, fixing
> >accessibility issues, using css, etc. I'm guessing you mainly use
> >DreamWeaver - don't - it isn't a tool any professional should use.
>
> CSS is a moving target. Actually, CSS is quite stationary, it's the
> browsers that are lacking. It -pains- me to say it, but IE 5.5 and 6 do
> the best job.
(in Moe Syzlavk voice): Whaaaaaaa?
IE unquestionably has worse CSS support than Mozilla or Opera. IE is
stuck in 2001. The reason your pages don't look right in Mo' or Opera
is that those browsers usually render the pages *correctly*. IE
guesses what you want to do and makes the page look correct, even if
your HTML is malformed out the wazoo. This is NOT good for web
standards.
There are many sites documenting IE's problems. Virtually every CSS
tutorial will have exception clauses that deal with IE's botched
floating and box models. The following page is just one place for
finding IE's deficencies (check out the 'Articles' section):
http://www.positioniseverything.net/
------------------------------
Date: 30 Jan 2004 03:18:47 -0800
From: s99999999s2003@yahoo.com (mike)
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <dfd17ef4.0401300318.3c80b93b@posting.google.com>
Kien Ha <kha@rogers.com> wrote in message news:<RCkSb.6281$ef.5373@twister01.bloor.is.net.cable.rogers.com>...
> mike wrote:
> > hi
> >
> > i need to verify if an ip-address falls inside a range for example,
> > say 10.1.1.1 to 10.1.2.255.
> > So if a user keys in 10.1.2.2, it should fall inside this range and
> > then the program can do something.
> >
> > How can i go about declaring the range, and how can i check the ip
> > whether it falls inside the range. ?
> > thanks.
>
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use IO::Socket qw(inet_aton);
>
>
> my @ip_range = qw{ 10.1.1.1 10.1.2.255 };
> my ($lower, $upper) = map { inet_aton($_) } @ip_range;
>
>
> for ( qw{ 10.1.2.2 10.1.2.10 10.1.3.222 } ) {
> my $packed_ip = inet_aton($_);
> if ( $packed_ip lt $lower or $packed_ip gt $upper ) {
> print "$_ is out of expected range ",
> "$ip_range[0] .. $ip_range[1].\n";
> next;
> }
>
>
> print "$_ is in range.\n";
> }
Thanks for all the tips...appreciate that..
------------------------------
Date: Fri, 30 Jan 2004 10:38:58 +0000
From: Danny Woods <no-mail-here@black.hole.com>
Subject: Re: HTTP::Request format.
Message-Id: <bvdc83$bv1$1@phys-pa.scotland.net>
Ben Morrow wrote:
> Note that if you use LWP::UserAgent to send the request it does all
> this for you.
Thanks, Ben.
I've been using LWP::UserAgent to actually send the request, but was
confusing things by setting up the request object and then using
$request->as_string to examine the request before sending. This shows
something rather different from what the agent actually fires out.
So the problem wasn't really a problem at all...
Thanks again,
Danny.
------------------------------
Date: Fri, 30 Jan 2004 12:51:25 +0100
From: "kz" <notpublic@restricted.com>
Subject: Re: HTTP::Request format.
Message-Id: <eCrSb.4$_n3.5616@news.uswest.net>
> Ben
>
> --
> $.=1;*g=sub{print@_};sub
r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
> $x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub
t{for(@_)
> {$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t #
ben@morrow.me.uk
> $J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.
This is OFPOS.
One Fine Piece Of Signature.
Wow!
Zoltan
------------------------------
Date: Fri, 30 Jan 2004 12:52:15 +0100
From: "kz" <notpublic@restricted.com>
Subject: Re: HTTP::Request format.
Message-Id: <gCrSb.5$_n3.5842@news.uswest.net>
> Ben
>
> --
> $.=1;*g=sub{print@_};sub
r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
> $x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub
t{for(@_)
> {$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t #
ben@morrow.me.uk
> $J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.
This is OFPOS.
One Fine Piece Of Signature.
Wow!
Zoltan
------------------------------
Date: Fri, 30 Jan 2004 19:28:08 +0100
From: "Xaver Biton" <javier@t-online.de>
Subject: perl script to exe
Message-Id: <bve7lk$l03$06$1@news.t-online.com>
Hi,
I'm playing a little bit around, trying to compile some script to exe. Many
of the script are working, but there a bit of code that give me a message
error :
Can't use an undefined value as an ARRAY reference at
PERL2EXE_STORAGE/Win32/TieRegistry.pm line 720.
[CODE]
use Win32::MachineInfo;
my $host = shift || "";
if (Win32::MachineInfo::GetMachineInfo($host, \%info)) {
for $key (sort keys %info) {
print "$key=", $info{$key}, "\n";
}
} else {
print "Error: $^E\n";
}[/CODE]when I run the script with the prel interpreter ActiveState
win32 5.6 work correctly.thks.Xaver
------------------------------
Date: 30 Jan 2004 08:05:28 -0800
From: jonas.andersson@rocketmail.com (Jonas Andersson)
Subject: Perl, DBI, localhost problem
Message-Id: <d2f49f4e.0401300805.1fba64d8@posting.google.com>
Hi
I run Apache and collect info from my local MySQL database through a
Perl-CGI using DBI. Works fine. However, when I try to write a non-CGI
script (hence not using Apache) to access MySQL, I cannot connect to
the database.
I use
my $username="user2"; my $password="(not shown)";
my $data_source="DBI:mysql:MyDatabase:localhost";
$dbh = DBI->connect($data_source, $username, $password) or die "1";
which works fine when CGI:ed. But when I try this for my non-CGI
script, all I get is
DBI connect('MyDatabase:localhost','user2',...) failed: Access denied
for user: 'user2@localhost' to database 'MyDatabase' at newdeal1a.pl
line 165
error connecting
The username and password are obviously correct, and I can see that
this has got something to do with localhost, but I'm afraid I can't
see what. I have searched FAQs and the net, but I can't find any help.
I'd be most grateful for whatever input I can get for this - I'm sure
the problem is trivial.
Thanks a lot, JA
------------------------------
Date: Fri, 30 Jan 2004 11:26:38 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Perl, DBI, localhost problem
Message-Id: <20040130112330.F29989@dishwasher.cs.rpi.edu>
On Fri, 30 Jan 2004, Jonas Andersson wrote:
> Hi
>
> I run Apache and collect info from my local MySQL database through a
> Perl-CGI using DBI. Works fine. However, when I try to write a non-CGI
> script (hence not using Apache) to access MySQL, I cannot connect to
> the database.
>
> I use
>
> my $username="user2"; my $password="(not shown)";
> my $data_source="DBI:mysql:MyDatabase:localhost";
> $dbh = DBI->connect($data_source, $username, $password) or die "1";
>
> which works fine when CGI:ed. But when I try this for my non-CGI
> script, all I get is
>
> DBI connect('MyDatabase:localhost','user2',...) failed: Access denied
> for user: 'user2@localhost' to database 'MyDatabase' at newdeal1a.pl
> line 165
> error connecting
>
> The username and password are obviously correct, and I can see that
> this has got something to do with localhost, but I'm afraid I can't
> see what. I have searched FAQs and the net, but I can't find any help.
> I'd be most grateful for whatever input I can get for this - I'm sure
> the problem is trivial.
>
> Thanks a lot, JA
Are you running the non-CGI script on the same server that the CGI script
is running on? If not, then "localhost" refers to two different machines.
One (the CGI's machine) has permissions to the database, the other does
not. Try changing the datasource to
"DBI:mysql:MyDatabase:machine.domain.com" where "machine.domain.com" is
the name of the server that the CGI script works with.
Paul Lalli
------------------------------
Date: 30 Jan 2004 18:21:02 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: printing sub results in heredocs
Message-Id: <u98yjpguwh.fsf@wcl-l.bham.ac.uk>
Brad Baxter <bmb@ginger.libs.uga.edu> writes:
> On Wed, 28 Jan 2004, Tassilo v. Parseval wrote:
>
> > Also sprach Michele Dondi:
> > > It has not been mentioned yet, so for completeness it may be worth to
> > > let the OP know that, since scalars are interpolated as well (and IMHO
> > > more frequently in actual code than arrays),
> > >
> > > perl -le 'print "There are ${\(1+1)} WTDI!"'
> > > ^^^^^^^^^^^^^^^^^^^^^^^^^
>
> > Only that you shouldn't assume that this always does what you expect
> > (namely providing scalar context because it doesn't):
> >
> > print "${ \localtime }\n";
> > __END__
> > 0
> >
> > Ever since I realized that, I never used ${\CODE} because @{[]} does at
> > least what you would expect.
>
> Interesting ...
>
> sub context {
> print <<"--";
> @_:\tgot @{[wantarray?"list":defined wantarray?"scalar":"null"]}
> --
> ''
> }
> $x = "${\ context 'Expect scalar?' }";
> Expect scalar?: got list
Actually the context you get after a \ operator is not an ordinary
list context. It is a context unlike any other you'll ever see in
Perl.
However in the case simple case of scalar(\func()) &func is in a list
context and then a reference to the last element is the list is
returned.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6054
***************************************