[17042] in Perl-Users-Digest
Perl-Users Digest, Issue: 4454 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 28 00:05:31 2000
Date: Wed, 27 Sep 2000 21:05:10 -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: <970113910-v9-i4454@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 27 Sep 2000 Volume: 9 Number: 4454
Today's topics:
Re: 2 Questions <emblow@ozlinx.com.au>
Re: ASAP: How $SCALAR = $LIST (Logan Shaw)
Re: ASAP: How $SCALAR = $LIST (Abigail)
Re: ASAP: How $SCALAR = $LIST <elephant@squirrelgroup.com>
Re: cgi that grabs html into @ from another cgi page <tina@streetmail.com>
Compiling perl under os/2. (Fred Leggett)
Re: Date Conversion Question <godzilla@stomp.stomp.tokyo>
Re: Date Conversion Question <godzilla@stomp.stomp.tokyo>
dereferencing an array from within a hash value <dprovac1@twcny.rr.com>
Re: dereferencing an array from within a hash value (Logan Shaw)
Re: foreach two elements at a time? (Abigail)
Re: foreach two elements at a time? (Daniel Chetlin)
Re: Help with Time::localtime <wongjonk@hotmail.com>
Re: how to read dir info ? <ren.maddox@tivoli.com>
Re: how to read dir info ? <vioon@hotmil.com>
Re: Locking files across CGI script invocations: advice <frank_vera@telocity.com>
Re: Newbie needs help with s/// script. (Keith Calvert Ivey)
Re: perl cookies <elephant@squirrelgroup.com>
Re: Perl on Windows kassebaum@my-deja.com
Re: Portability of Perl/Tk programs? (Clinton A. Pierce)
Re: Programming the Perl DBI <jkline@one.net>
Re: recommended link checking script? (Randal L. Schwartz)
Re: Shortest code for Fibonacci? <rick.delaney@home.com>
Suggestion for Web interface to DBI? (Jesse T Sheidlower)
Re: What does this do?! <yanick@babyl.sympatico.ca>
Re: What is %{$_} (Logan Shaw)
Re: What is %{$_} <anmcguire@ce.mediaone.net>
why "Prototype mismatch"? <premx.makhijani@intel.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 28 Sep 2000 12:49:23 +1000
From: "Nick Emblow, President IT Not Just Bears" <emblow@ozlinx.com.au>
Subject: Re: 2 Questions
Message-Id: <6pyA5.45$8G6.2041@nsw.nnrp.telstra.net>
That would be moving backwards, not forwards.
I suggest this learning structure:
BASIC [QB7x or PB] TO ASSEMBLY[NASM98]
OR
C [EGGS] TO ASSEMBLY[NASM98]
OR
C++[DJGPP] TO ASSEMBLY[NASM98]
You see, While going from QB to VB may seem like a smart move ie, you dont
need to program your own guis any more...You unfortunately have gone from
controlling your program[QB,PB,ASM,C/C++] to manipulating someone _elses_
program.
If however, you are one lazy son ova bitch, then VB is for you, but goof
luck trying to make an _original_ looking program.
And by C++ i think you meant, ms c++, didn't you...Well, you could use that,
but a _FREE_ equivelent would be DJGPP w/ the allegro library. DJGPP is the
way to go if you want to program in C/C++ using 32 bits.
I suggest using ASM [assembly] because it provides _MAXIMUM_ control over
your program.
It may be harder, longer nastier and INSANE, but in the end, you'll be so
goddam proud of your self.
Just a suggestion
Cheers
Nick
"Frankie" <frankie@centurytel.net> wrote in message
news:39C5974E.AC51F612@centurytel.net...
> My apologies for the cross-post and the broad nature of this question.
> I just can't seem to find the info I want via traditional search
> engines, including Deja News. And please, no flames. I'm not a newbie
> and am aware I'm on thin ice with the cross and the questions. Thanks.
>
> My question is what programming language would you recommend to a
> complete beginner in programming? I've extensive background in various
> environments, so I'm not going to be terribly uneasy with the comp, I'm
> just looking for a good start.
>
> The second, and virtually hand in hand with the first, is where to go
> from there and in what sequence. IOW, I'm thinking (just an example)
> qbasic to Visual Basic to C to C++ etc? And yes, I'm going to throw in
> HTML, but I want to go beyond that.
>
> Again, my apologies if this is an inappropriate post. Or, for that
> matter, too broad. Any help will be greatly appreciated. E-mails are
> welcome (take the ** out per below) but since I'm posing the question, I
> can check all the Groups also. TIA
>
> --
> "I do this really moronic thing that the government doesn't want me to
> do. It is called thinking" - George Carlin
>
>
> Remove * * to reply.
>
> -----------------------------------------------------------------------
> Pursuant to US Code, Title 47, Chapter 5, Subchapter II, ¢227,
> Any and all nonsolicited commercial E-mail sent to this address
> is subject to a download and archival fee in the amount of $500.00 US.
> E-Mailing denotes the acceptance of these terms
> -----------------------------------------------------------------------
------------------------------
Date: 27 Sep 2000 20:39:54 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: ASAP: How $SCALAR = $LIST
Message-Id: <8qu7ha$f72$1@provolone.cs.utexas.edu>
In article <MPG.143d4673c8e918df9897d6@localhost>,
jason <elephant@squirrelgroup.com> wrote:
>Abigail wrote ..
>>Don Vaillancourt (donv@webimpact.com) wrote on MMDLXXXIV September
>>MCMXCIII in <URL:news:39D259DC.7DE580A8@webimpact.com>:
>>~~ How to I get the number of elements in a list that is only accessible
>>~~ through a reference from a scalar.
>>
>> $#{EXPRESSION YIELDING A REFERENCE TO AN ARRAY}
>
>ahem .. plus one
In that case, don't you want
scalar @{EXPRESSION YIELDING A REFERENCE TO AN ARRAY}
?
- Logan
------------------------------
Date: 28 Sep 2000 01:40:12 GMT
From: abigail@foad.org (Abigail)
Subject: Re: ASAP: How $SCALAR = $LIST
Message-Id: <slrn8t589f.lo9.abigail@alexandra.foad.org>
jason (elephant@squirrelgroup.com) wrote on MMDLXXXV September MCMXCIII
in <URL:news:MPG.143d4673c8e918df9897d6@localhost>:
{} Abigail wrote ..
{} >Don Vaillancourt (donv@webimpact.com) wrote on MMDLXXXIV September
{} >MCMXCIII in <URL:news:39D259DC.7DE580A8@webimpact.com>:
{} >~~ How to I get the number of elements in a list that is only accessible
{} >~~ through a reference from a scalar.
{} >
{} > $#{EXPRESSION YIELDING A REFERENCE TO AN ARRAY}
{}
{} ahem .. plus one
Not if you have $[ set to 1.
Abigail
--
Pascal forever!
------------------------------
Date: Thu, 28 Sep 2000 14:50:53 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: ASAP: How $SCALAR = $LIST
Message-Id: <MPG.143d79366ff3dbdc9897d8@localhost>
Abigail wrote ..
>jason (elephant@squirrelgroup.com) wrote on MMDLXXXV September MCMXCIII
>in <URL:news:MPG.143d4673c8e918df9897d6@localhost>:
>{} Abigail wrote ..
>{} >Don Vaillancourt (donv@webimpact.com) wrote on MMDLXXXIV September
>{} >MCMXCIII in <URL:news:39D259DC.7DE580A8@webimpact.com>:
>{} >~~ How to I get the number of elements in a list that is only accessible
>{} >~~ through a reference from a scalar.
>{} >
>{} > $#{EXPRESSION YIELDING A REFERENCE TO AN ARRAY}
>{}
>{} ahem .. plus one
>
>
>Not if you have $[ set to 1.
;)
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 28 Sep 2000 03:33:11 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: cgi that grabs html into @ from another cgi page
Message-Id: <8que5n$g2a4m$8@ID-24002.news.cis.dfn.de>
hi,
In comp.lang.perl.misc drdementor@my-deja.com wrote:
> Ok here it goes
> Page A is a cgi page and dynamic.
> Page B is a cgi page and dynamic.
> I am writing Page A.(mypage)
> I have no control of page B. (the other page)
> I want page a to be created on the fly including contents from html
> results of the page B cgi.(the other page)
perldoc lwpcook
perldoc LWP::Simple
...
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: 27 Sep 2000 23:31:37 -0400
From: fleggett@seminole.gate.net (Fred Leggett)
Subject: Compiling perl under os/2.
Message-Id: <8que2p$v58$1@seminole.gate.net>
I don't want to assault this 'group with a bunch of specific
questions...yet. So, for now, I'd like to ask - has anyone gotten the
latest stable version of perl (available as stable.zip on www.perl.com) to
fully compile under os/2 using emx and pgcc? I can generate perl.exe and
miniperl.exe, but that's it. Oh, and I did apply the diff file found in
the os2 directory to the base configure script. Thanks.
--
---
FRED LEGGETT o http://www.anime.jyu.fi/~fleggett/mypage/
407-528-2643 o http://www.animegaijin.org (Anime Gaijin America)
o fleggett@gate.net : fleggett@anime.jyu.fi
------------------------------
Date: Wed, 27 Sep 2000 20:02:09 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Date Conversion Question
Message-Id: <39D2B4B1.B08ADE0@stomp.stomp.tokyo>
Larry Rosler wrote:
> Godzilla! wrote:
> > eT wrote:
> > if (rindex ($am_pm, "PM") > -1)
> > { $hour = $hour + 12; }
> > else
> > { $hour = "0$hour"; }
> Why does '11', for example, want to become '011'?
> You and Iain Chalmers:
> IC> Note 2: if the sybase date hours *aren't* in 24hr format(which the
> IC> AM at the end suggests), add the line
> IC> $hour+=12 if (substr($frac_sec,-2) eq 'PM');
> IC> between the split and the sprintf lines...
> have each overlooked a critical step in converting
> from 12-hour to 24-hour time notation:
Here ya go Mr. Rosler. This time below my signature
as a courtesy to readers, what few I have, which is
actually more than most will admit. My hopes are you
understand my feeling uncomfortable about having my
test scripts and printed results, automatically
quoted. I dunno, seems rude to me, and rudeness
certainly isn't one of my qualities.
* crosses her fingers behind her big butt *
Your critique of my code, your pointing out my error,
was accomplished in a straight forward, matter-of-fact
fashion, sans any malice intent. This is appreciated
more than your pointing out my code error.
I hold suspicions about you Mr. Rosler. I've always
suspected you of being a gentleman. I hope you won't
hold a grudge for my being suspect of you.
In time, I did figure out part of my other bug, which
I never could cause to manifest. Part of my figuring
is this index,
(index ($line, "00:00:00") == -1))
would always evaluate to true with no 00 hour
present in $line.
Changing this to,
(index ($line, "0:00:00") == -1))
as would be correct, still evaluates to true
if $line contains, 10:00:00 which it did for
my test conditions. Correcting this index error
during my testing, made no difference, which
I now find rather comical.
Clearly I set myself up for comical frustration
by selecting just the right error and, just the
right data in my data base. Correcting this error,
only led to another error due to my test data
pulled from a file. This was an enjoyable challenge.
You did say I am unique.
Thank you again for telling me about my error
and for your displayed diplomacy in doing so.
*laughs* There is a most pleasant inside joke
with all of this. Perhaps someday you may treat
me to a glass of champagne and, in exchange,
I will tell you some of the best newsgroup
gossip you will ever hear, just as unique
as myself.
LOOK MA! NO MODULES! ooppss....
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-type: text/plain\n\n";
open (TEST, "test.txt");
@Array = <TEST>;
close (TEST);
print "Boss, your input is:\n\n";
foreach $input (@Array)
{ print $input; }
print "\n\nBoss, my output is:\n\n";
chomp (@Array);
@Data = qw (jan:1 feb:2 mar:3 apr:4 may:5 june:6
july:7 aug:8 sept:9 oct:10 nov:11 dec:12);
foreach $line (@Array)
{
foreach $data (@Data)
{
($key, $value) = split (/:/, $data);
if ($value < 10)
{ $value = "0$value"; }
$line =~ s/$key/$value/i;
}
$line =~ s/\s+/:/g;
($mon, $day, $year, $hour, $min, $sec, $am_pm) = split (/:/, $line);
if (index ($line, ":0:00:00:000") == -1)
{
if (($hour < 12 ) & (rindex ($am_pm, "PM") > -1))
{ $hour = $hour + 12; }
if (($hour == 12) & (rindex ($am_pm, "AM") > -1))
{ $hour = 0; }
if ($hour < 10)
{ $hour = "0$hour"; }
if ($day < 10)
{ $day = "0$day"; }
}
else
{
$hour = "0$hour";
if ($day < 10)
{ $day = "0$day"; }
}
$new_date = "$year-$mon-$day $hour:$min:$sec";
print "$new_date\n";
}
print "\n\n\nAll done Boss.";
exit;
PRINTED RESULTS:
________________
Boss, your input is:
Apr 1 1991 0:00:00:000AM
Apr 1 1991 0:00:00:000PM
Apr 1 1991 12:00:00:000AM
Apr 1 1991 12:00:00:000PM
Apr 1 1991 1:00:00:000AM
Apr 1 1991 1:00:00:000PM
Mar 15 44BC 10:00:00:000AM
Mar 15 44BC 10:00:00:000PM
Aug 6 1945 8:10:10:000AM
Aug 6 1945 8:10:10:000PM
Aug 8 1972 6:24:00:000AM
Aug 8 1972 6:24:00:000PM
Aug 9 1945 12:03:23:000AM
Aug 9 1945 12:03:23:000PM
Boss, my output is:
1991-04-01 00:00:00
1991-04-01 00:00:00
1991-04-01 00:00:00
1991-04-01 12:00:00
1991-04-01 01:00:00
1991-04-01 13:00:00
44BC-03-15 10:00:00
44BC-03-15 22:00:00
1945-08-06 08:10:10
1945-08-06 20:10:10
1972-08-08 06:24:00
1972-08-08 18:24:00
1945-08-09 00:03:23
1945-08-09 12:03:23
All done Boss.
------------------------------
Date: Wed, 27 Sep 2000 20:22:18 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Date Conversion Question
Message-Id: <39D2B96A.2A82D183@stomp.stomp.tokyo>
Godzilla! slobbered:
> Larry Rosler wrote:
> > Godzilla! blathered:
> > > eT wrote:
(snipped)
> Changing this to,
> (index ($line, "0:00:00") == -1))
> as would be correct, still evaluates to true
> if $line contains, 10:00:00 which it did for
ooppsie...
$stupidity =~ s/if/unless/;
yours uniquely,
K
------------------------------
Date: Thu, 28 Sep 2000 01:25:08 GMT
From: "Dave" <dprovac1@twcny.rr.com>
Subject: dereferencing an array from within a hash value
Message-Id: <U5xA5.42419$%h6.6947249@typhoon.nyroc.rr.com>
Hi,
In this example:
%FIELDS = ('personal information' => ['Name', 'Address', 'Tele', 'Fax']);
foreach (keys %FIELDS) {
print "$_ $FIELDS{$_} \n";
}
How do I dereference $FIELDS{$_} so that
Name, Address, Tele, Fax prints out?
I keep getting:
personal information ARRAY(0A9320B)
Thanks,
Dave
------------------------------
Date: 27 Sep 2000 20:47:39 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: dereferencing an array from within a hash value
Message-Id: <8qu7vr$fbs$1@provolone.cs.utexas.edu>
In article <U5xA5.42419$%h6.6947249@typhoon.nyroc.rr.com>,
Dave <dprovac1@twcny.rr.com> wrote:
>Hi,
>In this example:
>
>%FIELDS = ('personal information' => ['Name', 'Address', 'Tele', 'Fax']);
>
>foreach (keys %FIELDS) {
> print "$_ $FIELDS{$_} \n";
>}
>
>How do I dereference $FIELDS{$_} so that
>Name, Address, Tele, Fax prints out?
>
>I keep getting:
>personal information ARRAY(0A9320B)
That's because you told it you want to print out the value of the
key/value pair, and the value is a reference to an array. So
perl dutifully turns that reference into a string like your
requested (by putting it in double quotes) and that's what you get.
If you want to treat the array reference as an array, put it inside of
@{ }. I personally would do something more elaborate than just
interpolating that into your double-quoted string (although you can
do that if you want). So, I'd change your middle line to this:
print $_, ' ', join (', ', @{ $FIELDS{$_} }), "\n";
Actually, I'd use each() and change your whole loop to this:
my ($key, $value);
while ( ($key, $value) = each %FIELDS )
{
print $key, ' ', join (', ', @$value), "\n";
}
Hope that helps.
- Logan
------------------------------
Date: 28 Sep 2000 01:45:12 GMT
From: abigail@foad.org (Abigail)
Subject: Re: foreach two elements at a time?
Message-Id: <slrn8t58iq.lo9.abigail@alexandra.foad.org>
Uri Guttman (uri@sysarch.com) wrote on MMDLXXXV September MCMXCIII in
<URL:news:x7snql74eb.fsf@home.sysarch.com>:
** >>>>> "MV" == Martien Verbruggen <mgjv@verbruggen.comdyn.com.au> writes:
**
** MV> Just as an extra question, _why_ is aliasing two variables slower
** MV> than creating references to them in @_?
**
** aliasing $a is a simple global copy of the ref to the value. but @_
** resides on the stack and so there has to be memory allocation for the
** aliases which still have to be copied.
There's another big reason why using @_ won't work for sort subs.
Sort subs aren't called in the same way as other subs. The internals
take all kinds of shortcuts when calling sortsubs. Including @_ handling.
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT
------------------------------
Date: 28 Sep 2000 02:11:04 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: foreach two elements at a time?
Message-Id: <8qu9bo02ja6@news1.newsguy.com>
On Wed, 27 Sep 2000 23:37:50 GMT,
Martien Verbruggen <mgjv@verbruggen.comdyn.com.au> wrote:
>\begin{peeve}
>
>That's an argument to allow sort subs to act on @_, so that we can
>write them in a slighlty more sane way.
>
>my @foo = sort { $_[0] <=> $_[1] } @bar;
>From perl56delta:
=head2 Enhanced support for sort() subroutines
Perl subroutines with a prototype of C<($$)>, and XSUBs in general,
can now be used as sort subroutines. In either case, the two elements
to be compared are passed as normal parameters in @_. See
L<perlfunc/sort>.
For unprototyped sort subroutines, the historical behavior of passing
the elements to be compared as the global variables $a and $b remains
unchanged.
Others have agreed with you, Martien. I certainly find this way of doing
things much easier.
-dlc
------------------------------
Date: Thu, 28 Sep 2000 11:03:00 +0800
From: "Jonathan Wong" <wongjonk@hotmail.com>
Subject: Re: Help with Time::localtime
Message-Id: <8quck2$6te$1@horn.hk.diyixian.com>
THANKS SO MUCH!!!!!!
jon
Jim Melanson <jim@thebeaches.to> wrote in message
news:DkrA5.19981$vZ.947215@news20.bellglobal.com...
>
> Johnathan,
>
> Go the simple (if less elegant) route:
>
> $todayval = time; $yesterdayval = $todayval - 86400; $tomorrowval =
> $todayval + 86400;
> @today = localtime($todayval); @yesterday = localtime($yesterdayval);
> @tomorrow = localtime($tomorrowval );
>
> #since we know that:
> #($second, $minute, $hour, $DAYOFMONTH, $MONTH, $YEAR, $weekday,
$dayofyear,
> $isDST) = localtime($offset);
> #then (and don't forget to increas the month)
>
> $today[4]++; $prevday[4]++; $nextday[4]++;
>
> %DATE = (
> 'today' => [$today[5], $today[4], $today[3]],
> 'yesterday' => [$yesterday[5], $yesterday[4], $yesterday[3]],
> 'tomorrow' => [$tomorrow[5], $tomorrow[4], $tomorrow[3]]);
>
>
> You will now access your info this way:
>
> For the year:
> $DATE{'today'}[0]
> $DATE{'yesterday'}[0]
> $DATE{tomorrow}[0]
>
> For the month:
> $DATE{'today'}[1]
> $DATE{'yesterday'}[1]
> $DATE{tomorrow}[1]
>
> For the day of the month:
> $DATE{'today'}[2]
> $DATE{'yesterday'}[2]
> $DATE{tomorrow}[2]
>
>
> I know, I know. It's clunky, un elegant but it works. Once you get more
> experience working with hashes/associateve arrays you can write a formula
> that will take this down to just a few lines.
>
> Jim
>
>
>
>
>
>
>
> "Jonathan Wong" <wongjonk@hotmail.com> wrote in message
> news:8qptde$1ls$1@horn.hk.diyixian.com...
> > Hi all,
> >
> > I have a small problem with time. I wrote in my script:
> >
> > use Time::localtime;
> > $now = localtime;
> >
> > I can access the year/month/day values by using $now->mon, etc.....
> >
> > My problem is that I need them for the day after and the day before
> today!!
> > $now->mday +1 won't work during month end and month beginning.
> >
> > How can I achieve that???
> >
> > Thanks for answering this small stupid problem!!!
> >
> >
> > Jonathan
> >
> >
> >
> >
>
>
------------------------------
Date: 27 Sep 2000 18:06:01 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: how to read dir info ?
Message-Id: <m3d7hpph9i.fsf@dhcp11-177.support.tivoli.com>
Ren Maddox <ren.maddox@tivoli.com> writes:
> "qwerty" <vioon@hotmil.com> writes:
>
> > Thanks, but it just does not work
>
> Please describe exactly how it does not work. It worked fine for me
> in the following context:
>
> #!/usr/local/bin/perl -w
> use strict;
> opendir DIR, "." or die "Could not open directory, $!\n";
# normally need a "chdir $dir or die" before the readdir
> my @dirs = grep( (!/^\./ && -d), readdir(DIR) );
> print "@dirs\n";
> __END__
Oops... As LR has already pointed out, if you aren't working with ".",
you also need to handle the fact that readdir only returns the actual
filenames with no path, and -d (et. al.) need the path.
The above example does not have this problem as it is working with
".". My previously posted example I also only tested with ".", and
probably also forgot the chdir (though I do remember thinking about it
-- wonder if I put it in... oh well, too lazy to go check....).
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 28 Sep 2000 00:29:07 +0200
From: "qwerty" <vioon@hotmil.com>
Subject: Re: how to read dir info ?
Message-Id: <8qtsea$mad$1@tesla.a2000.nl>
thanks, but it does not work, it actually shows ALL the files
and i only want is the directory names.
"Edward Valencia" <edward@netcomi.com> wrote in message
news:39D27231.EDD34C48@netcomi.com...
> opendir(DIR, "/www");
> @dirs = sort(grep(!/^\.\.?$/, readdir(DIR)));
> close(DIR);
> chomp(@dirs);
> foreach $line (@dirs) {
> print "$line\n";
> }
------------------------------
Date: Wed, 27 Sep 2000 22:39:57 -0400
From: "Frank Vera" <frank_vera@telocity.com>
Subject: Re: Locking files across CGI script invocations: advice sought.
Message-Id: <LbyA5.21274$Ao1.4288985@newsrump.sjc.telocity.net>
You might try a "locking" mechanism of your own.
If you are already keeping track of the user,
it's just a matter keeping track of who has requested "change" access.
You could create a table with fields like RECORD_ID USER_ID DATE LOCKID
When the user asks to edit the record, a query is performed on this lock
table to see
if there is currently a lock on that record. If there is, you may want to
offer the option of breaking the lock.
If the record is not locked then add a record in the lock table for the item
in the original table that will be locked and send the user the original
data and a unique lock id.
When the user finishes editing the record, check to make sure that lock_id
and user_id match. If they don't, warn who has modified the record and
offer whatever options you want. If they do match then edit the lock the
"locking" record, update the original record, delete the lock record, and
release all locks.
I know I haven't covered everything, but I've found this to be very
effective in entering and editing information using a web-based front end
for a database.
Enjoy,
Frank Vera
"Tim Richardson" <ter@my-deja.com> wrote in message
news:8qi3fi$hpj$1@nnrp1.deja.com...
> I'm interested in advice about how to lock simple database files across
> invocations of a CGI script. The scenario: First the user selects some
> data to edit (they choose a key to a record in a db_file database). They
> submit their record selection, and the script runs and returns a form
> with the data ready for editing.
> Then the user modifies the data in their browser, and submits it.
>
> What are some light-weight strategies to use to lock the database in
> this case? I've thought of passing back a CRC of the database via a
> hidden form field. When the form is resubmitted, the crc of the database
> file is checked again, and if it doesn't match there is a potential
> version conflict.
>
> We could also lock the database by giving each session some identifier,
> and recording in another database which session holds the lock, but then
> we must worry about timeouts and so on. Is there a module for this?
> I think there is probably no good way of doing this and keeping life
> simple, so I would be interested in what compromises have proved to be
> useful.
>
> regards,
>
> Tim
>
> --
> Tim Richardson
> (search string: qweeblebeast)
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Thu, 28 Sep 2000 02:20:21 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Newbie needs help with s/// script.
Message-Id: <39d3a8b0.4482665@news.newsguy.com>
neilwSPAMTHIS@idirect.com (Neil Watson) wrote:
>Search for Replace with
>-1500 -6
>-1250 -5
>-1000 -4
>...
>...
>750 3
>1000 4
>etc...
>
>My script is called points. I run "./points talents.html".
perl -pi.bak -e "s!\b(100|75|1?50|1?25)0\b!$1/25!ge"
talents.html
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Thu, 28 Sep 2000 14:50:03 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: perl cookies
Message-Id: <MPG.143d790684c460df9897d7@localhost>
Troy Rasiah wrote ..
>reset..compared to when i do it in Netscape
>
>For example...
> my $cookie_expire='+1s' ;
> $cookie = $query->cookie(-name=>'OPENRD',
> -value=>$session{_session_id},
> -expires=>$cookie_expire,
> -path=>'/',
> -domain=>$cookie_domain);
>
>print $query->header(-cookie=>$cookie);
>
>If the cookie was set to 10 minutes then it will expire after 10 minutes
>using IE.
>With Netscape it resets the cookie expire to 1s
>
>Anyone have any idea's?
sounds like a perfectly reasonable thing to expect from two different
implementations of a non-standard
you have no errors in your Perl code - if you're asking about browser
support for cookies then you'll find much more reliable information
elsewhere
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 28 Sep 2000 02:17:28 GMT
From: kassebaum@my-deja.com
Subject: Re: Perl on Windows
Message-Id: <8qu9nj$2pb$1@nnrp1.deja.com>
> How can I keep it open so I can view the final
>output?
Use this as your final line:
<>;
Any key will then end the program. (I hope. I'm a
beginner.)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 28 Sep 2000 01:39:31 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Portability of Perl/Tk programs?
Message-Id: <njxA5.12294$hD4.3310198@news1.rdc1.mi.home.com>
[Posted and mailed, cc to Sarathy]
In article <8qqmm6$52d$1@nnrp1.deja.com>,
Dick Latshaw <latsharj@my-deja.com> writes:
> In article <qq4A5.11135$hD4.2731831@news1.rdc1.mi.home.com>,
> clintp@geeksalad.org (Clinton A. Pierce) wrote:
>>
>> In what way that hasn't already been addressed on this thread?
>
> If you attempt to run the Interactive Client with IO::Socket and the
> TCP Server with IO::Socket examples from the perlipc man page, the
> child process in the client hangs when attempting to write to the
> socket handle. See open entry 306 at bugs.activestate.com.
I'll cc Sarathy on this note, since he's the one assigned to bug #306.
It's NOT a bug in fork necessarily. It's probably a bug in the Windows
I/O libraries and how they don't quite treat sockets as fully-fledged
filehandles:
If you change the example to use send/recv (like the socket documentation
suggests instead of file I/O) then the example works just fine.
Here's the example, cut up to use send/recv instead of stdio:
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my ($host, $port, $kidpid, $handle, $line, $sender);
unless (@ARGV == 2) { die "usage: $0 host port" }
($host, $port) = @ARGV;
# create a tcp connection to the specified host and port
$handle = IO::Socket::INET->new(Proto => "tcp",
PeerAddr => $host,
PeerPort => $port)
or die "can't connect to port $port on $host: $!";
$handle->autoflush(1); # so output gets there right away
print STDERR "[Connected to $host:$port]\n";
# split the program into two processes, identical twins
die "can't fork: $!" unless defined($kidpid = fork());
# the if{} block runs only in the parent process
if ($kidpid) {
# copy the socket to standard output
while ($sender = (recv $handle, $line, 1024, 0)) { # DIFF
last if (! length($line)); # DIFF
print STDOUT $line;
}
kill("TERM", $kidpid); # send SIGTERM to child
}
# the else{} block runs only in the child process
else {
# copy standard input to the socket
while (defined ($line = <STDIN>)) {
# print $handle $line; # DIFF
if ( (send $handle, $line, 0) < length($line)) { # DIFF
die "Short send!"; # DIFF
} # DIFF
}
}
The error checking ain't great, but *eh* it's just a hack. Tested under Win98,
AS 5.6 spin 618 Intel; I used identd, httpd and a custom "interative" server to
make sure the conversation didn't stop after the first reply, or two, or a dozen.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Wed, 27 Sep 2000 21:09:25 -0400
From: Joe Kline <jkline@one.net>
To: Sid Malhotra <sxm124@po.cwru.edu>
Subject: Re: Programming the Perl DBI
Message-Id: <39D29A45.66CEEEC0@one.net>
[posted and cc'd]
Sid Malhotra wrote:
>
> I am looking to buy "Programming the PERL DBI: Database Programming with
> PERL" by Alligator Descartes and Tim Bruce. I need to start writing
> scripts with better databases than the plain text that I am using right
> now.
>
> Any suggestions? Comments?
Buy it to learn how to use DBI. As for writing better databases, you
need a book that teaches database design. At least something that goes
into more depth than the Cheetah does.
I'm partway through:
"Database Design for Mere Mortals : A Hands-On Guide to Relational
Database Design" by Michael J. Hernandez
I think it's great for a newbie database maker. There are others that
go into the theory and all, this is a great intro into design, IMHO.
> ps: It is not I, but BARNES & NOBLE.com that calls it PERL. Amazon.com
> says "Perl". :-)
If you know the difference then correct them in your posting.
--
Joe Kline
It takes a lot of brains to enjoy satire, humor, and wit;
but none to be offended by them. ---The Midnight Skulker
------------------------------
Date: 27 Sep 2000 18:37:31 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: recommended link checking script?
Message-Id: <m1k8bx8ffo.fsf@halfdome.holdit.com>
>>>>> "mikelot" == mikelot <mikelot@my-deja.com> writes:
mikelot> I'm looking for a perl script that I can use to recursively
mikelot> check a web site, and that I can limit by either depth or url
mikelot> pattern matching. I need to do this via http, so that rules
mikelot> out some of the file based approaches. Any recommendations
mikelot> for any of your favorites?
mikelot> I've looked at randal's script at
mikelot> http://www.stonehenge.com/merlyn/WebTechniques/col14.html
You missed the ones at
http://www.stonehenge.com/merlyn/WebTechniques/col07.html
http://www.stonehenge.com/merlyn/WebTechniques/col27.html
http://www.stonehenge.com/merlyn/WebTechniques/col35.html
but most importantly
http://www.stonehenge.com/merlyn/LinuxMag/col15.listing.txt
and http://www.stonehenge.com/merlyn/LinuxMag/col16.listing.txt
As you can tell, "link checkers" are one of my favorite topics to
revisit, because I keep thinking of better ways of doing it. The
columns for the last two are not online yet, thanks to a 3-month
moratorium that Linux magazine places on my column text, but wait
a few months and visit
http://www.stonehenge.com/merlyn/LinuxMag/col15.html
http://www.stonehenge.com/merlyn/LinuxMag/col16.html
for the descriptions of that last one. It's sweeet. I use it
daily now.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Thu, 28 Sep 2000 02:33:25 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Shortest code for Fibonacci?
Message-Id: <39D2B0AB.A21A5BBC@home.com>
Mark-Jason Dominus wrote:
>
> Ho! Another improvement; we can get rid of $d too:
>
> sub mm {
> my ($n) = @_;
> return (1, 0) if $n == 0;
> return (1, 1) if $n == 1;
> if ($n % 2) { # odd n
> my ($a, $b) = mm($n-1);
> return ($a+$b, $a);
> } else { # even n
> my ($a, $b) = mm($n>>1);
> return ($a*$a+$b*$b, $b*(($a<<1)-$b));
> }
> }
Putting it back in (but calling it $p):
sub mm {
my ($n) = @_;
return (1, 0) if $n == 0;
return (1, 1) if $n == 1;
my ($a, $b) = mm($n>>1);
my $p = $n % 2;
($b*($a<<1) + ($p ? $a*$a : -$b*$b), $a*$a + $b*$b)[!$p,$p];
}
This is essentially identical for powers of two except it would be a bit
slower because of the slice. Expand if desired.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 27 Sep 2000 22:59:31 -0400
From: jester@panix.com (Jesse T Sheidlower)
Subject: Suggestion for Web interface to DBI?
Message-Id: <8quc6j$69o$1@panix2.panix.com>
I'm a relatively novice programmer looking for some advice on
a Web interface to a DBI database. I have a fairly straightforward
database of books, and I think I can handle most of the specific
display functions I need. But I was trying to find something to
use as example code for the usual maintenance (add/delete, modify,
etc.) features; I don't feel confident that I could write it
from scratch myself.
I had originally started with an address-book program that was
in the _CGI Programming with Perl_ book, but it ended up being
too much effort to modify into what I needed. There were a
number of programs at perlarchives.com, but I wasn't sure where
to start; the few I looked at seemed either too basic or so
advanced that I wouldn't be able to modify them without a lot
of work.
If it matters, I'm working with a simple CSV database because
it's what I have access to right now; there aren't enough
records for speed to be a huge factor, though I wouldn't mind
better date handling!
Thanks very much for any suggestions.
Jesse Sheidlower
<jester@panix.com>
------------------------------
Date: Thu, 28 Sep 2000 02:30:49 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: What does this do?!
Message-Id: <t3yA5.20502$vZ.1008997@news20.bellglobal.com>
Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
: I was shocked! How could Yanick Champoux <yanick@babyl.sympatico.ca>
: say such a terrible thing:
:>It's an encryption/decryption program. To encrypt a file, do
:>
:> mysterious.pl password clear.txt > encrypt.txt
:>
:>and to decrypt it
:>
:> mysterious.pl password encrypt.txt
: Very good, but you got the name wrong :)
Darn. So that ESP modules still has a few bugs in it... *grumble*
:>Note that I called the script 'mysterious.pl', although
:>I have the feeling the original script was named
:>'X' or 'XXX' because of the statement
:>'$0=~s/X*$// if $d;' (I mean, it's obvious, isn't? ;)
: nope...well it could have been, but that's not what it was in the book
: :)
My second guess it that it was a typo of the original poster
and that the real line is '$o=~s/X*$/ if $d;'. Would make sense
too. Of course, it is very possible that the line has been thrown in
as a gratuitous monkeywrench for the poor reverse-engineers' mind. :)
:>Almost readable:
:>
:>#!/smart2/bin/perl -s
:>
:># called as mysterious.pl [ -d ] <key> <text_file>
:># -d is to decrypt the message
:># E.g.: mysterious.pl password clear.txt > encrypt.txt
:># mysterious.pl password encrypt.txt
:>
:>$0 =~ s/X*$// if $d;
: too weird. obscure the name only if decrypting?
Can an encryption program really be 'too weird'?
I mean, by definition, weird is unearthly and
unexplainable. So, the weirder a program is
(past a sufficient large value of weirdness), the
better the encryption will be, no? :)
hum... 54 values... pack labeled as 'punny'...
cryptic mention of cards...
Are we looking at a demented implementation of
the solitaire game, per any chance?
Joy,
Yanick
--
($_,$y)=('Yhre lo .kePnarhtretcae', '(.) (.)');
$y=~s/\(/(./gwhile s/$y/$2$1/xg;print # @
# `---'
------------------------------
Date: 27 Sep 2000 20:32:00 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: What is %{$_}
Message-Id: <8qu72g$f5h$1@provolone.cs.utexas.edu>
In article <8qtval$qn5$1@nnrp1.deja.com>, <nlymbo@my-deja.com> wrote:
>I'm looking at someone else's code and don't understand the variables
>that i am seeing...could someone explain the following??
>
>1) @{$list{$_}}
>2) %{$_}
@{ blahblahblah }
means take blahblahblah as a reference to an array and have the value
of that array.
%{ blahblahblah }
means the same thing, but blahblahblah is some expression that yields a
reference to a hash.
The way to remember this is that often you have stuff like @foo %bar.
In this case, the "foo" is a symbol table entry and the interpreter
uses the % operator on it to find a hash with that symbol table entry.
When you substitute and expression (usually a variable) for a symbol
table entry, the interpreter (conceptually, at least) does the exact
same thing, only it gets the reference from the value of the expression
instead of from the symbol table. The braces are just used for
grouping (like parenthesis for other expressions).
Hope that helps.
- Logan
------------------------------
Date: Wed, 27 Sep 2000 22:28:25 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: What is %{$_}
Message-Id: <Pine.LNX.4.21.0009272214390.19089-100000@hawk.ce.mediaone.net>
On Wed, 27 Sep 2000, nlymbo@my-deja.com quoth:
> I'm looking at someone else's code and don't understand the variables
> that i am seeing...could someone explain the following??
>
> 1) @{$list{$_}}
$_ # some scalar value
$list{$_} # some scalar value as a key to an element of a hash
@{list{$_}} # whos value is a reference to an array
> 2) %{$_}
$_ # some scalar value that is a reference to a hash
%{$_} # dereferencing that entire hash
> my (@key_list) = parse_billkeys("cas1,cas2", "hashed" => "cornbeef");
I have no idea what parse_billkeys does, but apparently it returns a list.
> my (%list, $hash, $key, $verd);
Create 4 lexically scoped variables ( 1 hash, 3 scalars ).
> foreach (@key_list) {
Iterating over an array.
> # Yeah, using the bill ID hash ref as the key is a bit spooky, but
> # dang it works nicely fer later.
A poor comment.
> push(@{$list{$_}}, get_texts_by_billkey(%{$_}));
> }
> ^^^^^^^^^ ^^^^^
See above, you can figure out push(), I am sure.
anm
--
$ENV{PAGER} = 'cat';
system perldoc => '-t', '-F', $0;
=head1
Just another Perl Hacker
------------------------------
Date: Wed, 27 Sep 2000 20:39:55 -0700
From: "Prem Makhijani" <premx.makhijani@intel.com>
Subject: why "Prototype mismatch"?
Message-Id: <8quefd$aag@news.or.intel.com>
On running this perl script, perl complains about "Prototype mismatch", why
so?
DRIVE_FIXED is a constant.
#-------------------------------------
use strict;
use Win32API::File ;
my @Drives=Win32API::File::getLogicalDrives();
foreach (@Drives){
my $DriveType=Win32API::File::GetDriveType($_);
if ( $DriveType == Win32API::File::DRIVE_FIXED() )
{
print "*";
}
print "$_\t$DriveType\n";
};
#-------------------------------------
OUTPUT is ...........................
Prototype mismatch: sub Win32API::File::DRIVE_FIXED vs () at (eval 1) line
1.
A:\ 2
*C:\ 3
D:\ 5
F:\ 4
Thanks :),
Prem
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4454
**************************************