[16983] in Perl-Users-Digest
Perl-Users Digest, Issue: 4395 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 21 11:05:27 2000
Date: Thu, 21 Sep 2000 08: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: <969548710-v9-i4395@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 21 Sep 2000 Volume: 9 Number: 4395
Today's topics:
Accessing Objects in an array <mike_hopkins_us@yahoo.kom>
Re: Accessing Objects in an array <anders@wall.alweb.dk>
Re: Archive File Attribute on NT <elephant@squirrelgroup.com>
Re: Candidate for the top ten perl mistakes list (Eric Bohlman)
Re: Candidate for the top ten perl mistakes list <jbroz@transarc.com>
DBI Not working the same in perl 5.6 <dwb1@home.com>
Re: DBI Not working the same in perl 5.6 <nico@monnet.to>
how to add months in Perl? yudelin@my-deja.com
Re: how to add months in Perl? <nico@monnet.to>
Re: How to use perl to read content of a gdbm file? <anders@wall.alweb.dk>
Re: Interpolation on the fly <nico@monnet.to>
Re: Interpolation on the fly <nico@monnet.to>
Re: Interpolation on the fly <nico@monnet.to>
Re: IP Address <ales.romaniuk@zag.si>
Re: Is this terribly inefficient? <steph@hotkey.net.au>
ITS BEYOND ME! <Chris%2BSaunders@one.net.au>
Re: ITS BEYOND ME! <bill.kemp@wire2.com>
Re: ITS BEYOND ME! <temp1@williamc.com>
Re: ITS BEYOND ME! (Abigail)
Re: ITS BEYOND ME! <Chris%2BSaunders@one.net.au>
mirror <marty@ias.fr>
Newbie - averages... ian_tait@my-deja.com
Re: Newbie - averages... <yanick@babyl.sympatico.ca>
newbie string chopping question <rickyfusion@nospamfusionserver.com>
Re: newbie string chopping question <rmore1@my-deja.com>
Newbie trying to parse CGI POST data <mflaherty2@earthlink.net>
Re: Newbie trying to parse CGI POST data <anders@wall.alweb.dk>
OT: humour [was: Archive File Attribute on NT] <elephant@squirrelgroup.com>
Re: Problem with CGI -- buffered output? <je@bton.ac.uk>
Re: RegEx Question <bart.lateur@skynet.be>
Re: storing HoH in database <rmore1@my-deja.com>
Temporarily change Record Separator <randy_734@my-deja.com>
Re: Temporarily change Record Separator <nico@monnet.to>
Re: Temporarily change Record Separator (Garry Williams)
Re: Temporarily change Record Separator (Gwyn Judd)
Re: Time help <sariq@texas.net>
Re: Unrecognized character \327 <anders@wall.alweb.dk>
Re: using awk with perl <mikelm@ameritech.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 21 Sep 2000 13:25:31 GMT
From: "Mike Hopkins" <mike_hopkins_us@yahoo.kom>
Subject: Accessing Objects in an array
Message-Id: <f%ny5.11039$nk3.525913@newsread03.prod.itd.earthlink.net>
I am not sure how to do this. I am using CGI.pm and have put several CGI
objects into an array.
I can not figure out how to access a specific object function in the array.
Doing this does not work :
print $objectArray[2]->param('item'); #Can any one tell me how to do this?
This does work to loop threw all:
foreach $obj (@objectArray)
{
print $obj->param('item');
}
I just cant find the syntax to get to a specific element.
------------------------------
Date: Thu, 21 Sep 2000 15:28:22 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Accessing Objects in an array
Message-Id: <s3oy5.8$v4.447@news000.worldonline.dk>
Mike Hopkins wrote:
> I am not sure how to do this. I am using CGI.pm and have put several CGI
> objects into an array.
> I can not figure out how to access a specific object function in the
> array.
>
>
>
> Doing this does not work :
> print $objectArray[2]->param('item'); #Can any one tell me how to do
> this?
>
> This does work to loop threw all:
> foreach $obj (@objectArray)
> {
> print $obj->param('item');
> }
>
> I just cant find the syntax to get to a specific element.
>
>
perldoc perlref
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Thu, 21 Sep 2000 21:33:35 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: Archive File Attribute on NT
Message-Id: <MPG.14349d19e72eb07c9897c2@localhost>
tanya_ellis@my-deja.com wrote ..
>In article <MPG.1432a6b1b495b8e59897be@localhost>,
> jason <elephant@squirrelgroup.com> wrote:
>> tanya_ellis@my-deja.com <tanya_ellis@my-deja.com> wrote ..
>> >I would like to delete a list of files on NT
>> >which dont have the Archive File Attribute
>> >checked. (If the file is unchecked I know it has
>> >been backed up to tape and can now be deleted.)
>> >I have looked around for a file test operator to
>> >check the archive attribute but far so
>> >unsuccessful.
>> >
>> >can anyone help?
>>
>> (assuming you're using the standard Perl port for Win32)
>>
>> go to your pretty HTML documentation provided by ActiveState .. scroll
>> down the table of contents to the section containing the Win32 modules
>> .. then take a guess which one of the Win32 modules might help you
>find
>> out about file attributes
>>
>> click on it and read the information on the right
>>
>> repeat process for any other questions before asking them here
-
>well by the sounds of it I must apologise for asking such a dumb
>question. I was always lead to believe that there are no dumb
>questions. I also believed that this site is a place to share knowledge
>not only between experts but those trying to learn perl. By the looks
>of it I am not only dumb but wrong!
no apology required .. the only requirement here is an ability to learn
>But thank you jason for your "tip" - I had already found this. But
>oblivious I need more help! May be if the html documentation had more
>examples I would not have to correspond with the so called experts like
>you on this site!
ahh .. so you've already read the documentation for Win32::File .. how
would anyone guess that when you said that you'd "looked around for a
file test operator to check the archive attribute" ??
might I suggest that if you've read the docs and were simply after
an example then your query would have been better served with a question
along the lines of this...
"I have read the Win32::File documentation, but I really don't
understand how I'm meant to use GetAttributes to find out whether a
given file has the Archive bit set. There are no examples, and I'm still
learning so the docs are a little to vague. Can someone steer me in the
right direction ?"
to which you would have received a response something like this
#!/usr/bin/perl -w
use strict;
use Win32::File qw/GetAttributes ARCHIVE/;
my $file = 'foo.txt';
my $attrib = 0;
GetAttributes( $file, $attrib ) or die "Error: $!";
print "Archive not set\n" unless $attrib & ARCHIVE;
__END__
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 21 Sep 2000 10:28:57 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <8qcnt9$qo9$1@slb3.atl.mindspring.net>
Henry Hartley (hartleh1@westat.com) wrote:
: Russ Jones wrote:
: >
: > How often have you seen the word "seldomly?"
:
: Seldomly.
: :)
And how oftenly is that?
------------------------------
Date: Thu, 21 Sep 2000 15:25:05 +0100
From: "Joe_Broz@transarc.com" <jbroz@transarc.com>
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <39CA1A41.A85A66A8@transarc.com>
Russ Jones wrote:
>
> Abigail wrote:
> >
> > Russ Jones (russ_jones@rac.ray.com) wrote on MMDLXXVII September MCMXCIII
> > in <URL:news:39C8DD4C.2FD4B394@rac.ray.com>:
>
> > || Seldomly?
> >
> > How often do you see a program here where the cause of something not
> > working was the use of @array[$index] vs $array[$index]?
> >
>
> How often have you seen the word "seldomly?"
Do you speak any languages other than English? I think (but I'm guessing)
that Abigail does, and I don't think English was the first.
------------------------------
Date: Thu, 21 Sep 2000 11:30:08 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: DBI Not working the same in perl 5.6
Message-Id: <Pine.LNX.4.20.0009210612440.15842-100000@ethyl.addictmud.org>
Hello,
I asked for advice on any known issues with upgrading to perl 5.6
for existing scripts, and after testing, it went pretty much
without issue.
We are having one issue, but it's more an inconvience then a
problem.
With the Oracle DBD, when there is an error, we get messages like:
"ORA-00904: invalid column name (DBD ERROR: OCIStmtExecute/Describe)"
As most of you would probably expect. The problem is, previous
versions would also give the statement that was executed, and highlight
where the error was, for example:
ORA-00904: invalid column name (DBD: error possibly near <*> indicator at char 17 in 'select count(*),<*>a from accountuser')
Now, the differences between the 2 machines that I ran tests to
get those errors from are:
Machine 1:
perl 5.6
oracle 8i (8.1.6)
Machine 2:
perl 5.005_03
oracle 7.3.4
The are running the same version of DBI (1.14) and DBD::Oracle (1.06).
My first suspect is probably Oracle version that is the problem, but
I thought I would run it by everybody and see if anyone knows of any
switch or something that would help me get the error output I'm
looking for.
Thanks in advance,
Dan.
------------------------------
Date: Thu, 21 Sep 2000 16:51:12 +0100
From: "Nicolas MONNET" <nico@monnet.to>
Subject: Re: DBI Not working the same in perl 5.6
Message-Id: <Ylpy5.793$86.21600@tengri.easynet.fr>
That's interesting, I've never used it but with 5.6.0 and indeed
I would like to have a more detailed error message if at all
possible; I would suggest that you post your question to the
DBI mailing list. You're much more likely to get a response
there.
In article <Pine.LNX.4.20.0009210612440.15842-100000@ethyl.addictmud.org>,
"Daniel W. Burke" <dwb1@home.com> wrote:
>
> Hello,
>
> I asked for advice on any known issues with upgrading to perl 5.6 for
> existing scripts, and after testing, it went pretty much without issue.
>
> We are having one issue, but it's more an inconvience then a problem.
>
> With the Oracle DBD, when there is an error, we get messages like:
>
> "ORA-00904: invalid column name (DBD ERROR: OCIStmtExecute/Describe)"
>
> As most of you would probably expect. The problem is, previous versions
> would also give the statement that was executed, and highlight where the
> error was, for example:
>
> ORA-00904: invalid column name (DBD: error possibly near <*> indicator
> at char 17 in 'select count(*),<*>a from accountuser')
>
> Now, the differences between the 2 machines that I ran tests to get
> those errors from are:
>
> Machine 1:
> perl 5.6 oracle 8i (8.1.6)
>
> Machine 2:
> perl 5.005_03 oracle 7.3.4
>
> The are running the same version of DBI (1.14) and DBD::Oracle (1.06).
> My first suspect is probably Oracle version that is the problem, but I
> thought I would run it by everybody and see if anyone knows of any
> switch or something that would help me get the error output I'm looking
> for.
>
> Thanks in advance, Dan.
>
>
------------------------------
Date: Thu, 21 Sep 2000 14:39:06 GMT
From: yudelin@my-deja.com
Subject: how to add months in Perl?
Message-Id: <8qd6i7$rda$1@nnrp1.deja.com>
Hi,
Does Perl have a function (or Module) can do adding months easily? What
I am looking for is some function similar to add_months(d,n) function in
Oracle, so you can just put a date (d) and the number of months(n) and
get a results back. For example, a date of '31-mar-00' with n= "-1"
should give you '29-feb-00' (be able to take care of leap year issue),
not '31-feb-00' or '28-feb-00'.
Can Date::Calc do this?
Thanks for any help.
Yude
ylin@tradeloop.com
www.tradeloop.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 21 Sep 2000 16:51:50 +0100
From: "Nicolas MONNET" <nico@monnet.to>
Subject: Re: how to add months in Perl?
Message-Id: <xmpy5.794$86.21600@tengri.easynet.fr>
In article <8qd6i7$rda$1@nnrp1.deja.com>, yudelin@my-deja.com wrote:
> Can Date::Calc do this?
I think so.
------------------------------
Date: Thu, 21 Sep 2000 15:07:35 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: How to use perl to read content of a gdbm file?
Message-Id: <FLny5.11$s4.486@news010.worldonline.dk>
Carfield Yim wrote:
> As title, I write the following simple code in order to read the
> content of my gdbm file, but report cannot open the dbm file:
>
> sub printDBM {
> dbmopen(%dbm, $_[0], undef) || die "cannot open $_[0] for
> read\n";
>
> foreach $key (keys %dbm) { # step through all values
> print "$key\t%dbm{$key}\n";
^ $hash{$valu}, right?
> }
>
> dbmclose(%dbm);
> }
>
> I can sure that the path is correct, and everyone have read permission.
>
> Besides, How can I see the error message of why I can't open the file
> for read??
>
Run from the shell (unfortunate windows users (maybe) knows the "dos
window")
$perl myscript.pl
If no message appears, there is no error, but note above...
-anders
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Thu, 21 Sep 2000 16:55:44 +0100
From: "Nicolas MONNET" <nico@monnet.to>
Subject: Re: Interpolation on the fly
Message-Id: <cqpy5.795$86.21600@tengri.easynet.fr>
In article <slrn8sjecj.5fq.abigail@alexandra.foad.org>, abigail@foad.org
(Abigail) wrote:
> package deferred_interpolation;
Perl's semantics is still way too readable, even with this.
------------------------------
Date: Thu, 21 Sep 2000 16:57:41 +0100
From: "Nicolas MONNET" <nico@monnet.to>
Subject: Re: Interpolation on the fly
Message-Id: <0spy5.796$86.21600@tengri.easynet.fr>
In article <slrn8sibu9.1tk.tjla@thislove.dyndns.org>,
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:
> No you should be right to use interpolation. The magic you are looking
> for is called "eval". See the documentation:
>
> perldoc -f eval
>
> $fmt = '"User: $user\n"';
> print eval $fmt;
> $user = 'tom';
> print eval $fmt;
Needless to say, he who uses this kind of construct
with $user a user provided value in any kind of interactive
program, and most specifically CGIs, is bound to experience
various security issues ...
------------------------------
Date: Thu, 21 Sep 2000 16:59:23 +0100
From: "Nicolas MONNET" <nico@monnet.to>
Subject: Re: Interpolation on the fly
Message-Id: <Ctpy5.797$86.21600@tengri.easynet.fr>
In article <slrn8sj1k4.5fq.abigail@alexandra.foad.org>, abigail@foad.org
(Abigail) wrote:
> I can fix that:
Too late.
------------------------------
Date: Thu, 21 Sep 2000 12:52:21 +0200
From: Marvin <ales.romaniuk@zag.si>
Subject: Re: IP Address
Message-Id: <MPG.143406d25eee6c3098968e@news.siol.net>
In article <8qa838$bd1$1@nnrp1.deja.com>, mtaylorlrim@my-deja.com
says...
> If reverse host lookups are enabled on the web server, the environment
> variables $ENV{REMOTE_HOST} and $ENV{REMOTE_ADDR} contains the
> information you seek.
>
> Mark
>
>
>
> In article <MPG.14325fd11004d18698968a@news.siol.net>,
> Marvin <ales.romaniuk@zag.si> wrote:
> > Hello !
> >
> > I would like to make a CGI form and that every person can submit only
> > once. Is there any function that returns IP of remote host properly
> > (remote_addr() returns always "").
> >
> > Thanks
> >
>
> --
> Please reply to this newsgroup as my Deja mail
> is used as a spam catcher only!
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Thanks, that is what I was looking for.
------------------------------
Date: Fri, 22 Sep 2000 01:01:32 +1000
From: "Stephan Carydakis" <steph@hotkey.net.au>
Subject: Re: Is this terribly inefficient?
Message-Id: <39ca1373$1@news.iprimus.com.au>
Hiya,
Well, all of this should give me something to do for a few months. Thanks to
all who posted a reply. There's a multitude of info here.
Stephan Carydakis
------------------------------
Date: Thu, 21 Sep 2000 20:35:02 +1000
From: "Chris Saunders" <Chris%2BSaunders@one.net.au>
Subject: ITS BEYOND ME!
Message-Id: <39c9e424@pink.one.net.au>
Hiya,
I am a graphic designer, which means that (for now at least) I am a
not-particularly-brilliant web-designer. And my perl skills are
non-existent. I've managed to cheat, however, by downloading a freebee from
an address I got from a link through Dreamweaver.
My problem: I have tried to create a form for the first time. Done it ok,
and downloaded a perl script that seems to have the features I need (judging
by the descriptions), but its readme talks about server cgi_bins and so
forth.
WTF? Is it referring to a Unix machine, in which case I know nothing about
it.
I am just a poor little button clicker trying to set up a form, I have some
programming knowledge, but not in perl or any scripting.
How can I use this script (or any other that I dl) to process my form (just
a simple post to my email address)?
Anyone that can help me I will be more than happy to provide you with any
equal graphic design services to compensate your time and expertise.
I have a copy of the form (the whole website if you want it, its only about
600kb) and the script (13k) with its readme files.
Seriously, I would be so grateful to anyone that could help me out here, its
a business website, and I'm tryna construct an order form for a new
business.
Post me personally, or reply in the group, I don't mind.
Many thanks in advance, (and even more afterwards, ;)
Chris Saunders GRAPHIC DESIGNER
email chrissaunders@one.net.au
Ph 07 3899 0805
or mob 0438 197 726
ICQ 86067638
------------------------------
Date: Thu, 21 Sep 2000 12:01:41 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: ITS BEYOND ME!
Message-Id: <969534361.1610.0.nnrp-07.c3ad6973@news.demon.co.uk>
<snip>
>by the descriptions), but its readme talks about server cgi_bins and so
>forth.
>
>WTF? Is it referring to a Unix machine, in which case I know nothing about
>it.
You really are at square one and have lots to do, but the cgi-bin is really
just a directory on the server with programs or perl scripts in it.
>Anyone that can help me I will be more than happy to provide you with any
>equal graphic design services to compensate your time and expertise.
Chances are you need to either spend lots of time reading about this and
messing about, pay, or find a friend who can do it.
Its not like we could answer one or two questions and you'd be sorted out.
------------------------------
Date: Thu, 21 Sep 2000 12:15:10 GMT
From: PropART <temp1@williamc.com>
Subject: Re: ITS BEYOND ME!
Message-Id: <39C9FA56.DFA1EDFB@williamc.com>
Hello Chris,
Just have time for a quick response but can send you some references
later. I started out with the same background as you and took the
following approach:
Most ISP's have a form to e-mail program already set up (possibly
cgiemail) with a simple list of instructions. All you really have to do
is create a template for the order sheet that will be sent to you from
your server and correctly reference the cgi program.
Later I learned Perl and JavaScript, but back then I was able to get it
working very quickly and it was good enough for my company at the time.
--WmC.
------------------------------
Date: 21 Sep 2000 14:37:48 GMT
From: abigail@foad.org (Abigail)
Subject: Re: ITS BEYOND ME!
Message-Id: <slrn8sk77k.5fq.abigail@alexandra.foad.org>
Chris Saunders (Chris%2BSaunders@one.net.au) wrote on MMDLXXVIII
September MCMXCIII in <URL:news:39c9e424@pink.one.net.au>:
// Hiya,
// I am a graphic designer, which means that (for now at least) I am a
// not-particularly-brilliant web-designer. And my perl skills are
// non-existent. I've managed to cheat, however, by downloading a freebee from
// an address I got from a link through Dreamweaver.
//
// My problem: I have tried to create a form for the first time. Done it ok,
// and downloaded a perl script that seems to have the features I need (judging
// by the descriptions), but its readme talks about server cgi_bins and so
// forth.
//
// WTF? Is it referring to a Unix machine, in which case I know nothing about
// it.
//
// I am just a poor little button clicker trying to set up a form, I have some
// programming knowledge, but not in perl or any scripting.
//
// How can I use this script (or any other that I dl) to process my form (just
// a simple post to my email address)?
Go learn Perl. And if you need to do something on a Unix machine and need
Unix knowledge, go ahead and learn. Or perhaps you should hire someone
to do the work. Please don't come here to be spoon fed.
// Anyone that can help me I will be more than happy to provide you with any
// equal graphic design services to compensate your time and expertise.
//
// I have a copy of the form (the whole website if you want it, its only about
// 600kb) and the script (13k) with its readme files.
//
// Seriously, I would be so grateful to anyone that could help me out here, its
// a business website, and I'm tryna construct an order form for a new
// business.
All the more the reason to hire a professional.
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
------------------------------
Date: Fri, 22 Sep 2000 01:01:42 +1000
From: "Chris Saunders" <Chris%2BSaunders@one.net.au>
Subject: Re: ITS BEYOND ME!
Message-Id: <39ca22a4@pink.one.net.au>
Many thanks PropART.
I am using One Net and they've got a pretty extensive user-self-help
website, I'll have a look.
Thanks for your quick response.
Yes, I am at square one, but only in relation to Unix machines and scripts.
------------------------------
Date: Thu, 21 Sep 2000 14:51:02 +0200
From: Philippe Marty <marty@ias.fr>
Subject: mirror
Message-Id: <39CA0436.9798AEA1@ias.fr>
Hello,
J'ai un pb avec mirror 2.9 (script perl de sunsite qui permet de
faire un miroir d'un site ftp) : ce script marche avec les services
ftp standards (du type in.ftpd) mais pas avec le demon wu_ftpd en
particulier (j'ai essaye ce demon sous linux et sous HP). Il bloque
apres avoir fait CWD, au moment ou il tente de faire un listing
recursif du site a copier (LIST -lRat), ca part en timeout et ca
deconnecte.... Y a-t-il qqch a configurer sur mirror et/ou sur
wu.ftpd ?
HELP !
I'm having a problem with mirror 2.9 perl script (ftp site
mirroring tool from sunsite): it works well with built.in ftp
daemons but not with wu.ftpd daemon (it hangs after having done CWD
when trying to recursively list the site to mirror - LIST -lRat)...
Is there anything do configure either on mirror or on wu.ftpd ?
--
Philippe MARTY
------------------------------
Date: Thu, 21 Sep 2000 14:35:27 GMT
From: ian_tait@my-deja.com
Subject: Newbie - averages...
Message-Id: <8qd6bd$r42$1@nnrp1.deja.com>
Hi all,
I'm darned if I can figure out the right sintax
for this:
What I'm trying to do is to open a text file (I
can do this bit :-) that contains a column of
numbers eg,
33
33
44
55
and sum them, then to get an average of the
numbers, divide by the number of numbers present
(which changes).
I've looked through the faqs but can't find a
suitable reference :-(
Any pointers gratefully recieved.
Cheers,
Ian
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 21 Sep 2000 15:00:58 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: Newbie - averages...
Message-Id: <Kopy5.3832$vZ.236679@news20.bellglobal.com>
ian_tait@my-deja.com wrote:
: Hi all,
: I'm darned if I can figure out the right sintax
: for this:
: What I'm trying to do is to open a text file (I
: can do this bit :-) that contains a column of
: numbers eg,
: 33
: 44
: 55
: and sum them, then to get an average of the
: numbers, divide by the number of numbers present
: (which changes).
: I've looked through the faqs but can't find a
: suitable reference :-(
: Any pointers gratefully recieved.
perl -ne'$\+=$_;END{$\/=$.;print}' your_file
:)
Joy,
Yanick
--
eval" use 'that poor Yanick' ";
print map{ (sort keys %{{ map({$_=>1}split'',$@) }})[hex] }
qw/8 b 15 1 9 10 11 15 c b 13 1 12 b 13 f 1 c 9 a e b 13 0/;
------------------------------
Date: Tue, 19 Sep 2000 16:32:13 -0400
From: "Ric Smith" <rickyfusion@nospamfusionserver.com>
Subject: newbie string chopping question
Message-Id: <8q8iis$g6j$1@server.cntfl.com>
I left my camel book at home.
Is there a function to chop the characters off a
string after a specified character?
$string = "this is a line of text";
RemoveCharacters from $string after the
10th character yields.
$string = "this is a ";
Thanks.
--
Ric Smith
h_o_l_o_g_r_a_p_h_i_c
103 Meridian Street
Tallahassee, Florida 32301
http://www.holographic.com
------------------------------
Date: Thu, 21 Sep 2000 12:40:22 GMT
From: Rich More <rmore1@my-deja.com>
Subject: Re: newbie string chopping question
Message-Id: <8qcvjj$iks$1@nnrp1.deja.com>
In article <8q8iis$g6j$1@server.cntfl.com>,
"Ric Smith" <rickyfusion@nospamfusionserver.com> wrote:
> I left my camel book at home.
There is very good documentation online using the perldoc utility.
> Is there a function to chop the characters off a
> string after a specified character?
>
> $string = "this is a line of text";
>
> RemoveCharacters from $string after the
> 10th character yields.
>
> $string = "this is a ";
perldoc -f substr
In perl "There's more than one way to do it!"
$str = "1234567890ABCDEFG";
print substr($str,0,10),"\n";
print unpack("A10",$str),"\n";
print $str =~ m/(.{10})/ ,"\n";
--
=============================
Richard More
http://www.richmore.com/
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 21 Sep 2000 12:27:59 GMT
From: "Mike Flaherty" <mflaherty2@earthlink.net>
Subject: Newbie trying to parse CGI POST data
Message-Id: <j9ny5.13860$ks.530466@newsread1.prod.itd.earthlink.net>
I am trying to parse out POST elements from my HTML form. I am trying to
implemment a solution found at http://www.perlfaq.com/faqs/id/13 but I am
not having any luck. I'm sure I am overlooking something really simple.
This is my code below.
Thanks in Advance,
Mike
Westwood, MA
----------------------------------------------------------------------------
--
#!/usr/bin/perl
print "Content-type:text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
use CGI qw(:standard);
my $param1 = param('param1');
my $param2 = param('param2');
print "<html><head><title>Form Output</title></head><body>";
print "<h2>Results from FORM post</h2>\n";
print $param1;
print $param2;
print "</body></html>";
------------------------------
Date: Thu, 21 Sep 2000 14:56:11 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Newbie trying to parse CGI POST data
Message-Id: <ZAny5.14$l56.660@news000.worldonline.dk>
Mike Flaherty wrote:
> I am trying to parse out POST elements from my HTML form. I am trying to
> implemment a solution found at http://www.perlfaq.com/faqs/id/13 but I am
> not having any luck. I'm sure I am overlooking something really simple.
> This is my code below.
>
> Thanks in Advance,
>
> Mike
> Westwood, MA
>
>
----------------------------------------------------------------------------
>
----------------------------------------------------------------------------
> --
>
> #!/usr/bin/perl
>
> print "Content-type:text/html\n\n";
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>
> use CGI qw(:standard);
>
> my $param1 = param('param1');
> my $param2 = param('param2');
>
> print "<html><head><title>Form Output</title></head><body>";
>
> print "<h2>Results from FORM post</h2>\n";
>
> print $param1;
> print $param2;
>
> print "</body></html>";
>
>
Do some more reading...
You are confusing two methods:
1) do it from scratch, found in the perl faq (the read(...) thing) which is
good for learning, but requires some work.
2) use the CGI module - which is an excellent module, to read the docs for
it, use
$perldoc CGI
- or if your'e unfortunate enough to be on windows, look for the html
documentation...
Using CGI (object style) is like this:
use CGI;
my $q = new CGI;
my $a_param = $q->param('a_param');
# etc...
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Thu, 21 Sep 2000 21:42:26 +1000
From: jason <elephant@squirrelgroup.com>
Subject: OT: humour [was: Archive File Attribute on NT]
Message-Id: <MPG.14349f2cb30979569897c3@localhost>
H C wrote ..
>> (assuming you're using the standard Perl port for Win32)
>>
>> go to your pretty HTML documentation provided by ActiveState .. scroll
>> down the table of contents to the section containing the Win32 modules
>> .. then take a guess which one of the Win32 modules might help you find
>> out about file attributes
>>
>> click on it and read the information on the right
>>
>> repeat process for any other questions before asking them here
>
>Wow, what a jerk. You had so many opportunities available to you here,
>such as ignoring the question, or responding directly via email.
>
>Well, now we _all_ know how smart you are!
I hope the irony of your posts is escaping only you
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 21 Sep 2000 12:07:25 +0100
From: John English <je@bton.ac.uk>
Subject: Re: Problem with CGI -- buffered output?
Message-Id: <39C9EBED.416B47A0@bton.ac.uk>
nobull@mail.com wrote:
> Please consult the FAQ using the keywords "flush" or "unbuffer".
Ah, silly me. Apologies.
-----------------------------------------------------------------
John English | mailto:je@brighton.ac.uk
Senior Lecturer | http://www.it.bton.ac.uk/staff/je
Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
------------------------------
Date: Thu, 21 Sep 2000 13:16:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: RegEx Question
Message-Id: <m82kssc3rumbimou4q02k65ap6ar5j0c4v@4ax.com>
David Stanek wrote:
>Is there any way to do something like [^(</blockquote>)] so I can say get
>any character until it gets to </blockquote>?
The usual answer is to match using a nongreedy subpattern:
m~(.*?)(?=\z|</blockquote>)~s and print $1;
which will match everything up to the first "</blockquote>", or the end
of the string. But here is an alternative:
m~(([^<]+|<(?!/blockquote>))*)~s and print $1;
Here, the subpattern will match a repetition of any character but "<",
or a "<" provided it is not followed by "/lockquote>".
--
Bart.
------------------------------
Date: Thu, 21 Sep 2000 12:23:51 GMT
From: Rich More <rmore1@my-deja.com>
Subject: Re: storing HoH in database
Message-Id: <8qcuk3$ha9$1@nnrp1.deja.com>
In article <mcijsso1h1jva8e5et7edhke4br7pfvcdi@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> wrote:
> How would you store hashes of hashes in a database, in particular on
MS
> SQL server?
Try: Data::Dumper or FreezeThaw to stringify the hash.
From 'perldoc Data::Dumper'
The return value can be evaled to get back an identical copy
of the original reference structure.
--
=============================
Richard More
http://www.richmore.com/
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 21 Sep 2000 13:17:31 GMT
From: Randy <randy_734@my-deja.com>
Subject: Temporarily change Record Separator
Message-Id: <39ca086e.5491578@207.126.101.100>
Is there a better way to temporarily change the Record Separator in a
program? Both of these seem a bit clumsy.
{
local $/;
undef $/;
buncha statements here...
}
or...
$recsep=$/;
undef $/;
more code here...
$/=$recsep;
TIA
Randy Harris
------------------------------
Date: Thu, 21 Sep 2000 15:55:23 +0100
From: "Nicolas MONNET" <nico@monnet.to>
Subject: Re: Temporarily change Record Separator
Message-Id: <Dxoy5.786$86.21111@tengri.easynet.fr>
In article <39ca086e.5491578@207.126.101.100>, Randy
<randy_734@my-deja.com> wrote:
> Is there a better way to temporarily change the Record Separator in a
> program? Both of these seem a bit clumsy.
>
> {
> local $/; undef $/;
> buncha statements here...
> }
This is the best I think, does'nt seem to clumsy to me.
{
local $/ = undef;
# some shit
}
>
> or...
>
> $recsep=$/;
> undef $/;
> more code here...
> $/=$recsep;
>
> TIA Randy Harris
I find this last one more clumsy. Just a matter of preference.
------------------------------
Date: Thu, 21 Sep 2000 14:12:03 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Temporarily change Record Separator
Message-Id: <TGoy5.672$fa2.52652@eagle.america.net>
On Thu, 21 Sep 2000 15:55:23 +0100, Nicolas MONNET <nico@monnet.to> wrote:
>In article <39ca086e.5491578@207.126.101.100>, Randy
><randy_734@my-deja.com> wrote:
>> Is there a better way to temporarily change the Record Separator in a
>> program? Both of these seem a bit clumsy.
>>
>> {
>> local $/; undef $/;
>> buncha statements here...
>> }
>
>This is the best I think, does'nt seem to clumsy to me.
>
>{
> local $/ = undef;
> # some shit
>}
It's sufficient to say:
local($/);
See perldoc perlfunc and the section "Temporary Values via local()":
...
The argument list may be assigned to if desired, which allows you
to initialize your local variables. (If no initializer is given
for a particular variable, it is created with an undefined value.)
...
--
Garry Williams
------------------------------
Date: Thu, 21 Sep 2000 14:48:35 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Temporarily change Record Separator
Message-Id: <slrn8sk7u0.8b1.tjla@thislove.dyndns.org>
I was shocked! How could Randy <randy_734@my-deja.com>
say such a terrible thing:
>Is there a better way to temporarily change the Record Separator in a
>program? Both of these seem a bit clumsy.
>
>{
>local $/;
>undef $/;
> buncha statements here...
>}
This is probably the correct way to do what you want (without the
"undef" bit as local does that for you).
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Try not to have a good time... this is supposed to be educational.
-Charles Schulz (contributed by Chris Johnston)
------------------------------
Date: Thu, 21 Sep 2000 13:49:27 GMT
From: Tom Briles <sariq@texas.net>
Subject: Re: Time help
Message-Id: <39CA11E7.F0BA165@texas.net>
"John J. Trammell" wrote:
>
> On Wed, 20 Sep 2000 10:40:06 -0500, Tom Briles <sariq@texas.net> wrote:
> >"John J. Trammell" wrote:
> >>
> >> On Wed, 20 Sep 2000 14:54:30 +0100, Rui Miguel Venancio
> >> <rui.miguel@srd.alcatel.pt> wrote:
> >>
> >> >I have one variable with the system date (eg. 20000919 - YYYYMMDD),
> >> >And I have another variable with a date in the future
> >> >(eg: 20001005 - YYYYMMDD).
> >> >
> >> >I want to see a message if the second date have less than 4 weeks of
> >> >the first date !!!!
> >>
> >> You're looking for the Date::Calc module and its Delta_Days function.
> >
> >That's overkill. The formatted dates shown are very easily parsed for
> >input into the timelocal() function.
> >
>
> I've put it to the test; here's the output of my Benchmark:
>
> [ ~/test/time-001 ] ./foo.pl
> Benchmark: timing 10000 iterations of date-calc, time-local...
> date-calc: 2 wallclock secs ( 1.61 usr + 0.00 sys = 1.61 CPU)
> @ 6211.18/s (n=10000)
> time-local: 12 wallclock secs (11.76 usr + 0.00 sys = 11.76 CPU)
> @ 850.34/s (n=10000)
> [ ~/test/time-001 ]
>
> This is for routines that do identical parsing of strings, then either
> - call Date::Calc::Delta_Days
> - use Time::Local to calculate Epoch seconds, take the
> difference, and divide by 24*3600
> then use the result in a comparison against 28 days.
>
> Anyone able to confirm or deny this? Looks like Date::Calc is
> simpler and faster to me.
Since you don't show your code, it's impossible to comment on the
validity of your test.
You also haven't taken into consideration startup costs for including
Date::Calc, as well as installation costs (particularly since it
requires compilation from C).
- Tom
------------------------------
Date: Thu, 21 Sep 2000 15:01:15 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Unrecognized character \327
Message-Id: <IFny5.7$s4.486@news010.worldonline.dk>
udoline wrote:
> hi ,
>
> what's wrong in my code
>
> (i test my own filter more info www.cpan.org modules : Filter-1.18)
>
> Unrecognized character \327 at test.pe line 2.
>
Try using emacs...
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Thu, 21 Sep 2000 06:38:11 -0500
From: "The Ancient" <mikelm@ameritech.net>
Subject: Re: using awk with perl
Message-Id: <vpmy5.10600$US.234057@nntp0.chicago.il.ameritech.net>
I don't know why you want to use awk from your perl script but if you insist
on using awk
it by default splits on a whitespace. You want to split on a '=' Use:
/usr/local/apache/cgi-bin/printenv | grep REMOTE_ADDR|awk -F= '{print $2}'
<potato_salad@my-deja.com> wrote in message
news:8qaoq6$vi1$1@nnrp1.deja.com...
> I am wanting to use this line in a perl CGI script to grab the IP
> address of the users machine/firewall. when I run the below command
>
> /usr/local/apache/cgi-bin/printenv | grep REMOTE_ADDR|awk '{print $3}'
>
> it returns > REMOTE_ADDR = 200.200.200.2
>
> I want to cut everything but the 200.200.200.2 using awk. But it does
> not work that way.
>
> I am new to perl and any help would be great. Thanks, Yamar.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
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 4395
**************************************