[24354] in Perl-Users-Digest
Perl-Users Digest, Issue: 6543 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 8 14:05:44 2004
Date: Sat, 8 May 2004 11:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 8 May 2004 Volume: 10 Number: 6543
Today's topics:
Re: is there something more elegant to convert Dos to u <bik.mido@tiscalinet.it>
Re: is there something more elegant to convert Dos to u (Andrew)
newbie: need to put form data into associative array <root@localhost.localdomain>
Re: newbie: need to put form data into associative arra <1usa@llenroc.ude>
Re: newbie: need to put form data into associative arra <root@localhost.localdomain>
Re: newbie: need to put form data into associative arra <dave@nospam.net>
Re: newbie: need to put form data into associative arra <root@localhost.localdomain>
Re: Perl DBI and DB2 Stored Procedure <shirsch@adelphia.net>
Re: Spreadsheet::WriteExcel <sean_berry@cox.net>
timeout when reading from a server socket. (Darryl Perry)
Re: win32::ole and excel VBA macro conversion: SmallScr <invalid-email@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 08 May 2004 15:29:10 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: is there something more elegant to convert Dos to unix in subroutine?
Message-Id: <7vhp9094sgiout4cih86k0g4gfhfiapo9t@4ax.com>
On Mon, 03 May 2004 20:27:34 GMT, "Ala Qumsieh"
<xxala_qumsiehxx@xxyahooxx.com> wrote:
>> FWIW I customarily use
>>
>> perl -lpi.bak -e '' <files>
>
>Correct me if I'm wrong, but this doesn't work on *nix systems since the
>auto chomp() will only remove \n characters, leaving \r's intact.
[ashamed] Tes, you're right. I was implicitly doing a wrong
assumption. Though, what I do *really* customarily use (and *really*
works!) is
perl -lpi.bak -e "" <files>
in Win* environments on (possibly) *nix-line-terminated text files...
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: 8 May 2004 11:02:44 -0700
From: myfam@surfeu.fi (Andrew)
Subject: Re: is there something more elegant to convert Dos to unix in subroutine?
Message-Id: <c5826e91.0405081002.72e7f9b8@posting.google.com>
Ok, here is the next version, temp file stuff doesn't work on my CYGWIN
#
# Converts DOS to UNIX file
# if trim is true will trim leading and trailing spaces
#
sub toUnixFile {
my ($file, $trim) = @_;
-f $file || die "Can't open $file: $! \n";
my $temp_file = $file . ".tmp.$$.$^T";
move($file, $temp_file) || die "Can't move $file to $temp_file: $! \n";
open my $in, '<', "$temp_file" || die "Can't open $file: $! \n";
open my $out, '>', "$file" || die "Can't open $file: $! \n";
while(<$in>) {
s/[\r\n]+$//;
if ($trim eq "true") {
s/^\s+//;
s/\s+$//;
}
print $out "$_\n";
}
unlink $temp_file;
}
Uri Guttman <uri@stemsystems.com> wrote in message news:<x7ekpvtsth.fsf@mail.sysarch.com>...
> >>>>> "A" == Andrew <myfam@surfeu.fi> writes:
>
> A> Thanks for constructive remarks, here is the fixed one, which, again,
> A> works just fine :)
>
> and looks ugly too!
>
> A> sub toUnixFile {
> A> my ($file, $trim) = @_;
> A> -f $file || die "Can't open \"$file\": $! \n";
>
> lose the \ there. use an alternative delimiter
>
> A> my $temp_file = $file . ".tmp.$$.$^T";
>
> use the File::Temp module
>
> A> move($file, $temp_file);
> A> local *in;
> A> local *out;
>
> gack! use lexical filehandles. and glob handles are upper case by tradition
> A> open(in, "<$temp_file");
> A> open(out, ">$file");
>
> you check for the file with -f but not here? always check your open
> calls for failures
>
> A> while(<in>) {
> A> chomp;
> A> s/\r$//;
>
> why the chomp AND s///? s/[\r\n]+$// would work anywhere.
>
> A> if ($trim eq "true") {
> A> s/^\s*//;
> A> s/\s*$//;
> A> unless ( -z $_ ) {
>
> huh??!! what do you think -z does? this is perl, not shell.
>
> and if i get your logic (which is coded incorrectly), you want to not
> print lines that had only blanks. that means this is not a true dos2unix
> program since that is not part of the typical spec for that.
>
> A> print out "$_\n";
> A> }
> A> } else {
> A> print out "$_\n";
> A> }
>
> redundant code always bothers me. if you used next you could have that
> one print line for both cases.
>
>
> and you still top post.
------------------------------
Date: Sat, 08 May 2004 14:02:12 GMT
From: Little Monster <root@localhost.localdomain>
Subject: newbie: need to put form data into associative array
Message-Id: <d7aadb5cd87cbfc0729bc74e394521b7@news.teranews.com>
Hi all,
This must be a simple thing, but being very confused about CGI at the
moment, help appreciated. I need to accept POSTed form data, and put it
into an associative array. I can sort of see a long winded way of doing
it, but surely there must be a something that will do the equivalent of:
%FormData = CGI ->new();
Which appears not to work (or my form is horribly wrong!)
or need a way to turn @FormData into %FormData, whichever is easiest
You can see the current state of play at
http://www.the-monstruum.co.uk/quiz/quiz.html - not very impressive I know!
Tia,
Monster
--
I am the sexiest man in the UuuuKaaaayy
All the girls love me
And I will never grow Ooollldd
I am the sexiest man in the UuuKaaaay!
------------------------------
Date: 8 May 2004 14:53:20 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: newbie: need to put form data into associative array
Message-Id: <Xns94E36EC5AA1F3asu1cornelledu@132.236.56.8>
Little Monster <root@localhost.localdomain> wrote in
news:d7aadb5cd87cbfc0729bc74e394521b7@news.teranews.com:
> Hi all,
> This must be a simple thing, but being very confused about CGI at the
> moment, help appreciated. I need to accept POSTed form data, and put
> it into an associative array.
Reading the documentation is a good idea:
perldoc CGI
<blockquote>
Many people want to fetch the entire parameter list as a hash in which
the keys are the names of the CGI parameters, and the values are the
parameters' values. The Vars() method does this. Called in a scalar
context, it returns the parameter list as a tied hash reference. Changing
a key changes the value of the parameter in the underlying CGI parameter
list. Called in a list context, it returns the parameter list as an
ordinary hash. This allows you to read the contents of the parameter
list, but not to change it.
</blockquote>
Please read the rest of the docs. (Also available at:
http://search.cpan.org/~lds/CGI.pm-
3.05/CGI.pm#FETCHING_THE_PARAMETER_LIST_AS_A_HASH:
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Sat, 08 May 2004 15:14:13 GMT
From: Little Monster <root@localhost.localdomain>
Subject: Re: newbie: need to put form data into associative array
Message-Id: <6976ddc1fc8427fe1d49f1f06071ede6@news.teranews.com>
On Sat, 08 May 2004 14:53:20 +0000, the world was enlightented by A. Sinan
Unur, unto whom the words are attributed:
> Little Monster <root@localhost.localdomain> wrote in
> news:d7aadb5cd87cbfc0729bc74e394521b7@news.teranews.com:
>
>> Hi all,
>> This must be a simple thing, but being very confused about CGI at the
>> moment, help appreciated. I need to accept POSTed form data, and put
>> it into an associative array.
>
> Reading the documentation is a good idea:
>
> perldoc CGI
>
> <blockquote>
> Many people want to fetch the entire parameter list as a hash in which
> the keys are the names of the CGI parameters, and the values are the
> parameters' values. The Vars() method does this. Called in a scalar
> context, it returns the parameter list as a tied hash reference. Changing
> a key changes the value of the parameter in the underlying CGI parameter
> list. Called in a list context, it returns the parameter list as an
> ordinary hash. This allows you to read the contents of the parameter
> list, but not to change it.
> </blockquote>
>
> Please read the rest of the docs. (Also available at:
>
> http://search.cpan.org/~lds/CGI.pm-
> 3.05/CGI.pm#FETCHING_THE_PARAMETER_LIST_AS_A_HASH:
Hurrah, it works! (Though I couldn't find the doc at CPAN)
Big Thanks :-) (now are you going to take the test??)
MOnster
--
I am the sexiest man in the UuuuKaaaayy
All the girls love me
And I will never grow Ooollldd
I am the sexiest man in the UuuKaaaay!
------------------------------
Date: Sat, 8 May 2004 08:37:16 -0700
From: "Dave Oswald" <dave@nospam.net>
Subject: Re: newbie: need to put form data into associative array
Message-Id: <KLSdnUE1qJ6TYgHdRVn-tw@adelphia.com>
"Little Monster" <root@localhost.localdomain> wrote >
> Hurrah, it works! (Though I couldn't find the doc at CPAN)
> Big Thanks :-) (now are you going to take the test??)
That's so easy, I wouldn't admit to it if I weren't able to find it.
In your browser's address box type:
http://search.cpan.org
Next, in the CPAN search box type:
CGI
Click on the link to the module called CGI.
You will now see the CGI documentation, and you'll see how easy it is to
find module documentation. Now scan down the page a bit, and you'll find
the part about Vars().
------------------------------
Date: Sat, 08 May 2004 17:15:02 GMT
From: Little Monster <root@localhost.localdomain>
Subject: Re: newbie: need to put form data into associative array
Message-Id: <86d0f757a6fdcacac81cb3e1dc4433f2@news.teranews.com>
On Sat, 08 May 2004 08:37:16 -0700, the world was enlightented by Dave
Oswald, unto whom the words are attributed:
>
> "Little Monster" <root@localhost.localdomain> wrote >
>
>> Hurrah, it works! (Though I couldn't find the doc at CPAN)
>> Big Thanks :-) (now are you going to take the test??)
>
> That's so easy, I wouldn't admit to it if I weren't able to find it.
>
> In your browser's address box type:
> http://search.cpan.org
>
> Next, in the CPAN search box type:
> CGI
>
> Click on the link to the module called CGI.
>
> You will now see the CGI documentation, and you'll see how easy it is to
> find module documentation. Now scan down the page a bit, and you'll find
> the part about Vars().
That's really odd, search took me to (apparently) the exact same place
I looked before, and found it. I've gone either blind or stupd. Or both.
Monster
--
I am the sexiest man in the UuuuKaaaayy
All the girls love me
And I will never grow Ooollldd
I am the sexiest man in the UuuKaaaay!
------------------------------
Date: Sat, 08 May 2004 09:33:15 -0400
From: "Steven N. Hirsch" <shirsch@adelphia.net>
Subject: Re: Perl DBI and DB2 Stored Procedure
Message-Id: <ldGdnfwh6P0LfAHdRVn-sQ@adelphia.com>
Wonderinguy wrote:
> Hi everybody , I have been trying to execute a simple DB2 stored
> Procedure from perl. But it doesn't work. Could anybody please help me
> find out why this is happening :
>
> here is my perl script that execute the SP :
> <snip>
> my $dbh = DBI->connect( "dbi:DB2:$database","user1","passwd1") || die
> "cannot connect to db2";
> my $callstmt = "CALL SPACESP('DB','TEXAS')";
> my $sth = $dbh->prepare($callstmt) || die "can't do
> prepare",$dbh->errstr(),"\n";
> $sth->execute || die "Can't do executed:" , $dbh->errstr(),"\n";
DB2 needs some help in order to properly dispatch the call. Try
something like:
CALL SPACESP( CAST( ? AS VARCHAR(n)), CAST( ? AS VARCHAR(n)) )
for the prepared statement and bind your input to the placeholders:
$sth->bind_param( 1, 'DB', $attrib_char );
$sth->bind_param( 2, 'TEXAS', $attrib_char );
You will need to replace 'n' in the CAST expressions with a length
appropriate to what the actual stored-procedure is expecting. For all I
know, it may want CHAR rather than VARCHAR, so dig into it a bit.
BTW, this drove me nuts the first time I ran into it! The CLP
(command-line processor) is much smarter about call dispatching than a
prepared statement.
Steve
------------------------------
Date: Sat, 8 May 2004 10:32:55 -0700
From: "Sean Berry" <sean_berry@cox.net>
Subject: Re: Spreadsheet::WriteExcel
Message-Id: <TQ8nc.95193$Jy3.6707@fed1read03>
I would upgrade, bit there would be too many issues to deal with if I did.
For instance: the IO::Socket module is not backwards compatable, so any
program using it (lots of them) would be broken. The system admin already
had the SaveParser installed so I am almost certain that it should work.
The file is datad July of 2002. I am able to use the Parser and WriteExcel
mods with no problems.
"Bob Walton" <invalid-email@rochester.rr.com> wrote in message
news:409CD789.4030109@rochester.rr.com...
> Sean Berry wrote:
>
> ...
> > However, I tried a simple insert of one cell on a preformatted
spreadsheet
> > and it gave me the following error:
> >
> > Can't locate object method "set_print_scale" via package
> > "Spreadsheet::WriteExcel::Worksheet" at
> >
/usr/local/lib/perl5/site_perl/5.005/Spreadsheet/ParseExcel/SaveParser.pm
> > line 125.
> >
> > I am using perl 5.005. The module was already installed by the sytsem
>
> > admin, so what is the problem. Do I need a more recent version of the
> > SaveParser module???
>
> Do yourself and everyone else a huge favor and upgrade to a Perl that
> isn't years old. With that version of Perl, you probably need an
> *older* version of SaveParser, if there even was such a thing back then.
>
> Question: Are you using the docs that go with the versions of Perl and
> the various modules you are using?
>
>
> ...
>
> --
> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl
>
------------------------------
Date: 8 May 2004 09:43:42 -0700
From: dperry.geo@yahoo.com (Darryl Perry)
Subject: timeout when reading from a server socket.
Message-Id: <c39c8d76.0405080843.fcc4d55@posting.google.com>
I'm trying to write a simple finger client in perl on Redhat 9.0. I
can get it to read just fine, that's not the problem. The problem is
that when it tries to connect to a server that is not responding, it
takes several minutes before it fails. I would like to set up a
timeout value to like 10 seconds. Can anybody recommend a way for me
to do this? I've already tried alarm(), but that has unwanted side
effects when the alarm time has been reached.
Any help would be appreciated.
Regards,
Darryl Perry
------------------------------
Date: Sat, 08 May 2004 13:09:49 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: win32::ole and excel VBA macro conversion: SmallScroll
Message-Id: <409CDC14.1020300@rochester.rr.com>
Domenico Discepola wrote:
>>I wholeheartedly agree, a good book on the subject would have saved me
>>
> weeks
>
>>of experimenting and tinkering.
You should *never* have to "experiment and tinker". It is *way* more
effective to study and learn the terminology (so you know, for example,
what exactly VBA means when its docs say "property"), and then follow
the docs to the letter. When you do that, things work -- you can write
code that works the first time. The approach of copying the first
example you see, ignoring "minor" differences, must be hugely
frustrating. It is not the docs or the books that are deficient, it is
the technique by which you are approaching programming that is deficient.
...
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6543
***************************************