[23617] in Perl-Users-Digest
Perl-Users Digest, Issue: 5824 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 18 18:05:44 2003
Date: Tue, 18 Nov 2003 15:05:10 -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 Tue, 18 Nov 2003 Volume: 10 Number: 5824
Today's topics:
Re: "yield" doesnt work <usenet@morrow.me.uk>
Arrays / Hashes / LoLs -- Building a data store (Ben B)
Re: Arrays / Hashes / LoLs -- Building a data store <noreply@gunnar.cc>
Re: Arrays / Hashes / LoLs -- Building a data store <raisin@delete-this-trash.mts.net>
Re: Arrays / Hashes / LoLs -- Building a data store <emschwar@pobox.com>
Re: bit sequence match (Jay Tilton)
Re: comments on JAPH? <bik.mido@tiscalinet.it>
Re: comments on JAPH? <ThomasKratz@REMOVEwebCAPS.de>
Re: Find::File and taint mode <usenet@morrow.me.uk>
Re: Find::File and taint mode <dave.nospam@ntlworld.com>
Re: Find::File and taint mode <dave.nospam@ntlworld.com>
Re: How can I append todays date to the file name? (JR)
Match and cut regex? <bryan@akanta.com>
Re: Match and cut regex? <noreply@gunnar.cc>
Re: Match and cut regex? (Peter J. Acklam)
Re: Multiplication not commutitive in Perl? <asu1@c-o-r-n-e-l-l.edu>
Re: Multiplication not commutitive in Perl? <kkeller-usenet@wombat.san-francisco.ca.us>
perl LibXML (trevor)
Re: Perl sendmail going to spam folders? <noreply@gunnar.cc>
Re: Program that prints its source code <usenet@morrow.me.uk>
Re: Program that prints its source code <usenet@dwall.fastmail.fm>
SOAP::Lite versus DBI <kirk@strauser.com>
Re: where is DBI::DWIM? (Bill)
Re: where is DBI::DWIM? <pm@katz.cc.univie.ac.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 18 Nov 2003 20:29:17 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: "yield" doesnt work
Message-Id: <bpdvet$a9u$1@wisteria.csv.warwick.ac.uk>
sangeetha_b@india.com (sangeetha) wrote:
> Yesterday, i have started reading thread model programming in perl. (
> using Programming PERL
Perl
> by Larry wall,
Wall
> Tom, Jon
...whom I believe also have surnames... :)
> ). The following
> programming has been given to explain the LOCK CONCEPT and given that
> output of this program is "2". But, i'm getting "0" only. Any help y
> it is?
>
> I'm using "v5.8.0 built for i386-linux-thread-multi" version of perl.
>
> ##############################################
> use Thread qw/async yield/;
Thread.pm is obsolete with 5.8. The new thread model uses threads.pm,
and by default variables are *not* shared between threads: for this
you need to use threads::shared. The stuff in the Camel about
threading refers to the old, 5.005, thread model; most of the
specifics have changed.
> If my understanding is wrong please explain. What is the exact use of
> "yield" in the thread model programming. Thanks a lot.
As a second point, using yield guarantees you *nothing* about the
order threads will run in. It is entirely possible for one thread to
run all the way to completion (even if it uses yield) before the other
has started. If you need to synchronise, you must use lock and the
cond_wait etc. primitives. (Basically, under any decent timesharing OS
yield is precisely useless: mltitasking will happen properly without
it, and putting it in won't materially affect how it happens. Its use
is on broken systems like Win98 which don't preemptively multitask and
need prodding every now and then to give someone else a chance at a
bit of CPU.)
Ben
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
------------------------------
Date: 18 Nov 2003 13:36:48 -0800
From: google@dotinf.co.uk (Ben B)
Subject: Arrays / Hashes / LoLs -- Building a data store
Message-Id: <7881e289.0311181336.606314d2@posting.google.com>
All
I need to build something to store data. In its original form the
data looks like this --
Title File Level Content
---------------------------------------------------------------
"Home" "index.htm" 4 "Home Page"
"News" "news.htm" 1 "Welcome to the news"
"Contact" "id.htm" 3 "Contact me at..."
I have trawled Google and can't find the right structure for this data
-- a Hash, an Array, a List of Lists or so on -- I do know that Perl
does not have a true multi-dimensional array. I need to be able to
reference the line by the Title.
I am happy capturing each data element and dealing with it by chopping
up lines and elements, but what should I use to store this data, and
then reference it?
Any help appreciated -- I'd like an explanation, and suggestions,
rather than someone coding this for me out of the goodness of their
heart.
Regards
Ben
------------------------------
Date: Tue, 18 Nov 2003 23:09:29 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Arrays / Hashes / LoLs -- Building a data store
Message-Id: <bpe5ke$1n98im$1@ID-184292.news.uni-berlin.de>
Ben B wrote:
> I need to build something to store data. In its original form the
> data looks like this --
>
> Title File Level Content
> ---------------------------------------------------------------
> "Home" "index.htm" 4 "Home Page"
> "News" "news.htm" 1 "Welcome to the news"
> "Contact" "id.htm" 3 "Contact me at..."
>
> I need to be able to reference the line by the Title.
It sounds like you want a hash, with the titles as keys.
> I am happy capturing each data element and dealing with it by
> chopping up lines and elements, but what should I use to store this
> data, and then reference it?
Some thoughts follow:
One option is a one dimensional hash:
$hash{Home} = "index.htm\t4\tHome Page";
in which case you would need to split the value to access an
individual field.
Another option is a hash of arrays:
$hash{Home} = [ 'index.htm', 4, 'Home Page' ];
That way you would be able to access e.g. the content of the "Home"
record this way:
print $hash{Home}[2];
The first suggestion would make it possible to store the hash in a DBM
file, which is a simple but effective method.
The other suggestion would require some more sophisticated storage
method, and using the Storable module might be appropriate.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 18 Nov 2003 16:27:12 -0600
From: Master Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Re: Arrays / Hashes / LoLs -- Building a data store
Message-Id: <MPG.1a2458b6fafc53c59896d7@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <7881e289.0311181336.606314d2@posting.google.com>,
google@dotinf.co.uk says...
> All
>
> I need to build something to store data. In its original form the
> data looks like this --
>
> Title File Level Content
> ---------------------------------------------------------------
> "Home" "index.htm" 4 "Home Page"
> "News" "news.htm" 1 "Welcome to the news"
> "Contact" "id.htm" 3 "Contact me at..."
>
> I have trawled Google and can't find the right structure for this data
> -- a Hash, an Array, a List of Lists or so on -- I do know that Perl
> does not have a true multi-dimensional array. I need to be able to
> reference the line by the Title.
>
> I am happy capturing each data element and dealing with it by chopping
> up lines and elements, but what should I use to store this data, and
> then reference it?
>
> Any help appreciated -- I'd like an explanation, and suggestions,
> rather than someone coding this for me out of the goodness of their
> heart.
>
> Regards
>
> Ben
>
The following code (tested under Win XP , perl 5.8.0) should point you
in the right direction.
#!/usr/bin/perl -w
# Title File Level Content
# ---------------------------------------------------------------
#
# "Home" "index.htm" 4 "Home Page"
# "News" "news.htm" 1 "Welcome to the news"
# "Contact" "id.htm" 3 "Contact me at..."
@array = ();
push @array, [ "Home" , "index.htm" , 4 , "Home Page"];
push @array, [ "News" , "news.htm" , 1 , "Welcome to the news"];
push @array, [ "Contact" , "id.htm" , 3 , "Home Page"];
print "Title File Level Content\n";
for ( $i = 0 ; $i <= $#array ; ++$i ) {
printf "%-14s %-13s %-11d %s\n",$array[$i][0],$array[$i][1],$array
[$i][2],$array[$i][3];
}
exit 0;
------------------------------
Date: Tue, 18 Nov 2003 15:28:17 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Arrays / Hashes / LoLs -- Building a data store
Message-Id: <eto65hhgvlq.fsf@fc.hp.com>
google@dotinf.co.uk (Ben B) writes:
> I need to build something to store data. In its original form the
> data looks like this --
>
> Title File Level Content
> ---------------------------------------------------------------
> "Home" "index.htm" 4 "Home Page"
> "News" "news.htm" 1 "Welcome to the news"
> "Contact" "id.htm" 3 "Contact me at..."
>
> I have trawled Google and can't find the right structure for this data
> -- a Hash, an Array, a List of Lists or so on -- I do know that Perl
> does not have a true multi-dimensional array. I need to be able to
> reference the line by the Title.
Seems like you want a Hash of Hashes, then:
my %hoh = ( "Home" => { File => "index.htm",
Level => 4,
Content => "Home Page" },
"News" => { File => "news.htm",
Level => 1,
Content => "Welcome to the news" },
.... );
# get the Level of the "Home" line:
my $level = $hoh{"Home"}{"Level"}
# what's the Content of the News line?
my $content = $hoh{"News"}{"Content"}
> I am happy capturing each data element and dealing with it by chopping
> up lines and elements, but what should I use to store this data, and
> then reference it?
See above. To construct it, you'd loop over the data something like:
my %hoh = ();
while(<FILE>) {
my @fields = split;
$hoh{$fields[0]} = { File => $fields[1], Level => $fields[2],
Content => $fields[3] };
}
(untested, quite possibly buggy, and no attempt at error handling made)
> Any help appreciated -- I'd like an explanation, and suggestions,
> rather than someone coding this for me out of the goodness of their
> heart.
Spend some time with 'perldoc perlref'; it should explain whatever I missed.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Tue, 18 Nov 2003 22:47:03 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: bit sequence match
Message-Id: <3fba5adc.74203413@news.erols.com>
Several copies of each of your articles are being propagated, often
under several different names. One article and one name are quite
sufficient. _Please_ get this posting problem under control.
Edo <Edoallday@yahoo.com> wrote:
: Jay Tilton wrote:
: > Edo <edady2002@yahoo.com> wrote:
: >
: > : my @k1 = sort {$a <=> $b} keys %h1;
: > : my @k2 = sort {$a <=> $b} keys %h2;
: > :
: > : my $look_for = pack('(B2)*' => @h1{ @k1 });
: > : my $look_in = pack('(B2)*' => @h2{ @k2 });
[Snip query on why the pack template was changed. It's kosher.]
: > : #why can't we replace the above 2 lines with
: > : my $lookfor = join "", @h1{ @k1 };
: > : my $lookin = join "", @h2{ @k2 };
: > : #don't these do the same thing?
: >
: > Not even close. Do the values look at all similar when you print them?
:
: no they do not look similar but that does not matter, isn't the whole
: idea behind pack is to create a string from the array, and as long as
: the string in $look_for and $look_in are the same "string coding" thats
: all what matters?
The purpose of the match operation is not only to determine if a match
exists, but to determine the position of that match. Because one
element in @k2 or @k1 corresponds to one character (more accurately, one
octet) in the created strings, the position of the match tells exactly
where in @k2 to start extracting values.
The task could be done with simple concatenation, but the match
operation will no longer tell where in @k2 to start extracting. On the
other hand, if all of the concatenated values have the same length, the
match position could be divided by that length.
As well, simple concatenation can cause false positive matches. If, for
example, you want to know if "foo" and "bar" occur in an array that
contains "foobar" it will find a match when it should not. Choosing a
joining string that cannot occur in the values would prevent that.
: > : my @results;
: > : while( $lookin =~ /(?=\Q$lookfor\E)/g ) {
: > : push @results,
: > : {
: > : map { $_ => $h2{$_} }
: > : @k2[ $-[0] .. $-[0]+@k1-1 ]
: > : };
: > : }
: > :
: > : and could you place explain
: > : map { $_ => $h2{$_} }
: > : @k2[ $-[0] .. $-[0]+@k1-1 ]
: >
: > Not this time. This time we do it differently.
: >
: > You give me your best explanation of the code, then, if the explanation
: > is mistaken, I will tell you what the mistakes are.
:
: ok.. here we go
[snip false start]
: oh.. it returns a list which is a section of @k2[last-item-matched to
: last-item-matched + how many items in the @k1]
^^^^^^^^^^^^^^^^^^^^^^^^^
One less than the number of items in @k1. Google for a copy of "The
Jargon File" and see the entry for "fencepost error."
(Somewhat related, some people would rather have "$#k1" instead of
"@k1-1". There was debate a few months ago on which is more correct,
but I don't think the issue was resolved.)
: which in this case
: suppose to return @k2[number number+1 number+2...number+5-1].
: now that we have that section off @k2, we evaluate the block { $_ =>
: $h2{$_}} to each element of that list, hummmm. ok
: setting each element of the list to $_ then ... gave up.
You're almost there, dude. You've got it right so far.
The map returns a list containing key/value pairs from %h2 for each
value in the array slice.
The curly brackets enclosing the entire map function create an anonymous
hash from that list, and a reference to that anonymous hash is pushed
onto @results.
: the Dumper puts
: $VAR1 = {
: '22' => '00',
: '21' => '01',
: '24' => '11',
: '23' => '10',
: '41' => '11'
: };
: $VAR2 = {
: '119' => '10',
: '112' => '00',
: '120' => '11',
: '111' => '01',
: '121' => '11'
: };
: $VAR3 = '
: ';
That $VAR3 is troubling. It doesn't belong at all. Is it there because
of a mistake in the Dumper() call? E.g.
print Dumper( @results, "\n" );
: who can I have the results sored by keys in each hash?
If you want them sorted in the Data::Dumper output, set
$Data::Dumper::Sortkeys to a true value. Controlling that and other
aspects of the output are described in the Data::Dumper documentation.
------------------------------
Date: Tue, 18 Nov 2003 20:14:12 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: comments on JAPH?
Message-Id: <enfirvk2n0dftmde1eo67kkdi5tmuhu8ba@4ax.com>
On Mon, 17 Nov 2003 14:21:04 +0100, Thomas Kratz
<ThomasKratz@REMOVEwebCAPS.de> wrote:
>below my first attempt for a JAPH. It's not that obfuscated, but I had
>a tough time pressing it into 4 lines.
>
>Comments anyone?
My first comments, modulo the fact that I didn't even try (yet) to
understand what it does due to absymal lack of time, are:
(i) it doesn't work, for the following meaning of "doesn't work": it
prints "J" and then exits!
(ii) I see the following piece of code:
open STDIN,"<&DATA";# rest of line snipped
and that there's an __END__ token. Isn't it that you're maybe trying
to do something like '*ARGV=DATA'?
Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
------------------------------
Date: Tue, 18 Nov 2003 20:56:00 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: comments on JAPH?
Message-Id: <3fba7a00.0@juno.wiesbaden.netsurf.de>
Michele Dondi wrote:
>
> My first comments, modulo the fact that I didn't even try (yet) to
> understand what it does due to absymal lack of time, are:
>
> (i) it doesn't work, for the following meaning of "doesn't work": it
> prints "J" and then exits!
That's because you are on Win* are you? It will work when you
change the 14 in the first line to 15.
To have this working on all platforms I'll have to find out how many bytes
are written for a newline. length("\n") will always return 1 for all
platforms.
>
> (ii) I see the following piece of code:
>
> open STDIN,"<&DATA";# rest of line snipped
>
> and that there's an __END__ token. Isn't it that you're maybe trying
> to do something like '*ARGV=DATA'?
More like '*STDIN=DATA'. It is just to be able to say getc instead of
getc(DATA).
Using ARGV would be an alternative (and the above problem would vanish).
I just found out that you can't paste the lines via STDIN (always tested
with a file :-( ). The DATA filehandle seems to be missing. I have to look
that up.
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: Tue, 18 Nov 2003 20:32:04 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Find::File and taint mode
Message-Id: <bpdvk4$a9u$2@wisteria.csv.warwick.ac.uk>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Dave Saville wrote:
> > I have a cgi script that uses File::Find.
> >
> > find(\&wanted, 'D:/Apps/SouthSide/PMMail');
> >
> > I am getting:
> >
> > Insecure dependency in chdir while running with -T switch at
> > D:/usr/lib/perl/lib
> > /5.8.0/File/Find.pm line 807.
> >
> > How can I get around this?
>
> By using the 'untaint' option. See the File::Find docs.
You could also use the 'no_chdir' option, which may or may not be
safer...
Ben
--
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/' # ben@morrow.me.uk
------------------------------
Date: Tue, 18 Nov 2003 22:37:53 +0000 (GMT)
From: "Dave Saville" <dave.nospam@ntlworld.com>
Subject: Re: Find::File and taint mode
Message-Id: <qnirfnivyyragyjbeyqpbz.hoky351.pminews@text.news.ntlworld.com>
On Tue, 18 Nov 2003 20:32:04 +0000 (UTC), Ben Morrow wrote:
>
>Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> Dave Saville wrote:
>> > I have a cgi script that uses File::Find.
>> >
>> > find(\&wanted, 'D:/Apps/SouthSide/PMMail');
>> >
>> > I am getting:
>> >
>> > Insecure dependency in chdir while running with -T switch at
>> > D:/usr/lib/perl/lib
>> > /5.8.0/File/Find.pm line 807.
>> >
>> > How can I get around this?
>>
>> By using the 'untaint' option. See the File::Find docs.
>
>You could also use the 'no_chdir' option, which may or may not be
>safer...
Thanks - but File: Find is so S L O W I am going to have to rethink it
anyway.
Regards
Dave Saville
NB switch saville for nospam in address
------------------------------
Date: Tue, 18 Nov 2003 22:39:27 +0000 (GMT)
From: "Dave Saville" <dave.nospam@ntlworld.com>
Subject: Re: Find::File and taint mode
Message-Id: <qnirfnivyyragyjbeyqpbz.hoky5r2.pminews@text.news.ntlworld.com>
On Tue, 18 Nov 2003 20:32:04 +0000 (UTC), Ben Morrow wrote:
>
>Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>> Dave Saville wrote:
>> > I have a cgi script that uses File::Find.
>> >
>> > find(\&wanted, 'D:/Apps/SouthSide/PMMail');
>> >
>> > I am getting:
>> >
>> > Insecure dependency in chdir while running with -T switch at
>> > D:/usr/lib/perl/lib
>> > /5.8.0/File/Find.pm line 807.
>> >
>> > How can I get around this?
>>
>> By using the 'untaint' option. See the File::Find docs.
What I don't understand is why perl thinks it is tainted - all I am
passing is a quoted string.
Regards
Dave Saville
NB switch saville for nospam in address
------------------------------
Date: 18 Nov 2003 14:40:09 -0800
From: jrolandumuc@yahoo.com (JR)
Subject: Re: How can I append todays date to the file name?
Message-Id: <b386d54b.0311181440.3fe7db2b@posting.google.com>
LinuxTeam@yahoo.com (Dariush) wrote in message news:<d83f36a4.0311180715.5f89eb1f@posting.google.com>...
> Hello every one.
>
> I'm no expert at perl.
>
> I would like to append todays date to the file name
>
> I have many files that arrive daily
>
> filename.pdf and so on
>
> How can I rename the files to
>
> filename_DDMMYY.pdf
>
> so the output would be
>
> filename_18112003.pdf
>
> thank you all.
This should get you started. If your files are going to be located in
in a directory that has no subdirectories, you won't or may not need
to use the File::Find module. I hope this helps.
#!/perl
use strict;
use warnings;
use File::Find;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime (time);
$year+=1900;
$mon+=1;
my $date = "$mday$mon$year";
sub wanted {
if (-f) {
my($name, $ext) = split /\./, $_, 2;
rename $_, "$name".'_'."$date.$ext";
}
}
my $dir = 'C:/files'; # modify here as needed
&find(\&wanted, $dir);
------------------------------
Date: Tue, 18 Nov 2003 22:26:23 GMT
From: Bryan <bryan@akanta.com>
Subject: Match and cut regex?
Message-Id: <j0xub.6699$9q7.54480104@newssvr21.news.prodigy.com>
If I have a 'cut' phrase:
my $cut = "ABBCCCD";
and a 'sentence':
my $sentence = "ALSSDJOOASABBCCCDUUSIIASDLLLPP";
What regex do I use to match the ABBCCCD and then chop off everything
after it?
Thanks,
B
------------------------------
Date: Tue, 18 Nov 2003 23:31:23 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Match and cut regex?
Message-Id: <bpe6ti$1o0ur4$1@ID-184292.news.uni-berlin.de>
Bryan wrote:
> If I have a 'cut' phrase:
> my $cut = "ABBCCCD";
>
> and a 'sentence':
> my $sentence = "ALSSDJOOASABBCCCDUUSIIASDLLLPP";
>
> What regex do I use to match the ABBCCCD and then chop off
> everything after it?
One way:
($sentence) = $sentence =~ /(.*$cut)/;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 18 Nov 2003 23:37:11 +0100
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: Match and cut regex?
Message-Id: <vfphi9rc.fsf@online.no>
Bryan <bryan@akanta.com> wrote:
> If I have a 'cut' phrase:
> my $cut = "ABBCCCD";
>
> and a 'sentence':
> my $sentence = "ALSSDJOOASABBCCCDUUSIIASDLLLPP";
>
> What regex do I use to match the ABBCCCD and then chop off
> everything after it?
Use "index" to find the location and "substr" to do the chopping.
perldoc -f index
perldoc -f substr
Peter
--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
------------------------------
Date: 18 Nov 2003 19:57:44 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Multiplication not commutitive in Perl?
Message-Id: <Xns9437983648B2Dasu1cornelledu@132.236.56.8>
Marshall Dudley <mdudley@execonn.com> wrote in
news:3FBA4E29.F84183A7@execonn.com:
> Opps, you are right. I had a $ missing from the user4 in the one that
> was not working. Odd, I would have expected a compiler error with
> that. I can't believe how many times I can look at something yet miss
> something as obvious as that. :<
Do not top post.
Do read the posting guidelines for this group (especially the bits about
copying and pasting rather than retyping and not asking people to do the
work of a machine).
Do search for the guidelines using google rather than complaining about
not having seen them before.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Tue, 18 Nov 2003 11:57:25 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Multiplication not commutitive in Perl?
Message-Id: <5jtdpb.66p.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2003-11-18, Marshall Dudley <mdudley@execonn.com> wrote:
> Opps, you are right. I had a $ missing from the user4 in the one that was
> not working.
All the more reason not to retype code, but to cut and paste, when
posting a problem.
> Odd, I would have expected a compiler error with that.
use strict;
use warnings;
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/unmjhVcNCxZ5ID8RAlb4AJ98opg3NoiI/DwaFb1QnrIT/X9e4wCgjWN5
666vSdHcf/RfQZTLXKY3i+Y=
=VAjG
-----END PGP SIGNATURE-----
------------------------------
Date: 18 Nov 2003 13:02:01 -0800
From: trevor_obba@yahoo.co.uk (trevor)
Subject: perl LibXML
Message-Id: <59615909.0311181302.67f34fd0@posting.google.com>
I installed the following perl module with my perl version 5.8.0
libxml2-2.6.2
XML-SAX-0.12
XML-NamespaceSupport-1.08
XML-LibXML-1.56
XML-LibXSLT-1.53
XML-LibXML-Common-0.13
the installation went fine. but when I run a cgi that uses the perl
module I get the following error messages in my apache error_log files
error log:
Warning: program compiled against libxml 206 using older 204
[Tue Nov 18 16:40:18 2003] [error] [client 170.75.98.82] Premature
end of
script headers: /exlibris/aleph/a50_5/aleph/cgi/do_bor_trans.cgi
------------------------------
Date: Tue, 18 Nov 2003 20:25:26 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl sendmail going to spam folders?
Message-Id: <bpds0n$1o3orc$1@ID-184292.news.uni-berlin.de>
Duke of Hazard wrote:
> I am using sendmail in a perl script to send a message to the email
> address provided in a web form. The problem is that this message
> always end up in the person's spam/bulk folder. I don't know what
> it is about the sendmail that makes yahoo think it is spam.
It has probably nothing to do with sendmail, even less with Perl, btw
(this is a Perl group), but rather with the source of the message.
You'd better ask that "the person" tries to find out the criteria used
for guessing that it's spam.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 18 Nov 2003 20:36:56 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Program that prints its source code
Message-Id: <bpdvt8$a9u$3@wisteria.csv.warwick.ac.uk>
"David K. Wall" <usenet@dwall.fastmail.fm> wrote:
> If I want a program to print its own source code, is there any reason
> to prefer one of these code snippets over the other? Or is there an
> even better way to do it?
>
> Snippet 1:
>
> seek DATA, 0, 0;
> print <DATA>;
> __DATA__
>
>
> Snippet 2:
>
> open SELF, $0 or die "Error opening self for reading";
> print <SELF>;
I would prefer the first, just because I always prefer to use a handle
I've got on the file rather than open another... also, I believe $0 is
not always perfectly reliable, as in there are some situations on some
OSen where it is impossible for perl to correctly find the path to the
running script.
In any case, the second should use FindBin (modulo the thread a while
ago about whether or not it's broken...).
Ben
--
EAT
KIDS (...er, whoops...)
FOR ben@morrow.me.uk
99p
------------------------------
Date: Tue, 18 Nov 2003 22:16:53 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Program that prints its source code
Message-Id: <Xns9437AFCC2422Ddkwwashere@216.168.3.30>
Ben Morrow <usenet@morrow.me.uk> wrote:
> "David K. Wall" <usenet@dwall.fastmail.fm> wrote:
>> If I want a program to print its own source code, is there any
>> reason to prefer one of these code snippets over the other? Or
>> is there an even better way to do it?
>>
>> Snippet 1:
>>
>> seek DATA, 0, 0;
>> print <DATA>;
>> __DATA__
>>
>> Snippet 2:
>>
>> open SELF, $0 or die "Error opening self for reading";
>> print <SELF>;
>
> I would prefer the first, just because I always prefer to use a
> handle I've got on the file rather than open another...
Good point. That in itself is enough to convince me.
--
David Wall
------------------------------
Date: Tue, 18 Nov 2003 21:15:06 GMT
From: Kirk Strauser <kirk@strauser.com>
Subject: SOAP::Lite versus DBI
Message-Id: <njeq81x058.ln2@news.conpoint.com>
I'm hoping to build a SOAP server to wrap a FoxPro database.
I built a minimal server:
-----------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use SOAP::Transport::HTTP;
use FoxPro;
my $daemon = SOAP::Transport::HTTP::Daemon
-> new (LocalPort => 8080, Reuse => 1)
-> dispatch_to('FoxPro')
;
print "Contact to SOAP server at ", $daemon->url, "\n";
$daemon->handle;
-----------------------------------------------------------
and a package to handle the backend:
-----------------------------------------------------------
#!/usr/bin/perl -w
package FoxPro;
use strict;
use DBI;
# Create a new FoxPro object
sub new
{
my $self = shift;
my $dbpath = shift || '.';
my $class = ref($self) || $self;
bless {'_dbpath' => $dbpath} => $class;
}
# Execute a query on a named table and return a handle to the result.
sub execute
{
my $self = shift;
my $query = shift;
my $limit = shift || 10;
my $dbh = DBI->connect("DBI:XBase:$self->{'_dbpath'}") or die $DBI::errstr;
my $sth = $dbh->prepare($query);
$sth->execute();
return $sth;
}
-----------------------------------------------------------
Now, I can use the FoxPro module locally, but when I run the little server
and try to pull results from it, I get errors like:
dbih_getcom handle DBI::st=HASH(0x86848dc) is not a DBI handle (has no magic)
I've Googled about, and it seems that other people have had similar
problems, but I've never found an answer to their questions. Is there
some problem passing around statement handles via SOAP::Lite that doesn't
exists when calling the modules locally?
--
Kirk Strauser
The Day Companies
------------------------------
Date: 18 Nov 2003 11:15:48 -0800
From: wherrera@lynxview.com (Bill)
Subject: Re: where is DBI::DWIM?
Message-Id: <239ce42f.0311181115.3b9773dc@posting.google.com>
Eric Wilhelm <ewilhelm@somethinglike.sbcglobalDOTnet> wrote in message news:<pan.2003.11.18.09.27.56.187312.1618@somethinglike.sbcglobalDOTnet>...
> On Tue, 18 Nov 2003 05:12:33 -0600, Tore Aursand wrote:
>
> The situation that I have is that 3-4 programs are responsible for
> creating one record in a table. The first application may set 2-3
> columns, another application sets 1 column, etc.
>
> If there were a pre-ordained order in which they had to run, it would make
> sense that the first to run sets the name and values with an INSERT,
> except that it must also assume that it may have run before, therefore it
> could use a REPLACE.
>
> All other applications could then require that the row is already present
> and they could use an UPDATE to set their column(s) (each column is the
> responsibility of only one program.)
>
> The problem is that all of the column values are independent of each
> other, so if the programs are forced to run in the order C,D,E,A,B and C
> always does a REPLACE, you would have to re-run D,E,A,B to get the
> previous (unchanged) values back into the table.
>
> Now, we could eliminate this "row-smashing" by adding code to C which did
> UPDATE or INSERT, but that still leaves us tied to the order C,D,E,A,B
> when the data does not logically require that order.
>
> To allow the programs to run in any order, each one would have to UPDATE
> or INSERT which means that each one needs twice as much SQL code.
>
Subclass DBIx::DWIW (and add it to CPAN if it works well)
------------------------------
Date: 18 Nov 2003 20:45:39 GMT
From: Peter Marksteiner <pm@katz.cc.univie.ac.at>
Subject: Re: where is DBI::DWIM?
Message-Id: <3fba84f3$0$33210$3b214f66@usenet.univie.ac.at>
Tore Aursand <tore@aursand.no> wrote:
: I don't know enough about your application(s) to offer the best solution,
: but it seems pretty clear that you need a function (in Perl) which does
: all the dirty work for you;
: 1. Lookup record (if it exists)
: 2. UPDATE or INSERT, depending on #1
On databases with decent transaction handling, you could use this
brute-force approach:
$sth1 = $dbh->prepare("delete from my_table where pkey = ?");
$sth2 = $dbh->prepare("insert into my_table (pkey, other) values (?,?)");
$dbh->begin_work;
$sth1->execute($primary_key);
$sth2->execute($primary_key, $other_value);
$dbh->commit;
Peter
--
------------------------------
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 5824
***************************************