[19596] in Perl-Users-Digest
Perl-Users Digest, Issue: 1791 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 22 09:05:31 2001
Date: Sat, 22 Sep 2001 06:05:08 -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: <1001163907-v10-i1791@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 22 Sep 2001 Volume: 10 Number: 1791
Today's topics:
Re: Best way to hide the perl source code.. <jurgenex@hotmail.com>
Re: Best way to hide the perl source code.. <mikesl@wrq.com>
Re: Best way to hide the perl source code.. <pne-news-20010922@newton.digitalspace.net>
Re: Best way to hide the perl source code.. (Damian Conway)
Connecting to SQL Server (Jimmy)
Re: Connecting to SQL Server <projectobjects@earthlink.net>
Re: converting 20010921 into 21-09-2001 <krahnj@acm.org>
Re: File::Find::name problem... <dtweed@acm.org>
newbie question make from 2 variable fields one with a <discusNOSPAM@wanadoo.nl>
Re: newbie question make from 2 variable fields one wit nobull@mail.com
Re: Peek and Poke on Perl? <gamtci1@mpinet.net>
Perhaps some help for a newbie - uninitialized value... <travis5765@hotmail.com>
Re: Perhaps some help for a newbie - uninitialized valu (Logan Shaw)
Re: Perhaps some help for a newbie - uninitialized valu <travis5765@hotmail.clothes.com>
Re: Perhaps some help for a newbie - uninitialized valu nobull@mail.com
Problems with FetchRow_Hashref (BorisVian)
Re: Problems with FetchRow_Hashref <philip@zaynar.demon.co.uk>
Re: Problems with FetchRow_Hashref <kevin@vaildc.net>
Re: Regular Expresion help needed <pne-news-20010922@newton.digitalspace.net>
Re: Schwartzian Transform problem <tsee@gmx.net>
Re: use of uninitialized value using join (q777)
Re: variables inside patterns? nobull@mail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 21 Sep 2001 22:39:04 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Best way to hide the perl source code..
Message-Id: <3bac23f8@news.microsoft.com>
"Jayakumar Mundunuri" <jkumar@atrenta.com> wrote in message
news:3BABE40D.82225D00@atrenta.com...
> Can you suggest me what is the best way to hide perl source code?
A couple of years ago I read about the WOM in a German computer magazine.
Privacy advocates were thrilled by it, because it's absolutely secure.
Maybe that's an option for you, too.
I think it was in issue #4 of that year, although I don't recall which year.
jue
PS: Oh, before I forget: WOM is the acronym for _W_rite-_O_nly-_M_emory.
------------------------------
Date: Sat, 22 Sep 2001 05:54:53 GMT
From: Michael Slass <mikesl@wrq.com>
Subject: Re: Best way to hide the perl source code..
Message-Id: <m3y9n7rcr7.fsf@thneed.na.wrq.com>
Jayakumar Mundunuri <jkumar@atrenta.com> writes:
>Hi Friends!!
>
>Can you suggest me what is the best way to hide perl source code?
>
>perl Compiler/ perlcc / perl Bite code / encrypt / perl Filter ....
>
>I heard the above names but not really attempted to use them.
>
>It would be great help if anybody guide me with some references.
>
>Thanks in advance.
>
>jay
I just stumbled on this in the perl FAQ
Try:
perldoc -q hide source
,----
| Found in /usr/lib/perl5/5.6.0/pod/perlfaq3.pod
| How can I hide the source for my Perl program?
|
| Delete it. :-) Seriously, there are a number of (mostly
| unsatisfactory) solutions with varying levels of ``security''.
|
| First of all, however, you *can't* take away read permission,
| because the source code has to be readable in order to be
| compiled and interpreted. (That doesn't mean that a CGI script's
| source is readable by people on the web, though, only by people
| with access to the filesystem) So you have to leave the
| permissions at the socially friendly 0755 level.
|
| Some people regard this as a security problem. If your program
| does insecure things, and relies on people not knowing how to
| exploit those insecurities, it is not secure. It is often
| possible for someone to determine the insecure things and
| exploit them without viewing the source. Security through
| obscurity, the name for hiding your bugs instead of fixing them,
| is little security indeed.
|
| You can try using encryption via source filters (Filter::* from
| CPAN), but any decent programmer will be able to decrypt it. You
| can try using the byte code compiler and interpreter described
| below, but the curious might still be able to de-compile it. You
| can try using the native-code compiler described below, but
| crackers might be able to disassemble it. These pose varying
| degrees of difficulty to people wanting to get at your code, but
| none can definitively conceal it (this is true of every
| language, not just Perl).
|
| If you're concerned about people profiting from your code, then
| the bottom line is that nothing but a restrictive license will
| give you legal security. License your software and pepper it
| with threatening statements like ``This is unpublished
| proprietary software of XYZ Corp. Your access to it does not
| give you permission to use it blah blah blah.'' We are not
| lawyers, of course, so you should see a lawyer if you want to be
| sure your license's wording will stand up in court.
`----
-Mike
------------------------------
Date: Sat, 22 Sep 2001 08:01:19 +0200
From: Philip Newton <pne-news-20010922@newton.digitalspace.net>
Subject: Re: Best way to hide the perl source code..
Message-Id: <0g9oqt8rf6epi63m5ksi8j941cvr5k5t55@4ax.com>
On Fri, 21 Sep 2001 18:06:21 -0700, Jayakumar Mundunuri
<jkumar@atrenta.com> wrote:
> Can you suggest me what is the best way to hide perl source code?
It seems no-one has done this yet, so I'll do it:
perldoc -q "hide the source"
Summary: Don't try. Either delete the source, or get a decent licence.
Or try to re-think your question. Why do you think you have a need to
hide the source? If you answer that question, perhaps there will be
other ways to solve the question without having to hide the source.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 22 Sep 2001 06:52:19 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Best way to hide the perl source code..
Message-Id: <9ohcf3$ha2$1@towncrier.cc.monash.edu.au>
Dan Sugalski <dan@tuatha.sidhe.org> writes:
>> That's Acme::Bleach...
>Acme::Buffy would work too. And Acme::DWIM isn't that bad either...
Also Lingua::Romana::Perligata and (by Christmas!) Lingua::thlInganHol::yIghun.
Damian
------------------------------
Date: 21 Sep 2001 23:01:43 -0700
From: jimmyr@softhome.net (Jimmy)
Subject: Connecting to SQL Server
Message-Id: <453c0300.0109212201.2dc35212@posting.google.com>
Anyone knows how to connect to SQL Server 2000 using perl modules?
Thanks!
-Jimmy
www.hostdepartment.com
------------------------------
Date: Sat, 22 Sep 2001 08:14:17 GMT
From: "Dale Henderson" <projectobjects@earthlink.net>
Subject: Re: Connecting to SQL Server
Message-Id: <tLXq7.5881$W83.541783@newsread2.prod.itd.earthlink.net>
DBD::ODBC
"Jimmy" <jimmyr@softhome.net> wrote in message
news:453c0300.0109212201.2dc35212@posting.google.com...
> Anyone knows how to connect to SQL Server 2000 using perl modules?
> Thanks!
>
> -Jimmy
> www.hostdepartment.com
>
------------------------------
Date: Sat, 22 Sep 2001 07:03:48 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: converting 20010921 into 21-09-2001
Message-Id: <3BAC3850.5D33F607@acm.org>
Martin wrote:
>
> There must be an easy way to convert a date string like 20010921 into
> a readable string like 21-09-2001 (european format).
> Please help me out!
printf '%s-%s-%s', reverse( unpack 'a4a2a2', '20010921' );
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 22 Sep 2001 04:42:30 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: File::Find::name problem...
Message-Id: <3BAC1570.13DED34A@acm.org>
Rob wrote:
> find sub {
> printf("%s%s",substr($File::Find::name, 2),"\n")
> if ( -f && /^[0-9]*/ )
> }, ".";
Your regex isn't very selective; it allows anything that starts with
zero or more digits -- in other words, anything at all. Change the *
to a + and maybe add a $ at the end.
Also, you might want to try something like this (untested):
find sub {
# get the last element of the current path
my $dir = (split ('/', $File::Find::dir))[-1];
# print the directory and name if the directory numerically
# matches the last two digits of the name
print "$dir/$_\n" if -f && /^\d+$/ && $dir == substr ($_, -2);
}, ".";
This might actually be more restrictive than you want; for example,
it won't print the names of files that are in the wrong "bucket".
If you want to print all numerical filenames that are in numerical
directories, try this:
find sub {
# get the last element of the current path
my $dir = (split ('/', $File::Find::dir))[-1];
# print the directory and name if both are numeric
print "$dir/$_\n" if -f && /^\d+$/ && $dir =~ /^\d+$/;
}, ".";
Just curious: Do the filenames never end in "00"?
-- Dave Tweed
------------------------------
Date: Sat, 22 Sep 2001 09:36:04 +0200
From: "Walter Soestbergen" <discusNOSPAM@wanadoo.nl>
Subject: newbie question make from 2 variable fields one with a _
Message-Id: <9ohejk$pq9$1@news1.xs4all.nl>
Hello,
I have written a little script that has an input form what asked a
first_name and a last_name.
that is working good but now I want to change someting in the script as
follows:
I am trying to get a new variable filled with the information from
First_name and Last_name but there must be an underscore between it like
First_name_Last_name (output will be Walter_Soestbergen)
What I tryed was the following but it is not working :(
$complete_name = $INPUT{'first_name'}_$INPUT{'last_name'};
what am I doing wrong?
With Regards
Walter Soestbergen
------------------------------
Date: 22 Sep 2001 12:27:00 +0100
From: nobull@mail.com
Subject: Re: newbie question make from 2 variable fields one with a _
Message-Id: <u9wv2r1n5n.fsf@wcl-l.bham.ac.uk>
"Walter Soestbergen" <discusNOSPAM@wanadoo.nl> writes:
> $complete_name = $INPUT{'first_name'}_$INPUT{'last_name'};
>
> what am I doing wrong?
Leaving out the "" surronding an interpolated string. BTW the ''
arround literal hash subcripts are optional when the subcript is a
a word[1] and they are conventionally ommited.
$complete_name = "$INPUT{first_name}_$INPUT{last_name}";
[1] When I say 'word' I mean somthing that matches /\w+/.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sat, 22 Sep 2001 12:45:33 GMT
From: Gary <gamtci1@mpinet.net>
Subject: Re: Peek and Poke on Perl?
Message-Id: <3BAC87B4.381F@mpinet.net>
My (currently) limited knowledge of this tells me adding
embedded C wouldn't solve this problem. Using a direct
memory instruction should raise an exception/memory violation.
It seems to me this code needs to be some sort of "driver" or
registered with the OS in some way to be permitted access to
a fixed address space (or I/O space for that matter).
I hope I'm wrong and you're right.
remove "1" in reply to email
------------------------------
Date: Sat, 22 Sep 2001 00:27:34 -0400
From: root <travis5765@hotmail.com>
Subject: Perhaps some help for a newbie - uninitialized value...
Message-Id: <3BAC1336.365755EC@hotmail.com>
This is a multi-part message in MIME format.
--------------495D85C8E67DB8CE92D872BA
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
First things first.
Linux 2.2.17-21mdksecure
Perl 5.6.1
Ok, this script (perl script attached, assuming the servers allow it.)
is one that i got from the author. I know it works. see it in action at
www.snort.org (attacker ip list at right).
When i run it, i get the following output.
------------------------
Use of uninitialized value in concatenation (.) or string at
./attacked_snort.pl line 75.
Use of uninitialized value in concatenation (.) or string at
./attacked_snort.pl line 75.
Use of uninitialized value in concatenation (.) or string at
./attacked_snort.pl line 75.
Use of uninitialized value in concatenation (.) or string at
./attacked_snort.pl line 75.
Use of uninitialized value in concatenation (.) or string at
./attacked_snort.pl line 75.
Use of uninitialized value in concatenation (.) or string at
./attacked_snort.pl line 75.
Use of uninitialized value in concatenation (.) or string at
./attacked_snort.pl line 75.
Use of uninitialized value in concatenation (.) or string at
./attacked_snort.pl line 75.
Use of uninitialized value in concatenation (.) or string at
./attacked_snort.pl line 75.
------------------------
Now, being a newbie to the perl language i can only debug what i know,
and i know little about perl.
Given my knowlege of other scripting languages, the line listed as
containing an error appears fine to me.
What exactly should i be looking for? (what specificly is an
"uninitialized value"?)
Thanks in advance,
~Travis
--------------495D85C8E67DB8CE92D872BA
Content-Type: application/x-perl;
name="attacked_snort.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="attacked_snort.pl"
#!/usr/bin/perl -w
# attacked_snort.pl - generate some HTML of those that attacked us
#
# Brian Caswell <bmc@snort.org>
#
my %allowed = (
'192.168.0.16' => "Linux1", # An example of a machine allowed
'192.168.0.1' => "Cgf", # to scan us. THESE ARE NOT ON
'192.168.0.25' => "Glendon1", # SNORT.ORG SO DON'T BOTHER!!!
);
my $ids_logserver = "linux1";
my $alert_file = "/var/log/messages";
my $output_html = "/var/www/html/attacked-me.php3";
my $ips_shown = 8;
my @ips;
my @unique_ips;
my %seen = ();
get_attacks($alert_file);
if (scalar(@unique_ips) < $ips_shown) {
get_attacks("$alert_file.1");
if (scalar(@unique_ips) < $ips_shown) {
get_attacks("$alert_file.2");
if (scalar(@unique_ips) < $ips_shown) {
get_attacks("$alert_file.3");
if (scalar(@unique_ips) < $ips_shown) {
get_attacks("$alert_file.4");
}
}
}
}
@ips = reverse @unique_ips;
sub get_attacks {
my ($file) = @_;
if (!(-e $alert_file)) { return; }
my $attacks = `grep \"$ids_logserver snort\" $alert_file`;
my @attackers = split(/\n/, $attacks);
foreach my $temp (@attackers)
{
$temp =~ /(\d+\.\d+\.\d+\.\d+)/;
if ($1 && !$allowed{$1}) { push (@ips,$1); }
}
@unique_ips = grep { ! $seen{$_} ++ } @ips;
}
open (OUT, ">$output_html");
print OUT <<HTML;
<table bgcolor="#000000" CELLPADDING=1 CELLSPACING=0 border="0" width=100%>
<tr><td>
<TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0 ALIGN="center"
BGCOLOR="#006699">
<TR> <TD VALIGN="middle" align=center><B><FONT SIZE=-1 COLOR=#FFFFFF>
Latest hosts that thought scanning an IDS site would go unnoticed
</FONT></B></TD></TR>
</TABLE> </TD></TR>
<tr><td>
<TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0 ALIGN="center"
BGCOLOR="#EEEEEE">
<TR> <TD VALIGN="middle">
<FONT size=-1>
HTML
for (my $i = 0; $i <= $ips_shown; $i++) {
print OUT "<li>$ips[$i]</li>";
}
print OUT <<HTML;
<br><sub> Brought to you by the letter Q</sub>
</font>
</td>
</TR>
</TABLE>
</td></tr></table>
HTML
--------------495D85C8E67DB8CE92D872BA--
------------------------------
Date: 22 Sep 2001 00:30:00 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Perhaps some help for a newbie - uninitialized value...
Message-Id: <9oh7ko$879$1@charity.cs.utexas.edu>
In article <3BAC1336.365755EC@hotmail.com>,
root <travis5765@hotmail.com> wrote:
>Ok, this script (perl script attached, assuming the servers allow it.)
The servers allow it, but actually it's considered bad netiquette to
use MIME (or anything but plain text) on Usenet newsgroups. (The
obvious exceptions are the newsgroups devoted to binary postings.)
Plus, few people have time to read through a 100-line script when
there's really only a few lines you're having trouble with. It's best
to trim the script down to just a few lines that illustrate the problem
and then post just those few lines. (And sometimes you find the answer
to your in the process of doing that trimming...)
>When i run it, i get the following output.
>------------------------
>Use of uninitialized value in concatenation (.) or string at
>./attacked_snort.pl line 75.
Variables are used for storing values. It is, generally speaking, a
good idea to put a value into a variable before you go trying to read
the value out of it. It's not strictly necessary in every case,
but it's considered good practice at the very least.
So, what this message is telling you is that, somewhere on line 75, the
script tries to use the value of a variable before that variable has
been given a value. Perl doesn't just abort the script when you do
this; instead, it substitutes a default value. (You can write a few
test scripts to see what default values if you're curious.) But this
could very easily be not what you want, which is why Perl issues the
warning.
- Logan
--
"Everybody
Loves to see
Justice done
On somebody else" ( Bruce Cockburn, "Justice", 1981 )
------------------------------
Date: Sat, 22 Sep 2001 02:57:39 -0400
From: Technician <travis5765@hotmail.clothes.com>
Subject: Re: Perhaps some help for a newbie - uninitialized value...
Message-Id: <MPG.1616006eb886c187989716@news.megalink.net>
On 22 Sep 2001 00:30:00 -0500, Logan Shaw Decided to grace us with
his/her presance by stating:
> In article <3BAC1336.365755EC@hotmail.com>,
> root <travis5765@hotmail.com> wrote:
> >Ok, this script (perl script attached, assuming the servers allow it.)
>
> The servers allow it, but actually it's considered bad netiquette to
> use MIME (or anything but plain text) on Usenet newsgroups. (The
> obvious exceptions are the newsgroups devoted to binary postings.)
Sorry, i tried to copy and paste it but couldn't get netscape to paste
from a kedit copy so i attached it.
>
> Plus, few people have time to read through a 100-line script when
> there's really only a few lines you're having trouble with. It's best
> to trim the script down to just a few lines that illustrate the problem
> and then post just those few lines. (And sometimes you find the answer
> to your in the process of doing that trimming...)
As i don't really know perl i felt it best to post the entire script.
>
> >When i run it, i get the following output.
> >------------------------
> >Use of uninitialized value in concatenation (.) or string at
> >./attacked_snort.pl line 75.
>
> Variables are used for storing values. It is, generally speaking, a
> good idea to put a value into a variable before you go trying to read
> the value out of it. It's not strictly necessary in every case,
> but it's considered good practice at the very least.
>
> So, what this message is telling you is that, somewhere on line 75, the
> script tries to use the value of a variable before that variable has
> been given a value. Perl doesn't just abort the script when you do
> this; instead, it substitutes a default value. (You can write a few
> test scripts to see what default values if you're curious.) But this
> could very easily be not what you want, which is why Perl issues the
> warning.
>
> - Logan
>
Ok, well lets see.
line 75 "for (my $i = 0; $i <= $ips_shown; $i++) {"
$i is defined and filled in this line. $ips_shown is defined and filled
on line 18 (my $ips_shown = 8;).
It does create the output file (and would probably fill it with ips if
the source log contained any entries that matched the query).
The problem is, i plan to run this via cron (aka Linux scheduling) and
any text outputed by the script (errors, etc...) are automaticly mailed
to the cron owner. if this is run every minute, that would produce 86,400
messages per day. This would be very annoying to say the least.
If i could just get it to run withought any errors, warnings, or any
other text output it would be great.
I have tried removing the line "use strict" but this had no affect.
Oh, i just remembered. lines within {} brackets are read as one line.
So $ips[$i] would have to be uninitialized to give this error. As i
stated, there is currently no entry in the requested log that matches the
query so $ips[$i] is uninitialized at the current moment.
Now, to correct this, i should be able to add a if statment testing if
$ips[$i] is null then set $ips[$i] = "000.000.000.000".
The for statment would then read;
--------------
for (my $i = 0; $i <= $ips_shown; $i++) {
if (!$ips[$i]) {$ips[$i] = "000.000.000.000";}
print OUT "<li>$ips[$i]</li>";
}
--------------
I seem to have solved my own problem i guess.
(well, after you reminded me of a few things :-)
~Travis
--
PGP ID and fingerprint in headers
travis5765@hotmail.clothes.com
ICQ - 25722174
http://www.megalink.net/~farmers/
Comp1 OS: Linux Mandrake 7.2 Server
Comp2 OS: N/A (motherboard is toast)
Gateway OS: Winblows 98SE (sygate 3.11)
To reply direct, remove clothes.
Ask for PGP public Key.
---------
"Well, let's just say, 'if your VCR is still blinking 12:00, you don't
want Linux'".
--- Bruce Perens, Debian's Fearless Leader
------------------------------
Date: 22 Sep 2001 12:22:19 +0100
From: nobull@mail.com
Subject: Re: Perhaps some help for a newbie - uninitialized value...
Message-Id: <u9zo7n1ndg.fsf@wcl-l.bham.ac.uk>
logan@cs.utexas.edu (Logan Shaw) writes:
> In article <3BAC1336.365755EC@hotmail.com>,
> root <travis5765@hotmail.com> wrote:
> >Use of uninitialized value in concatenation (.) or string at
> >./attacked_snort.pl line 75.
>
> So, what this message is telling you is that, somewhere on line 75, the
> script tries to use the value of a variable before that variable has
> been given a value.
Actually this warning message is misworded - that's not what it means!
What you cite is just one possible cause of this message (and may or
may not be what caused it in this case - I've not looked).
What the warning actually means is that the special scalar value
'undefined' is being used in a string context. It may be that thwe
undefined value comes from an uninitialized variable, but it may also
come from the a varialbe that has been explicitly undef()ed or from a
more complex expression.
E.g.
my $foo = "bar". ( 'foo' =~ /f(\d+)?o/ )[0];
Here the so called 'uninitialized value' is the subsring that was
matched by a subpattern that didn't match!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 22 Sep 2001 01:01:52 -0700
From: dmonterrubio@terra.es (BorisVian)
Subject: Problems with FetchRow_Hashref
Message-Id: <fb3ce80.0109220001.15ef11b7@posting.google.com>
Hi,
I'm using a postgresql database and doing :
$sql = "select * from example;";
$sth = $dbh->prepare($sql);
$sth->execute;
$example = $sth->fetchrow_hashref;
When I try to execute, the perl compiler says : Modification on a
read-only value attempted
Can anyone helps me?
Thanks
------------------------------
Date: Sat, 22 Sep 2001 10:01:08 +0100
From: Philip Taylor <philip@zaynar.demon.co.uk>
Subject: Re: Problems with FetchRow_Hashref
Message-Id: <+HKhrGAUNFr7Ew7F@zaynar.demon.co.uk>
In article <fb3ce80.0109220001.15ef11b7@posting.google.com>, BorisVian
<dmonterrubio@terra.es> writes
>Hi,
>
>I'm using a postgresql database and doing :
> $sql = "select * from example;";
> $sth = $dbh->prepare($sql);
> $sth->execute;
>
> $example = $sth->fetchrow_hashref;
>
>When I try to execute, the perl compiler says : Modification on a
>read-only value attempted
>
>Can anyone helps me?
>
>Thanks
I don't know about postgresql, but in MySQL you'd have to replcae
"select * from example;" with "select * from example" -- the semicolon
at the end would probably cause an SQL error.
But if this doesn't fix anything, it would help to say exactly which
line the error is referring to -- I can't see anything obviously wrong,
although that doesn't mean there *isn't* something obviously wrong :-)
--
Philip Taylor
philip @ zaynar . demon . co . uk
http://robowarriors.ultrastore.com/legoworld.shtml
-- If the Earth was made of Lego...
------------------------------
Date: Sat, 22 Sep 2001 08:54:35 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: Problems with FetchRow_Hashref
Message-Id: <220920010854355597%kevin@vaildc.net>
In article <fb3ce80.0109220001.15ef11b7@posting.google.com>, BorisVian
<dmonterrubio@terra.es> wrote:
> Hi,
>
> I'm using a postgresql database and doing :
> $sql = "select * from example;";
> $sth = $dbh->prepare($sql);
> $sth->execute;
>
> $example = $sth->fetchrow_hashref;
>
> When I try to execute, the perl compiler says : Modification on a
> read-only value attempted
It should also have given you a line number. What's on that line?
> Can anyone helps me?
The code you posted doesn't have anything that would cause this error,
so you need to post a larger fragment. Be sure to copy-and-paste
rather than re-type it, and include the line the error message refers
to.
(And, as another poster has pointed out, drop the semicolon inside the
quotes on the first line of your posted code. It doesn't have anything
to do with this error, but it will cause problems later.)
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)
------------------------------
Date: Sat, 22 Sep 2001 07:38:46 +0200
From: Philip Newton <pne-news-20010922@newton.digitalspace.net>
Subject: Re: Regular Expresion help needed
Message-Id: <nd7oqtk252u28abi4rnt7tfb326bgeerv4@4ax.com>
On Fri, 21 Sep 2001 04:00:37 GMT, Dave Tweed <dtweed@acm.org> wrote:
> If ranges don't follow the ASCII sequence for characters from \0 to \177,
> I would consider them to be broken in a major way.
I take it you've never worked on an EBCDIC machine, then? :)
Well, neither have I, but Perl runs on OS/390, which uses EBCDIC as its
native character set. One of the effects, for example, is that ord('A')
> ord('a'), while with ASCII, the opposite is true. Similarly, ranges
will probably not work the way you expect since the order of characters
is different.
(There are also gaps in the letters, but I believe perl works around
that; if you specify [a-z] you get only lowercase letters and not
everything between ord('a') and ord('z'), inclusive.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sat, 22 Sep 2001 12:26:46 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Schwartzian Transform problem
Message-Id: <9ohop3$98l$06$1@news.t-online.com>
"Bart Lateur" <bart.lateur@skynet.be> schrieb im Newsbeitrag
news:dnbnqt41r2l3b5pssk1i3p2m79ujfkfuml@4ax.com...
> As Anno said: Randal's post might simply not have appeared in Michael's
> newsfeed. I rarely ever see a post from M.J. Dominus. I don't know why.
You really do miss some good posts then ;)
Fortunately, I don't seem to have any problems at all. Just that there
haven't been a lot of Godzilla-isms around in a while - umm, that's not a
problem, it's a feature!
Steffen
------------------------------
Date: 21 Sep 2001 22:20:28 -0700
From: quang777@email.com (q777)
Subject: Re: use of uninitialized value using join
Message-Id: <9f14310.0109212120.1b145c10@posting.google.com>
Bart Lateur <bart.lateur@skynet.be> wrote in message news:<rornqt8klreqhau0mihcj1mp256n6dndio@4ax.com>...
> q777 wrote:
>
> >my @array = ();
> >my $string = join /\n/, @array;
> >
> >why does this give the "Use of uninitialized value" error?
>
> Because you're joining using a regex instead of a plain string, which
> does matching on $_, which in turn is undefined?
Duh. Thanks. Forgot about the $_ default behavior.
Quang
------------------------------
Date: 22 Sep 2001 12:07:21 +0100
From: nobull@mail.com
Subject: Re: variables inside patterns?
Message-Id: <u93d5f32mu.fsf@wcl-l.bham.ac.uk>
bowen@cs.toronto.edu (bowen hui) writes:
> i was wondering if anyone knows how i might be able to use variables
> when i'm pattern matching?
Variables interpolate into regular expressions just like they do into
any qouted construct.
>i tried the obvious, which is something like:
>
> $verb = "run|swim|walk";
> if( $input =~ /he $verb/ )
The varaible interpolation takes place on the string representation of
the regex before it is parsed. This means that the above is
equivalent to
if( $input =~ /he run|swim|walk/ )
I supsuct you were subconciously assuming that the variable
interpolation occured at a later stage and hense believing that it
would be equivalent to:
if( $input =~ /he (?:run|swim|walk)/ )
> i tried to capture a word and then check it against an array instead:
>
> $verb ...
> @VERB = split /\|/, $verb;
> if( $input =~ /he ([a-zA-Z]+)/ )
> ...
>
> and then check to see that whatever i captured matches something inside
> the array. this doesn't seem the most direct solution... does anyone know
> of a better solution?
This is the conventional solution except that you should use a key-only
hash rather then an array.
my %verb;
@verb{split /\|/, $verb} = ();
if( $input =~ /he ([a-zA-Z]+)/ && exists $verb{$1} )
--
\\ ( )
. _\\__[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.
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 1791
***************************************