[23585] in Perl-Users-Digest
Perl-Users Digest, Issue: 5792 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 13 09:10:43 2003
Date: Thu, 13 Nov 2003 06:10:16 -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 Thu, 13 Nov 2003 Volume: 10 Number: 5792
Today's topics:
last index of array reference <ryantate@ryantate.com>
Re: last index of array reference <rev_1318@hotmail.com>
Re: last index of array reference <mbudash@sonic.net>
Re: last index of array reference <wwonko@rdwarf.com>
Re: last index of array reference (Anno Siegel)
Re: last index of array reference <abigail@abigail.nl>
Re: last index of array reference <usenet@morrow.me.uk>
Re: last index of array reference (Anno Siegel)
long running perl programs & memory untilization <stanb@panix.com>
Re: long running perl programs & memory untilization <HelgiBriem_1@hotmail.com>
Mail::MboxParser trouble <pkornmod@hotmail.com>
Meaning of ` signs (Torch)
Need help with a program (rband)
Re: Need help with a program <me@privacy.net>
Re: Need help with a program <jwillmore@remove.adelphia.net>
Re: Net::SMTP on Windows 2000. I'm stuck! <jim.mozley@exponential-e.com>
Re: Newbie wants to flock <usenet@morrow.me.uk>
Re: Newbie wants to flock <usenet@morrow.me.uk>
Re: Newbie wants to flock <spammerswelcome@aol.com>
Re: OLE and Internet Explorer (William Herrera)
Re: problem with if-else assignment in text database (Anno Siegel)
Re: problem with if-else assignment in text database <usenet@morrow.me.uk>
Re: Problem with IO::Socket::INET and pop <usenet@morrow.me.uk>
Re: Problem with IO::Socket::INET and pop (Joe)
Re: Problem with IO::Socket::INET and pop (Joe)
Re: Very newbie Q anout $,@ and % <josef.moellers@fujitsu-siemens.com>
Re: Very newbie Q anout $,@ and % <usenet@morrow.me.uk>
Re: Very newbie Q anout $,@ and % <josef.moellers@fujitsu-siemens.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 13 Nov 2003 07:55:13 +0000 (UTC)
From: Ryan Tate <ryantate@ryantate.com>
Subject: last index of array reference
Message-Id: <bovdd1$1l57$1@agate.berkeley.edu>
If I have an array @array, I can get the last index with $#array.
What is the equivalent way to get the last index of array reference
$array?
I thought $#{@$array} would work, but perl coughed up "Bizarre copy of
ARRAY in leave at /script.pl line 230."
Haven't been able to find anything in this in Camel or Google Groups.
Thanks for any help
Cheers
r
------------------------------
Date: Thu, 13 Nov 2003 09:04:08 +0100
From: "Paul van Eldijk" <rev_1318@hotmail.com>
Subject: Re: last index of array reference
Message-Id: <pan.2003.11.13.08.04.08.159599@hotmail.com>
On Thu, 13 Nov 2003 07:55:13 +0000 Ryan Tate wrote:
> If I have an array @array, I can get the last index with $#array.
>
> What is the equivalent way to get the last index of array reference
> $array?
>
> I thought $#{@$array} would work, but perl coughed up "Bizarre copy of
> ARRAY in leave at /script.pl line 230."
Try: $#{$array}
HTH
Paul
--
$_=q{ ^4;c;14;1b:a^5;16:c^17:e^a;11;19:h^9;15:j^0:k^18:l^13
:n^6:o^7:p^10:r^b;12;1a:s^2:t^3;8:u^1};s{(?<=[;^])(\d)?([\d
abc])}{$a=$1;$2=~/([abc])/?$a*13+ord($1)%87:$1*13+$2}egx;
for(split/:/){($a,@_)=split/[;^]/;@@[@_]=($a)x@_}print@@
------------------------------
Date: Thu, 13 Nov 2003 08:00:52 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: last index of array reference
Message-Id: <mbudash-C3083C.00005213112003@typhoon.sonic.net>
In article <bovdd1$1l57$1@agate.berkeley.edu>,
Ryan Tate <ryantate@ryantate.com> wrote:
> If I have an array @array, I can get the last index with $#array.
>
> What is the equivalent way to get the last index of array reference
> $array?
>
> I thought $#{@$array} would work, but perl coughed up "Bizarre copy of
> ARRAY in leave at /script.pl line 230."
works for me using perl 5.8.1
--
Michael Budash
------------------------------
Date: Thu, 13 Nov 2003 08:10:35 +0000 (UTC)
From: Louis Erickson <wwonko@rdwarf.com>
Subject: Re: last index of array reference
Message-Id: <bove9r$3ls$1@holly.rdwarf.com>
Ryan Tate <ryantate@ryantate.com> wrote:
: If I have an array @array, I can get the last index with $#array.
: What is the equivalent way to get the last index of array reference
: $array?
: I thought $#{@$array} would work, but perl coughed up "Bizarre copy of
: ARRAY in leave at /script.pl line 230."
: Haven't been able to find anything in this in Camel or Google Groups.
Hmm. I thought, "What a cool error message!" and wanted to see what
'use diagnostics' would say about it. So I wrote:
#! /usr/bin/perl
use strict;
use warnings;
my @a=qw(One Two Three);
my $r = \@a;
print "num: ", $#a, "\n";
print "num: ", $#{@$r}, "\n";
__END__
Running it gets:
$ perl foo.pl
num: 2
num: 2
That looks to be working just as you expected it to, doesn't it?
What version of Perl are you using? My 5.6.0 on Linux and 5.6.1 on Win32
both work. 5.8.2 for Cygwin also works. Those are all I have handy
at the moment.
--
Louis Erickson - wwonko@rdwarf.com - http://www.rdwarf.com/~wwonko/
Stay away from flying saucers today.
------------------------------
Date: 13 Nov 2003 10:42:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: last index of array reference
Message-Id: <bovn7e$kku$1@mamenchi.zrz.TU-Berlin.DE>
Michael Budash <mbudash@sonic.net> wrote in comp.lang.perl.misc:
> In article <bovdd1$1l57$1@agate.berkeley.edu>,
> Ryan Tate <ryantate@ryantate.com> wrote:
>
> > If I have an array @array, I can get the last index with $#array.
> >
> > What is the equivalent way to get the last index of array reference
> > $array?
> >
> > I thought $#{@$array} would work, but perl coughed up "Bizarre copy of
> > ARRAY in leave at /script.pl line 230."
>
> works for me using perl 5.8.1
It does, in 5.6.0 thru 5.9.0, but should it?
The canonical form is "$#{$arrayref}", which is derived from "$#array"
by replacing the identifier "array" with a block "{$arrayref}" which
returns a reference (symbolic or real) to an object of the right type.
Why it works with an array instead of an array reference is anybody's
guess.
Anno
------------------------------
Date: 13 Nov 2003 12:00:01 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: last index of array reference
Message-Id: <slrnbr6si1.e2n.abigail@alexandra.abigail.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMDCCXXVI
September MCMXCIII in <URL:news:bovn7e$kku$1@mamenchi.zrz.TU-Berlin.DE>:
}} Michael Budash <mbudash@sonic.net> wrote in comp.lang.perl.misc:
}} > In article <bovdd1$1l57$1@agate.berkeley.edu>,
}} > Ryan Tate <ryantate@ryantate.com> wrote:
}} >
}} > > If I have an array @array, I can get the last index with $#array.
}} > >
}} > > What is the equivalent way to get the last index of array reference
}} > > $array?
}} > >
}} > > I thought $#{@$array} would work, but perl coughed up "Bizarre copy of
}} > > ARRAY in leave at /script.pl line 230."
}} >
}} > works for me using perl 5.8.1
}}
}} It does, in 5.6.0 thru 5.9.0, but should it?
It has always worked this way, AFAIK.
}} The canonical form is "$#{$arrayref}", which is derived from "$#array"
}} by replacing the identifier "array" with a block "{$arrayref}" which
}} returns a reference (symbolic or real) to an object of the right type.
}}
}} Why it works with an array instead of an array reference is anybody's
}} guess.
It seems to work with just $#{@array}. @{@array} doesn't give you a list
of elements of @array.
Abigail
--
perl -swleprint -- -_='Just another Perl Hacker'
------------------------------
Date: Thu, 13 Nov 2003 12:04:18 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: last index of array reference
Message-Id: <bovs02$qb3$4@wisteria.csv.warwick.ac.uk>
Louis Erickson <wwonko@rdwarf.com> wrote:
> Ryan Tate <ryantate@ryantate.com> wrote:
> : I thought $#{@$array} would work, but perl coughed up "Bizarre copy of
> : ARRAY in leave at /script.pl line 230."
>
> Hmm. I thought, "What a cool error message!" and wanted to see what
> 'use diagnostics' would say about it. So I wrote:
<snip>
perldiag says it's an internal error (otherwise known as a bug in perl
:)... rather as I suspected.
Interestingly, $#@a fails as expected, but $#{@a} succeeds...
Ben
--
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
ben@morrow.me.uk <=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=> (Kate Rusby)
------------------------------
Date: 13 Nov 2003 12:31:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: last index of array reference
Message-Id: <bovtj9$p47$1@mamenchi.zrz.TU-Berlin.DE>
Abigail <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMDCCXXVI
> September MCMXCIII in <URL:news:bovn7e$kku$1@mamenchi.zrz.TU-Berlin.DE>:
> }} Michael Budash <mbudash@sonic.net> wrote in comp.lang.perl.misc:
> }} > In article <bovdd1$1l57$1@agate.berkeley.edu>,
> }} > Ryan Tate <ryantate@ryantate.com> wrote:
> }} >
> }} > > If I have an array @array, I can get the last index with $#array.
> }} > >
> }} > > What is the equivalent way to get the last index of array reference
> }} > > $array?
> }} > >
> }} > > I thought $#{@$array} would work, but perl coughed up "Bizarre copy of
> }} > > ARRAY in leave at /script.pl line 230."
> }} >
> }} > works for me using perl 5.8.1
> }}
> }} It does, in 5.6.0 thru 5.9.0, but should it?
>
> It has always worked this way, AFAIK.
Apparently. I never noticed.
[...]
> It seems to work with just $#{@array}. @{@array} doesn't give you a list
> of elements of @array.
No, it does what it should do: evaluate @array in scalar context, i.e.
take its length, and access the corresponding regex capture variable $<n>
(if symbolic references are allowed).
Similarly, $#{ @array} "ought to" return the top index of @<n>. The
actual behavior could be meant to be a case of DWIM, though I doubt it.
It isn't documented, afaik, and it shouldn't be used except for obfuscation.
Anno
------------------------------
Date: Thu, 13 Nov 2003 13:19:30 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: long running perl programs & memory untilization
Message-Id: <bp00d2$cgj$1@reader2.panix.com>
I find myself in the position of writing long running (months) perl scripts
under FreeBSD, and Linux.
I seem to be having a lot of problems with memory leaks.
I was wondering if anyone had some words of wisdom as to how toadress these
issues? I'm interested in tips for avoiding them, as well as techniqies for
diagnsing existing problems.
If it helps my 'Native: language is C, and I just can't see anyway thet
these scripts should be leaking memory, based upon that experience.
I tend to use a lot of "local" variablse in subroutines, and allmost no
"global" variables at all. if that impacts this discussion.
Thanks for any wisdom that the comunity might be willing to share, and of
course, as always, pointers to docs are appreciated.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: Thu, 13 Nov 2003 13:54:42 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: long running perl programs & memory untilization
Message-Id: <f337rvgt6iob81gf50tlgngk29icjt2tki@4ax.com>
On Thu, 13 Nov 2003 13:19:30 +0000 (UTC), Stan Brown <stanb@panix.com>
wrote:
>If it helps my 'Native: language is C, and I just can't see anyway thet
>these scripts should be leaking memory, based upon that experience.
>
>I tend to use a lot of "local" variablse in subroutines, and allmost no
>"global" variables at all. if that impacts this discussion.
Well, that probably explains most of it. 'local' in Perl is
nothing like 'local' in C, but more like the opposite. It is
used to change the value of a global variable for use locally.
In Perl you should use 'my' to localise variables.
------------------------------
Date: Thu, 13 Nov 2003 14:53:39 +0100
From: "Poul Kornmod" <pkornmod@hotmail.com>
Subject: Mail::MboxParser trouble
Message-Id: <3fb38ce5$0$29316$edfadb0f@dread15.news.tele.dk>
Dear all,
I have had real trouble implementing Mail::MboxParser in my environment. The
installation went perfect and all the tests succeeded! But whenever I try to
call my little test (ripped from the manual) I got this error:
DEBUG (Mail::Mbox::MessageParser): Preparing file handle
Can't use an undefined value as a symbol reference at
/usr/local/lib/perl5/site_perl/5.8.0/Mail/Mbox/MessageParser.pm line 194.
DEBUG (Mail::Mbox::MessageParser): Exiting and writing cache if necessary
I identified the problem to be with the gensym call in the MboxParser.pm. If
I altered the code to use the Filehandle module instead of the Symbol - the
code just ran without any problems. Do any of you guys have had similar
problems?
Regards
Poul Kornmod
<example.pl>
#!/usr/bin/perl
#
#
use Mail::MboxParser;
my $parseropts = {
enable_cache => 1,
enable_grep => 1,
debug => 1,
cache_file_name => 'cache-file',
};
my $mb = Mail::MboxParser->new('My_Mbox',
decode => 'ALL',
parseropts => $parseropts
);
# -----------
# slurping
for my $msg ($mb->get_messages) {
print $msg->header->{subject}, "\n";
$msg->store_all_attachments(path => '');
}
</example.pl>
<Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:>
Platform:
osname=linux, osvers=2.4.7-10, archname=i686-linux
uname='linux cphzt-linux 2.4.7-10 #1 thu sep 6 17:27:27 edt 2001 i686
unknown '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags
='-fno-strict-aliasing -I/usr//include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BI
TS=64 -I/usr/include/gdbm',
optimize='-O3',
cppflags='-fno-strict-aliasing -I/usr//include -I/usr/include/gdbm'
ccversion='', gccversion='3.1', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.2.4.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.4'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under linux
Compiled at Oct 7 2002 07:07:11
@INC:
/usr/local/lib/perl5/5.8.0/i686-linux
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl
</Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:>
------------------------------
Date: 13 Nov 2003 06:04:23 -0800
From: rvw_torch@hotmail.com (Torch)
Subject: Meaning of ` signs
Message-Id: <d774347.0311130604.69aa764a@posting.google.com>
Hey again all. I have progressed a great deal with the basics of perl.
I have however a question were I do not seem to get the awnser of.
It has to do with appointing a value to a variable. This is the last
part of a program which I am trying to understand
My question:
The value given to the variable $STR is given in between ` signs.
What does this mean?
my $STR = `sqlplus -s $ORASTR >$f <<END
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET LINESIZE 127
SET HEADING OFF
SET FEEDBACK OFF
SET ECHO OFF
SET TAB OFF
SET COLSEP |
$Q
`;
When I try to display the value of $STR I get nothing
I am not really interested in what this variable does, I can probably
find that out myself. I am more interested in de function of the `
signs
Thx alot for all your help people! It really makes a difference!
------------------------------
Date: 12 Nov 2003 22:08:49 -0800
From: rband@yahoo.com (rband)
Subject: Need help with a program
Message-Id: <1618337a.0311122208.6b653675@posting.google.com>
People,
Need your help with a problem.
I need a program that will
1. take two input files of strings, file1 and file2.
2. read strings one by one from file1, and search for strings in
file2 that contain the string in file1 and append these to output
file3.
Probably a simple problem for perl gurus, but I am a complete novice
...
Appreciate any help ...
Thanks.
robin
------------------------------
Date: Thu, 13 Nov 2003 19:24:46 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: Need help with a program
Message-Id: <bov850$1hvu10$1@ID-172104.news.uni-berlin.de>
"rband" <rband@yahoo.com> wrote in message
news:1618337a.0311122208.6b653675@posting.google.com...
> People,
>
> Need your help with a problem.
> I need a program that will
> 1. take two input files of strings, file1 and file2.
> 2. read strings one by one from file1, and search for strings in
> file2 that contain the string in file1 and append these to output
> file3.
>
> Probably a simple problem for perl gurus, but I am a complete novice
> ...
> Appreciate any help ...
Is this a homework question?
------------------------------
Date: Thu, 13 Nov 2003 11:02:15 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Need help with a program
Message-Id: <20031113055831.22039db5.jwillmore@remove.adelphia.net>
On 12 Nov 2003 22:08:49 -0800
rband@yahoo.com (rband) wrote:
> People,
Well ... now that's the first time I've seen that as a salutation in
this group. Lucky for you (and AFAIK) that cats and dogs don't read
this newsgroup :-)
> Need your help with a problem.
> I need a program that will
> 1. take two input files of strings, file1 and file2.
At the command line, type the following commands to get documentation
related (closely and distant) to this question.
perldoc -f open
perldoc -q open
perldoc -q file
perldoc perlfaq5
This *should* get you started.
> 2. read strings one by one from file1, and search for strings in
> file2 that contain the string in file1 and append these to output
> file3.
Ditto.
>
> Probably a simple problem for perl gurus, but I am a complete novice
Maybe. Maybe not. I'll never tell :-) Seriously, it is a simple
task. And I have provided some resources for you to find the answer
for your simple problem. You *could* also try Google. Perhaps
someone wrote the code for you.
> ...
> Appreciate any help ...
And this was *any* help offered :-)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
When in doubt, do what the President does -- guess.
------------------------------
Date: Thu, 13 Nov 2003 09:41:36 +0000
From: Jim Mozley <jim.mozley@exponential-e.com>
Subject: Re: Net::SMTP on Windows 2000. I'm stuck!
Message-Id: <bovjkl$1imabd$1@ID-201189.news.uni-berlin.de>
Just Me wrote:
> I'm using ActivePerl 5.6. Everything I read says I need to "use Net::SMTP"
> but use is not a valid command from Windows, and in PPM it is an unknown or
> ambiguous.
>
> I can not for the life of me figgure out how to "Use" the Net::SMTP module,
> or the Net-SMTP-Server-Clinet2 module from Windows, PPM or from within
> another script. Where should this "use" command be entered?
You use the module within your script so you have:
use Net::SMTP;
near the beginning of you script.
If you need to get the module on your windows machine then from the dos
command line type ppm to get into the perl package manager and then
search smtp to find the exact name (probably net-smtp), then install
net-smtp.
The new learning perl objects, references & modules book from O'Reilly
is worth getting for learning this stuff.
Jim
------------------------------
Date: Thu, 13 Nov 2003 11:42:45 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Newbie wants to flock
Message-Id: <bovqnl$qb3$1@wisteria.csv.warwick.ac.uk>
"Dick Rosser" <spammerswelcome@aol.com> wrote:
> Thanks Ben
> The script runs a search on a flatfile database containing
> 'where are you now' type messages.
> The database can be accessed by both the message poster
> to change/delete/update his/her posted message. (Using a
> different script which does have flock implemented)
> and it can also be accessed by 'searchers' looking at the
> message - using this script.
>
> At the risk of being terribly boring I have appended the script
> below. Perhaps you would be kind enough to point me in the
> right direction.
I have included here some general advice that will make your program
more robust and easier to maintain. If you don't care about this,
don't really know Perl, and just want to get it working, then you only
need include the 'use Fcntl' and the 'flock' lines. :)
> #!/usr/bin/perl
use warnings;
use strict;
# add other 'use' statements here: see below
'use strict' means that all your variables will need to be declared
with 'my' the first time you use them. So, for instance, you will need
to change this line
> $charset = "";
to
my $charset = "";
. %ENV, %SIG, and the single-punctuation-character variables (and the
others listed in 'perldoc perlvar') are exempt from this.
<snip>
> # Parse Form Contents
> &parse_form;
As a general rule, you should not call subs with an initial '&' in
Perl5. Either use
parse_form();
or add
use subs qw/parse_form search etc./;
at the top and simply call it with
parse_form;
. (NB that 'etc.' isn't meant literally... :)
>
> if ($ENV{'REQUEST_METHOD'} ne 'POST') {
> if (!$ARGV[0] && $ENV{'QUERY_STRING'} !~ /=/) {
> $in{'template'} = $ENV{'QUERY_STRING'};
> $in{'opendb'} = 1;
> }
> elsif ($ARGV[0]) {
> $in{'template'} = $ARGV[0];
> $in{'opendb'} = 1;
> }
> }
It is generally a bad idea to parse CGI stuff yourself: there are many
subtleties, and it is easy to make mistakes. A much better idea would
be to add
use CGI;
or
use CGI::Lite;
at the top, and then read 'perldoc CGI' to see how to extract the
paramaters using that module.
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
> if ($mday < 10) {
> $mday = "0$mday";
> }
> $month = ($mon + 1);
> if ($month < 10) {
> $month = "0$month";
> }
> $year = 1900 + $year;
> $us_date = "$month/$mday/$year";
> $europe_date = "$mday/$month/$year";
You may want to investigate 'strftime' in 'perldoc POSIX', rather than
doing this by hand.
> open(DB,"$database_dir$dbname");
*Always* check the return value of open.
open DB, "$database_dir$dbname" or die "can't open database: $!";
You may want to read 'perldoc CGI::Carp' for a way to send the errors
somewhere sensible in a CGI context.
This is where you actually do the locking. You need
use Fcntl qw/:flock/;
at the top, and then here you put
flock DB, LOCK_SH or die "can't get lock: $!";
here. This will wait until any writing processes have finished (more
precisely, until any lock set with LOCK_EX has been unlocked), and
then lock the file for reading. If you want to be more sophisticated
than that, you will need to read about LOCK_NB in 'perldoc -f flock'.
<snip>
> open(DB,"$database_dir$dbname");
You don't want to re-open the file: you'll lose the lock. I think what
the script is trying to do is go back to the beginning, which is
better achieved by changing the Fcntl line above to
use Fcntl qw/:flock :seek/;
and then using
seek DB, 0, SEEK_SET or die "can't seek back to start: $!";
.
<snip the rest>
[in future, please include a *trimmed* quote above rather than below
your post]
Ben
--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else * ben@morrow.me.uk
------------------------------
Date: Thu, 13 Nov 2003 12:23:30 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Newbie wants to flock
Message-Id: <bovt42$r8p$3@wisteria.csv.warwick.ac.uk>
Eric Schwartz <emschwar@pobox.com> wrote:
> Ben Morrow <usenet@morrow.me.uk> writes:
> > (I note you assume this is in a CGI context :)
>
> Yes, bad Eric, no biscuit.
...you were right, of course :)
Ben
--
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die. |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-| ben@morrow.me.uk
------------------------------
Date: Thu, 13 Nov 2003 13:25:18 -0000
From: "Dick Rosser" <spammerswelcome@aol.com>
Subject: Re: Newbie wants to flock
Message-Id: <DCLsb.138$Et2.0@newsfep3-gui.server.ntli.net>
"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:bovqnl$qb3$1@wisteria.csv.warwick.ac.uk...
> [in future, please include a *trimmed* quote above rather than below
> your post]
Many thanks for your time and the pointers given.
Anything I can do to return the favour?
Dick Rosser
------------------------------
Date: Thu, 13 Nov 2003 06:09:04 GMT
From: wherrera@lynxview.com (William Herrera)
Subject: Re: OLE and Internet Explorer
Message-Id: <3fb32010.185350245@news2.news.adelphia.net>
On Tue, 11 Nov 2003 15:15:19 -0600, "newshost.cc.utexas.edu"
<r.brooks@mail.uhs.utexas.edu> wrote:
>Hello, does anyone know how to read client side cookies from client itself
>using Win32::OLE and InternetExplorer?
>
>
I think what you really need _might_ be on CPAN as HTTP::Cookies::Microsoft
---
Use the domain skylightview (dot) com for the reply address instead.
------------------------------
Date: 13 Nov 2003 11:14:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: problem with if-else assignment in text database
Message-Id: <bovp2d$lev$1@mamenchi.zrz.TU-Berlin.DE>
Schlick <invalid@invalid.com.invalid> wrote in comp.lang.perl.misc:
> Tad McClellan wrote:
>
> > Vumani Dlamini <dvumani@hotmail.com> wrote:
> >
> >
> >
> >>Thanks again guys, hope you don't get tired of me, like Ted.
> >
> >
> >
> > To avoid becoming wearysome, simply see the Posting Guidelines
> > that are posted here frequently...
> >
> >
>
> To become wearisome, simply quote them in every single one of your messages.
We're not here to entertain you, we want a workable newsgroup.
Anno
------------------------------
Date: Thu, 13 Nov 2003 11:48:50 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: problem with if-else assignment in text database
Message-Id: <bovr32$qb3$2@wisteria.csv.warwick.ac.uk>
dvumani@hotmail.com (Vumani Dlamini) wrote:
> Thanks again guys, hope you don't get tired of me, like Ted.
It's generally considered courteous to get people's names right,
especially when they're trying to help you.
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: Thu, 13 Nov 2003 11:56:12 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Problem with IO::Socket::INET and pop
Message-Id: <bovrgs$qb3$3@wisteria.csv.warwick.ac.uk>
"A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote:
> IIRC, $@ is the relevant variable for socket errors.
I don't think you do... there is nothing in perlvar or perlipc or
IO::Socket (that I can find) that implies this. I think you may be
thinking of
| Additionally, if the "h_errno" variable is supported in C, its value
| is returned via $? if any "gethost*()" function fails.
from perlvar?
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: 13 Nov 2003 05:26:55 -0800
From: unixverse@yahoo.com (Joe)
Subject: Re: Problem with IO::Socket::INET and pop
Message-Id: <fcc97b00.0311130526.fe5e615@posting.google.com>
Ben Morrow <usenet@morrow.me.uk> wrote in message news:<boueo5$9cp$1@wisteria.csv.warwick.ac.uk>...
> unixverse@yahoo.com (Joe) wrote:
> > # Connect to the POP server using port 110
> > $SocketHandle = IO::Socket::INET->new (Proto=>"tcp",
> > PeerAddr=>$ServerName, PeerPort=>$Port);
> >
> > if (!$SocketHandle)
> > {
> > # Customized Error Function
> > Error("cannot connect to port <B>$Port</B> on <B>$ServerName</B>",
> > "Back");
> >
> > exit(0);
> > }
> >
> > The web hosting company keeps telling me that they didn't change
> > anything and that they can connect fine via telnet ServerName 110.
> >
> > Was this code correct to begin with? Maybe I used some functionality
> > that has been deprecated since? Is there a way to better debug and
> > find out why !$SocketHandle is returned?
>
> You need to include $! in the error message so you (and we) have a
> better idea of what's going wrong.
>
> Ben
For $! I get 'Bad file number' and for $@ 'IO::Socket::INET: Connection refused'
Thanks,
Joe
------------------------------
Date: 13 Nov 2003 05:27:19 -0800
From: unixverse@yahoo.com (Joe)
Subject: Re: Problem with IO::Socket::INET and pop
Message-Id: <fcc97b00.0311130527.6faaa526@posting.google.com>
"A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote in message news:<Xns9431E16F41CF4asu1cornelledu@132.236.56.8>...
> Ben Morrow <usenet@morrow.me.uk> wrote in news:boueo5$9cp$1
> @wisteria.csv.warwick.ac.uk:
>
> >
> > unixverse@yahoo.com (Joe) wrote:
> >
> >> # Customized Error Function
> >> Error("cannot connect to port <B>$Port</B> on <B>$ServerName</B>",
> >> "Back");
> ...
> > You need to include $! in the error message so you (and we) have a
> > better idea of what's going wrong.
>
> IIRC, $@ is the relevant variable for socket errors.
For $! I get 'Bad file number' and for $@ 'IO::Socket::INET: Connection refused'
Thanks,
Joe
------------------------------
Date: Thu, 13 Nov 2003 10:30:36 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Very newbie Q anout $,@ and %
Message-Id: <3FB34F3C.6577C58D@fujitsu-siemens.com>
Ben Morrow wrote:
> =
> "J=FCrgen Exner" <jurgenex@hotmail.com> wrote:
> > You can think of hashes in two ways. They are like arrays, except tha=
t they
> > allow arbitrary scalar values as indices.
> =
> Arbitrary *string* values.
Says who?
The camel book says: "... a scalar always contains a single value. This
value may be a number, a string, or a reference to another piece of
data. Or, there might even be no value at all, in which case the scalar
is said to be undefined."
But, although it also says "As we said earlier, a hash is just a funny
kind of array in which you look values up using key strings instead of
numbers.", let's give it a try:
my %hash =3D ();
$hash{0x10} =3D "Sixteen";
print $hash{16}, "\n";
-> Sixteen
And even
my %hash =3D ();
$hash{undef} =3D "Not defined";
print $hash{undef}, "\n";
-> Not defined
and ...
$a =3D 1;
$b =3D \$a;
my %hash =3D ();
$hash{$b} =3D "Reference to a";
print $hash{\$a}, "\n";
-> Reference to a
So, in all aspects, "scalar" is perfectly ok.
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Thu, 13 Nov 2003 12:17:26 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Very newbie Q anout $,@ and %
Message-Id: <bovsom$r8p$1@wisteria.csv.warwick.ac.uk>
Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com> wrote:
> Ben Morrow wrote:
> >
> > "Jürgen Exner" <jurgenex@hotmail.com> wrote:
> > > You can think of hashes in two ways. They are like arrays,
> > > except that they allow arbitrary scalar values as indices.
> >
> > Arbitrary *string* values.
>
> Says who?
Says the perl source, apart from anything else... :)
> The camel book says: "... a scalar always contains a single value. This
> value may be a number, a string, or a reference to another piece of
> data. Or, there might even be no value at all, in which case the scalar
> is said to be undefined."
Yes.
> But, although it also says "As we said earlier, a hash is just a funny
> kind of array in which you look values up using key strings instead of
> numbers.", let's give it a try:
>
> my %hash = ();
> $hash{0x10} = "Sixteen";
> print $hash{16}, "\n";
>
> -> Sixteen
Yes. The hash key is stringified, and both 16 and 0x10 stringify to
"16".
> my %hash = ();
> $hash{undef} = "Not defined";
> print $hash{undef}, "\n";
>
> -> Not defined
print keys %hash
-> undef
A bareword in the {} of a hash element is stringified.
> $a = 1;
> $b = \$a;
> my %hash = ();
> $hash{$b} = "Reference to a";
> print $hash{\$a}, "\n";
>
> -> Reference to a
Again, \$a stringifies to something like "SCALAR(0x8168544)", so this
works. Now try
use strict;
my $x = 1;
my %y;
$y{\$x} = 2;
my $z = (keys %y)[0];
print $$z;
-> Can't use string ("SCALAR(0x8154b70)") as a SCALAR ref while "strict
refs" in use
> So, in all aspects, "scalar" is perfectly ok.
I think not :)
Ben
--
Musica Dei donum optimi, trahit homines, trahit deos. |
Musica truces molit animos, tristesque mentes erigit. | ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras. |
------------------------------
Date: Thu, 13 Nov 2003 13:23:08 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Very newbie Q anout $,@ and %
Message-Id: <3FB377AC.C4B9D8A6@fujitsu-siemens.com>
Ben Morrow wrote:
> works. Now try
> =
> use strict;
Point taken.
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
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 5792
***************************************