[18060] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 220 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 6 06:10:06 2001

Date: Tue, 6 Feb 2001 03:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981457512-v10-i220@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 6 Feb 2001     Volume: 10 Number: 220

Today's topics:
    Re: "Average of List of Numbers" by Abigail <frido@q-software-solutions.com>
    Re: 'print' problem <brondsem@my-deja.com>
        Best way to build tests for objects francesc_guasch@my-deja.com
        Cannot Decrement in For Loop? <grichards@endertechnology.com>
    Re: Cannot Decrement in For Loop? <joe+usenet@sunstarsys.com>
    Re: Cannot Decrement in For Loop? <ccx138@coventry.ac.uk>
    Re: Cannot Decrement in For Loop? <joe+usenet@sunstarsys.com>
        CGI Scripts <dordrakx@samye.org>
    Re: Confused on IPC <david@kasey.umkc.edu>
        Damian Conway Seattle Talks: Stump the Guru! <tim@timji.consultix.wa.com>
        Emailing with a file attached <E.Smalley@idevelop.nl>
    Re: getting line number n of a file <joe+usenet@sunstarsys.com>
        Handling flock failure <flair@blueyonder.co.uk>
        Help with calling functions from dynamic/shared librari <jeff_nokes@yahoo.com>
    Re: Help with calling functions from dynamic/shared lib jimjim123@my-deja.com
        Help with LWP <ramesh_r@my-deja.com>
    Re: How to tell which Perl is running <nospam.newton@gmx.li>
    Re: How to tell which Perl is running <somewhere@planet.earth>
        How to tell which perl is running? <lynn@swcp.com>
    Re: How to tell which perl is running? <Peter.Dintelmann@dresdner-bank.com>
    Re: Insert value into table using perl/DBI (Chris)
    Re: Insert value into table using perl/DBI <joe+usenet@sunstarsys.com>
    Re: Is scalar a float, int or string? (Rafael Garcia-Suarez)
    Re: Is scalar a float, int or string? (Abigail)
        Making an lvalue subroutine for a tied scalar in XS <pjl@best.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 06 Feb 2001 08:26:49 +0100
From: Friedrich Dominicus <frido@q-software-solutions.com>
Subject: Re: "Average of List of Numbers" by Abigail
Message-Id: <87g0hsgtl2.fsf@frown.here>

Chris Stith <mischief@velma.motion.net> writes:

> 
> Like I mentioned earlier, Abigail's knowledge of the language
> impresses me, including in this example. I doubt, though, that
> Abigail herself would call her example "strikingly elegant".
> Impressive in how it's done, perhaps. Impressive in its length
> or its speed, no.
> 
From the mentioned page
|Shown here is a strikingly elegant way to calculate the average of an array of numbers. 
|>Artiste: Abigail 
|Medium: Perl 

Regards
Friedrich


------------------------------

Date: Tue, 06 Feb 2001 03:33:45 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: 'print' problem
Message-Id: <95nrap$5il$1@nnrp1.deja.com>

In article <15956-3A7E4AA7-83@storefull-245.iap.bryant.webtv.net>,
  dennis100@webtv.net (BUCK NAKED1) wrote:
>
> b0l4549@cs.tamu.edu (Bin=A0-=A0Lu)
> > I have such a problem:
> > At the beginning of my code I have to
> > use print "content-type: text/html\n\n";
> > But then I want to use:
> > print "Location: $link\n\n";
> > exit;
> > which achieves redirection and requires > not to use the
first 'print'
> line. How can I > 'deactivate' the first 'print' line or change > the
> print content type?
>
> Just put it in a scalar before the content header, and call it out
later
> like so:
>
> $redirect =3D "Location: $link\n\n";
>
> print "Content-type: text/html\n\n";
>
> print $redirect;
>
> I hope that's right. You may need to change the 1st line to read...
>
> $redirect =3D print "Location: $link\n\n";

I don't think so....

but you do need to change it to be
$redirect = print "Location: $link\n";
After 2 \n in a row, the browser assumes your headers are over.  You
must have just one \n to seperate your headers.

>
> --Dennis
>
>

--
Dave Brondsema


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Tue, 06 Feb 2001 09:47:39 GMT
From: francesc_guasch@my-deja.com
Subject: Best way to build tests for objects
Message-Id: <95oh7q$n71$1@nnrp1.deja.com>

I'm looking for some hints to build tests for objects.
I do use h2xs -X -n for creating the objects but I
find the test template that creates a little short.

I've seen some objects whith `t' directories and I'd
like to use this technique.

I've searched in a couple of books I have unsuccessfully:
Programming Perl & Perl CookBook. I also digged in perltoot.

Please, someone can advise me where to look for more ?
Maybe I missed something , or I could read the sources
of a well crafted CPAN module like ... ?


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Tue, 06 Feb 2001 08:26:05 GMT
From: "Gabriel Richards" <grichards@endertechnology.com>
Subject: Cannot Decrement in For Loop?
Message-Id: <xyOf6.181306$y9.31536460@typhoon.we.rr.com>

This works fine:

for (my $i=1; $i<$num+1; $i++) {
   my $j = ID('pollans', 'ansid', $dbh);
   $answers{$j} = $cgi->param("ans$i");
}

The problem is, I need the answers saved in %answers in reverse order so I
tried this:

for (my $i = $num; $i<1; $i--) {
   my $j = ID('pollans', 'ansid', $dbh);
   $answers{$j} = $cgi->param("ans$i");
}

But $i is not decrementing (I've tested by printing $i in the loop). Help?

Gabe
--
Ender Technology
Website and Database Development for Small Business
http://www.endertechnology.com
310-532-7455




------------------------------

Date: 06 Feb 2001 03:35:24 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Cannot Decrement in For Loop?
Message-Id: <m3elxcjjjn.fsf@mumonkan.sunstarsys.com>

"Gabriel Richards" <grichards@endertechnology.com> writes:

> This works fine:
> 
> for (my $i=1; $i<$num+1; $i++) {
>    my $j = ID('pollans', 'ansid', $dbh);
>    $answers{$j} = $cgi->param("ans$i");
> }
> 
> The problem is, I need the answers saved in %answers in reverse order so I
> tried this:
> 
> for (my $i = $num; $i<1; $i--) {
                      ^^^
$i >= 0

>    my $j = ID('pollans', 'ansid', $dbh);
>    $answers{$j} = $cgi->param("ans$i");
> }
> 
> But $i is not decrementing (I've tested by printing $i in the loop). Help?

-- 
Joe Schaefer      "The fear of death is the most unjustified of all fears, for
                      there's no risk of accident for someone who's dead."
                                                --Albert Einstein


------------------------------

Date: Tue, 06 Feb 2001 08:41:59 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: Cannot Decrement in For Loop?
Message-Id: <3A7FB8D7.223A4683@coventry.ac.uk>



Gabriel Richards wrote:

> This works fine:
>
> for (my $i=1; $i<$num+1; $i++) {
>    my $j = ID('pollans', 'ansid', $dbh);
>    $answers{$j} = $cgi->param("ans$i");
> }
>
> The problem is, I need the answers saved in %answers in reverse order so I
> tried this:
>
> for (my $i = $num; $i<1; $i--) {
>    my $j = ID('pollans', 'ansid', $dbh);
>    $answers{$j} = $cgi->param("ans$i");
> }
>
> But $i is not decrementing (I've tested by printing $i in the loop). Help?
>
> Gabe
> --
> Ender Technology
> Website and Database Development for Small Business
> http://www.endertechnology.com
> 310-532-7455

Try doing
for (my $i = $num; $i>1; $i--) {
                             ^^^^
Do why $i is greater than 1.





------------------------------

Date: 06 Feb 2001 04:11:17 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Cannot Decrement in For Loop?
Message-Id: <m3ae80jhvu.fsf@mumonkan.sunstarsys.com>

Joe Schaefer <joe+usenet@sunstarsys.com> writes:

> "Gabriel Richards" <grichards@endertechnology.com> writes:
> 
> > This works fine:
> > 
> > for (my $i=1; $i<$num+1; $i++) {
> >    my $j = ID('pollans', 'ansid', $dbh);
> >    $answers{$j} = $cgi->param("ans$i");
> > }
> > 
> > The problem is, I need the answers saved in %answers in reverse order so I
> > tried this:
> > 
> > for (my $i = $num; $i<1; $i--) {
>                       ^^^
> $i >= 0
> 

Actually, since your working for loop ranges from 1 to $num,
I think you want 

        for (my $i = $num; $i>0; $i--) {
or      
        foreach my $i (reverse 1..$num) {

so your loop ranges from 1..$num in reverse now.

HTH
-- 
Joe Schaefer     "A little inaccuracy sometimes saves a ton of explanation." 
                                        -- H. H. Munro (Saki)


------------------------------

Date: Tue, 6 Feb 2001 10:34:13 +0000
From: d d <dordrakx@samye.org>
Subject: CGI Scripts
Message-Id: <9SRSZcAlM9f6QAmU@samye.org>

I've found this great perl CGI site with some amazing scripts.

http://www.mono.org/~viator/

Have fun.

d


------------------------------

Date: Thu, 01 Feb 2001 15:59:36 -0600
From: "David L. Nicol" <david@kasey.umkc.edu>
To: davecolson@pro-usa.net
Subject: Re: Confused on IPC
Message-Id: <3A79DC48.39655CA1@kasey.umkc.edu>

Abigail wrote:
> 
> David Colson (davecolson@pro-usa.net) wrote on MMDCCIII September
> MCMXCIII in <URL:news:3A6F42B8.33F6A7DF@pro-usa.net>:
> [] Hi,
> []
> [] Can some tell me how write a code segment that will allow me to start a
> [] program
> [] and then be able to commuicate with it, both read and write.
> 
> man IPC::open2
> 
> [] The perl doc on IPC is not very clear to me. I am not a programmer by
> [] trade.
> 
> Can someone tell me how to set a broken bone? The documentation on
> bones is not very clear to me. I am not a doctor by trade.
> 
> Abigail

Ha ha.  Abigail, you are amusing.


=pod
Here you go David, Setting broken bones for the nonprogrammer. We
are going to invoke a unix command line utility blargl and have a
handle that gives us its output (called OUTPUT) and a handle
that we can write to to write to its input.

You'll have to fool with it a little if it buffers anything.

=cut

system "/usr/bin/mkfifo /tmp/blarglchannel$$";
open INPUT,"| blargl > /tmp/blarglchannel$$";
open OUTPUT, "/tmp/blarglchannel$$";

# now you can print to INPUT to give blargl commands, and
# read from <OUTPUT> to see what it has to say, if anything.
# careful not to read from OUTPUT when there is nothing there; 
# as you'll hang.


unlink "/tmp/blarglchannel$$"; #don't clutter your /tmp



-- 
                      David Nicol 816.235.1187 dnicol@cstp.umkc.edu
                          "gorkulator borked.  Please investigate."


------------------------------

Date: 6 Feb 2001 02:36:10 GMT
From: Tim Maher/CONSULTIX <tim@timji.consultix.wa.com>
Subject: Damian Conway Seattle Talks: Stump the Guru!
Message-Id: <95nnuq$nv3$0@216.39.144.161>
Keywords: Dr. Damian Conway free talks seminars Seattle February

Dr. Damian Conway, "The Perl Wonder from Down Under", and author of
the groundbreaking book "Object Oriented Perl", will be presenting
two free talks in the Seattle area in February.  On Feb. 19th,
he'll discuss what's in store with Perl 6.0, and on Feb. 21st,
he'll be playing "Stump the Guru", by inviting audience questions
on Perl and his CPAN modules.  These talks are being sponsored
by SPUG and E-SPUG, the Seattle-area Perl Users Groups.

See http://www.consultix-inc.com for more information.

-Tim
*========================================================================*
| Dr. Tim Maher, CEO, Consultix       (206) 781-UNIX/8649;  ask for FAX# | 
| Email: tim@consultix-inc.com        Web: http://www.consultix-inc.com  |
| TIM MAHER: Unix/Perl  DAMIAN CONWAY: Adv. Perl   COLIN MEYER: Perl/DBI |
|        12 Int Perl; 15 OO-Perl; 20 Data Munging; 22 Adv OO-Perl        |
*========================================================================*


------------------------------

Date: Tue, 06 Feb 2001 09:12:08 +0100
From: Eric Smalley <E.Smalley@idevelop.nl>
Subject: Emailing with a file attached
Message-Id: <3A7FB1D8.DE557C8E@idevelop.nl>


--------------095BEF02B99F33630C4718CB
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi there,

Was wondering whether you could help me out with this.

I have a perl script that needs to be able to send an email with an
attached ascii file. The file doesn't have to be uploaded first (it's
not an email program that it emulates), the script just needs to send an
email at a certain time, and it requires to have a file attached that is
located somewhere on the server.

I've seen all kinds of stuff with MIME modules, but I can't get it to
work, and if I would just know the basics how to attach a file in Perl,
I wouldn't have to rely on these modules.

How would I need to complement the following code so that it would send
the file along with it?

=========================
$mailer = "usr/sbin/sendmail";

$file = "./home/httpd/cgi-bin/file.txt";

$addressto = "addressto@domain.com";
$addressfrom = "addressfrom@domain.com";

open(MAILER, "|$mailer $addressfrom $addressto");
print MAILER "To: $addressto\n";
print MAILER "From: $addressfrom\n";
print MAILER "Subject: Here is an attached file\n\n";
print MAILER "In the body of this email there is some text\n";
close(MAILER);

# How would I attach $file to the email sent above?

============================

Thanks in advance for any help.
I'm sure a solution to this could be handy for anyone..

Regards,
Eric

--------------095BEF02B99F33630C4718CB
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Hi there,

<P>Was wondering whether you could help me out with this.

<P>I have a perl script that needs to be able to send an email with an
attached ascii file. The file doesn't have to be uploaded first (it's not
an email program that it emulates), the script just needs to send an email
at a certain time, and it requires to have a file attached that is located
somewhere on the server.

<P>I've seen all kinds of stuff with MIME modules, but I can't get it to
work, and if I would just know the basics how to attach a file in Perl,
I wouldn't have to rely on these modules.

<P>How would I need to complement the following code so that it would send
the file along with it?

<P>=========================
<BR>$mailer = "usr/sbin/sendmail";

<P><B>$file = "./home/httpd/cgi-bin/file.txt";</B>

<P>$addressto = "addressto@domain.com";
<BR>$addressfrom = "addressfrom@domain.com";

<P>open(MAILER, "|$mailer $addressfrom $addressto");
<BR>print MAILER "To: $addressto\n";
<BR>print MAILER "From: $addressfrom\n";
<BR>print MAILER "Subject: Here is an attached file\n\n";
<BR>print MAILER "In the body of this email there is some text\n";
<BR>close(MAILER);

<P># How would I attach <B>$file</B> to the email sent above?

<P>============================

<P>Thanks in advance for any help.
<BR>I'm sure a solution to this could be handy for anyone..

<P>Regards,
<BR>Eric</HTML>

--------------095BEF02B99F33630C4718CB--



------------------------------

Date: 05 Feb 2001 21:45:15 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: getting line number n of a file
Message-Id: <m3wvb4jzr8.fsf@mumonkan.sunstarsys.com>

tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:

> I was shocked! How could Abigail <abigail@foad.org>
> say such a terrible thing:
> 
> >From the PGA:
> >
> >   perl -nwe '$.==4&&die$_' file
> 
>     perl -e 'die((<>)[3])' file
> 
> This is blatantly assuming there are at least four lines 
> in the input of course.

Here's a shorter one:

        % perl -pe '4..last}{' file

Joe Schaefer
-- 
"Anyone who considers arithmetical methods of producing random digits
is, of course, in a state of sin."
                                        -- John von Neumann


------------------------------

Date: Tue, 6 Feb 2001 08:28:30 -0000
From: "Andy" <flair@blueyonder.co.uk>
Subject: Handling flock failure
Message-Id: <95ocji$2cbe$1@purple.gradwell.net>

Probably a simple thing but it's got me stumped at present!  I've got a perl
script that opens a semaphore file, attempts to flock it and if the flock is
successful add data to a log file then go on and display a web page.

What I would like to do is add some code so that if the flock has not
succeeded after say 3 seconds, we just skip the logging bit and go on with
displaying the output page.

Any help would be appreciated.

--
Regards - Andy





------------------------------

Date: Mon, 05 Feb 2001 22:47:32 -0800
From: "Jeffry A. Nokes" <jeff_nokes@yahoo.com>
Subject: Help with calling functions from dynamic/shared libraries
Message-Id: <3A7F9E04.1F238A77@yahoo.com>

Greetings,
I was wondering if anyone new of a way to call functions from a ".so"
file in Linux/Unix from a Perl script?  I currently use Perl on Win32
and call functions from DLLs using Win32::API.  Is there an equivalent
Perl module I can use to call functions from the Linux/Unix
environments?  Or even better, a single Perl module that will work bothe
with DLLs in Win32, and .so files in Linux/Unix?  This would save me a
lot of time.

Thanks in advance,
 - Jeff



------------------------------

Date: Tue, 06 Feb 2001 08:06:30 GMT
From: jimjim123@my-deja.com
Subject: Re: Help with calling functions from dynamic/shared libraries
Message-Id: <95oba4$i2a$1@nnrp1.deja.com>

My advice is read the perlxs man pages....  There are tutorials around
which show you how to include C functions in your PERL code.  In fact,
I have a problem with this right now, but no-one answered my message
about it :-(

Cheers!

Hamish Rickerby.

In article <3A7F9E04.1F238A77@yahoo.com>,
  "Jeffry A. Nokes" <jeff_nokes@yahoo.com> wrote:
> Greetings,
> I was wondering if anyone new of a way to call functions from a ".so"
> file in Linux/Unix from a Perl script?  I currently use Perl on Win32
> and call functions from DLLs using Win32::API.  Is there an equivalent
> Perl module I can use to call functions from the Linux/Unix
> environments?  Or even better, a single Perl module that will work
bothe
> with DLLs in Win32, and .so files in Linux/Unix?  This would save me a
> lot of time.


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Tue, 06 Feb 2001 10:04:56 GMT
From: A Searcher <ramesh_r@my-deja.com>
Subject: Help with LWP
Message-Id: <95oi86$nnu$1@nnrp1.deja.com>

Hi all!

I'm fairly new with LWP, so am not sure if I've missed something really
plain here.

I'm attempting to connect to www.email.com to download my Web-emails
there, and read them off-line. However, there some problems connecting
to my mailbox.

It's a POST connection, so I've sub-classed LWP::UserAgent, and enabled
redirect_ok to allow redirection. I've enabled cookies, and asked my
program to read my own existing Netscape cookie file. Below is the trace
(with some munging to protect the innocent; there also seems to be some
problems with LWP::Debug, but I don't think that affects my program).

**** <start trace>

LWP::UserAgent::new: ()
LWP::UserAgent::proxy: ARRAY(0x33e5118), http://
some.proxy_machine.com:8080/
# Use of uninitialized value.
File 'someVol:lib:LWP:Debug.pm'; Line 123
WebRobot::fetchURL:
LWP::UserAgent::request: ()
LWP::UserAgent::simple_request: POST http://ltd.snap.com/main/redirect/
ab/1,295,,00.html
LWP::UserAgent::_need_proxy: Proxied to http://
some.proxy_machine.com:8080/
HTTP::Cookies::add_cookie_header: Checking ltd.snap.com for cookies
HTTP::Cookies::add_cookie_header: Checking .snap.com for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/
HTTP::Cookies::add_cookie_header:  - checking cookie u_mem_0_0=
some_index
HTTP::Cookies::add_cookie_header:    it's a match
HTTP::Cookies::add_cookie_header:  - checking cookie u_login_0_0=
another_index
HTTP::Cookies::add_cookie_header:    it's a match
HTTP::Cookies::add_cookie_header:  - checking cookie u_data_0_0=
yet_another_index
HTTP::Cookies::add_cookie_header:    it's a match
LWP::Protocol::http::request: ()
LWP::Protocol::http::request: POST http://ltd.snap.com/main/redirect/ab/
1,295,,00.html HTTP/1.0

Host: ltd.snap.com

User-Agent: libwww-perl/5.44

Content-Length: 42

Content-Type: application/x-www-form-urlencoded

Cookie: u_mem_0_0=some_index; u_login_0_0=another_index; u_data_0_0=
yet_another_index

Cookie2: $Version=1




LWP::Protocol::http::request: POST http://ltd.snap.com/main/redirect/ab/
1,295,,00.html HTTP/1.0

Host: ltd.snap.com

User-Agent: libwww-perl/5.44

Content-Length: 42

Content-Type: application/x-www-form-urlencoded

Cookie: u_mem_0_0=some_index; u_login_0_0=another_index; u_data_0_0=
yet_another_index

Cookie2: $Version=1




LWP::Protocol::http::request: reading response
LWP::Protocol::http::request: HTTP/1.0 301 Because I felt like it.

Date: Tue, 06 Feb 2001 09:35:39 GMT

Content-Length: 0

Content-Type: text/html

Server: Netscape-Communications/1.12

Set-Cookie: s_cur_0_0=y_yet_another_index; path=/

Set-Cookie: u_vid_0_0=yy_yet_another_index; path=/; domain=.nbci.com;
expires=Thu, 31-Dec-2037 23:59:59 GMT

Last-modified: Tuesday, 06-Feb-01 09:35:40 GMT

Via: 1.0 netcache32 (NetCache NetApp/5.0D12)

Location: http://www.email.com/?ed=one_long_index




LWP::Protocol::http::request: HTTP/1.0 301 Because I felt like it.
HTTP::Cookies::extract_cookies: Set cookie s_cur_0_0 =>
y_yet_another_index
HTTP::Cookies::extract_cookies: Set cookie u_vid_0_0 =>
yy_yet_another_index
HTTP::Cookies::extract_cookies: Domain .nbci.com does not match host
ltd.snap.com
LWP::UserAgent::request: Simple result: Moved Permanently
LWP::UserAgent::request: ()
LWP::UserAgent::simple_request: POST http://www.email.com/?ed=
one_long_index
LWP::UserAgent::_need_proxy: Proxied to http://
some.proxy_machine.com:8080/
HTTP::Cookies::add_cookie_header: Checking www.email.com for cookies
HTTP::Cookies::add_cookie_header: Checking .email.com for cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=/
HTTP::Cookies::add_cookie_header:  - checking cookie www.email.com-mail=
yyy_yet_another_index
HTTP::Cookies::add_cookie_header:    it's a match
LWP::Protocol::http::request: ()
LWP::Protocol::http::request: POST http://www.email.com/?ed=
one_long_index HTTP/1.0

Host: www.email.com

User-Agent: libwww-perl/5.44

Content-Length: 42

Content-Type: application/x-www-form-urlencoded

Cookie: www.email.com-mail=yyy_yet_another_index

Cookie2: $Version=1




LWP::Protocol::http::request: POST http://www.email.com/?ed=
one_long_index HTTP/1.0

Host: www.email.com

User-Agent: libwww-perl/5.44

Content-Length: 42

Content-Type: application/x-www-form-urlencoded

Cookie: www.email.com-mail=yyy_yet_another_index

Cookie2: $Version=1




LWP::Protocol::http::request: reading response
LWP::Protocol::http::request: HTTP/1.0 400 Bad Request

Date: Tue, 06 Feb 2001 09:35:44 GMT

Content-Length: 272

Content-Type: text/html

Server: JavaWebServer/1.1.1

Via: 1.1 netcache5 (NetCache NetApp/5.0D14)



<HTML>

<HEAD>

<TITLE>Bad Request (400)</TITLE>

</HEAD>

<BODY>

<H1>

Bad Request (<FONT COLOR="#FF0000">400</FONT>)

</H1>

<P>

Your request to the server could not be understood.

Please check to ensure that the request you made is correct.

</P>

</BODY>

</HTML>


LWP::Protocol::http::request: HTTP/1.0 400 Bad Request
LWP::Protocol::collect: read 272 bytes
LWP::UserAgent::request: Simple result: Bad Request

***** <end trace>

I have no problems when using Netscape to connect to the site.

Could someone give me some pointers to chase down?

Thanks.

Cheers,
Ramesh


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Tue, 06 Feb 2001 09:35:16 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: How to tell which Perl is running
Message-Id: <rgdv7t88dnd4uiej2cn43ps5n1h1eo4eqd@4ax.com>

[Please trim your line length]

On Mon, 05 Feb 2001 17:11:47 -0700, Lynn Wilson <lynn@swcp.com> wrote:

> I want to write some perl scripts that will run under ActiveState
> (launched from a DOS shell) and under the /usr/local/bin/perl in a
> Cygwin environment.  The ActiveState doesn't understand that a
> '/c/program files/path' is the same as the 'c:/program files/path'
> that it understands.

Does the Cygwin perl understand 'c:/program files/path' style paths? If so, just
use those and both Perls will understand them.

> Is there a $Variable that will tell me the name of the perl that I'm
> running under (not $] $PERL_VERSION which only tells me 5.006 etc.)?

$^X gives you the path of the executable -- for example, on my box,
"D:\Perl\bin\perl.exe". $^O gives you the name of the OS (Cygwin Perl and
ActivePerl may have different values).

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


------------------------------

Date: Tue, 6 Feb 2001 09:40:49 +0100
From: "Dimitri Gunsing" <somewhere@planet.earth>
Subject: Re: How to tell which Perl is running
Message-Id: <95od9n$uhr$1@list.pbnec.nl>

> Is there a $Variable that will tell me the name of the perl that I'm
running under (not $] $PERL_VERSION which only tells me 5.006 etc.)?
>

How about $ENV{'OS'} which tells you which operating system you are running
under? Then you know which kind of Perl your using (Activestate or Linux
build).

Dimitri




------------------------------

Date: Mon, 05 Feb 2001 20:09:34 -0700
From: Lynn Wilson <lynn@swcp.com>
Subject: How to tell which perl is running?
Message-Id: <3A7F6AEE.5DB67976@swcp.com>

I want to write some perl scripts that will run under ActiveState
(launched from a DOS shell) and under the /usr/local/bin/perl in a
Cygwin
environment.  The ActiveState doesn't understand that a '/c/program
files/path' is the same as the 'c:/program files/path' that it
understands.

Cygwin contains a built-in 'cygpath' function that will convert between
the two but how do I know when to call it?

Is there a $Variable that will tell me the name of the perl that I'm
running under (not $] $PERL_VERSION which only tells me 5.006 etc.)?

Thanks.

Lynn


------------------------------

Date: Tue, 6 Feb 2001 10:14:19 +0100
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: How to tell which perl is running?
Message-Id: <95ofcs$dqf1@intranews.bank.dresdner.net>

    Hi,

"Lynn Wilson" <lynn@swcp.com> wrote in message
news:3A7F6AEE.5DB67976@swcp.com...

    [snip]

> Is there a $Variable that will tell me the name of the perl that I'm
> running under (not $] $PERL_VERSION which only tells me 5.006 etc.)?

    have you tried $^X ?

    HTH.

        Peter Dintelmann





------------------------------

Date: Tue, 06 Feb 2001 06:29:55 GMT
From: cprasley@home.com (Chris)
Subject: Re: Insert value into table using perl/DBI
Message-Id: <3a829967.48450107@news.rchmd1.bc.wave.home.com>

On Tue, 16 Jan 2001 20:20:52 GMT, Jing Zhou <jing@research.att.com> wrote
in comp.lang.perl.misc:

You would improve performance by doing the prepare only once and calling
execute with parameters, as in:

chomp($x = <INPUT>);
my $sth = $dbh->prepare( "INSERT INTO IDFSwitch VALUES ?,?,?,?,?);
while ($x ne "") {
	($MacAddress,$HostName,$IPAddress,
	$SwitchBoardPort,$LastSeen) = split(" ",$x);

$sth->execute($MacAddress,$HostName,$IPAddress,$SwitchBoardPort,$LastSeen);
	chomp($x = <INPUT>);
}

It might also lead to more useful error messages when things go wrong.



------------------------------

Date: 06 Feb 2001 02:08:23 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Insert value into table using perl/DBI
Message-Id: <m3k874jnko.fsf@mumonkan.sunstarsys.com>

cprasley@home.com (Chris) writes:

> On Tue, 16 Jan 2001 20:20:52 GMT, Jing Zhou <jing@research.att.com> wrote
> in comp.lang.perl.misc:
> 
> You would improve performance by doing the prepare only once and calling
> execute with parameters, as in:
> 
> chomp($x = <INPUT>);
> my $sth = $dbh->prepare( "INSERT INTO IDFSwitch VALUES ?,?,?,?,?);
> while ($x ne "") {
> 	($MacAddress,$HostName,$IPAddress,
> 	$SwitchBoardPort,$LastSeen) = split(" ",$x);
> 
> $sth->execute($MacAddress,$HostName,$IPAddress,$SwitchBoardPort,$LastSeen);
> 	chomp($x = <INPUT>);
> }
> 
> It might also lead to more useful error messages when things go wrong.

It might help clarify things by reorganizing your code a bit:

    my $sql =<<SQL;
        INSERT INTO IDFSwitch 
        (mac, hostname, ip, port, last) 
        VALUES ?, ?, ?, ?, ?
    SQL

    my $sth = $dbh->prepare($sql) or 
                 die "Can't prepare '$sql': $DBI::errstr";

    while (<INPUT>) {
        chomp;
        $sth->execute( split ) or 
             die "Can't execute '$sql' with parameters $_: $DBI::errstr";
    }


Note that some databases support a "LOAD DATA INFILE" sql command;
by changing the default split character from \t to " " you might 
try using that instead.

HTH
-- 
Joe Schaefer    "Truth is the most valuable thing we have - so let us economize
                                              it."
                                                --Mark Twain


------------------------------

Date: Tue, 06 Feb 2001 07:42:46 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Is scalar a float, int or string?
Message-Id: <slrn97vant.79s.rgarciasuarez@rafael.kazibao.net>

Daniel Pfeiffer wrote in comp.lang.perl.misc:
> 
> When treating a number passed in as a scalar, I need to do nothing if it
> is an int, split it up if it is a float, transform it and possibly split
> it up if it is a string.  Question is, how can I tell what it is _very_
> efficiently, i.e. without potentially casting it to a string and then
> parsing that.
> 
> Background is that I am currently rewriting Math::BigInt, which was
> lousy and has now become faster by a varying (enormous in some cases)
> factor.  And I need this for an optimal "new" method.

Your goal is pretty unclear. Do you know that there is a FAQ in the docs:

  "How do I determine whether a scalar is a number/whole/integer/float?"

You can benchmark various methods with the Benchmark module.

To determine if a scalar $x holds an integer, you can try
  $x eq 0 + $x
This will fail for integers out of range. I don't know if this will
be useful to you.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


------------------------------

Date: 6 Feb 2001 09:58:34 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Is scalar a float, int or string?
Message-Id: <slrn97vima.4f2.abigail@tsathoggua.rlyeh.net>

Rafael Garcia-Suarez (rgarciasuarez@free.fr) wrote on MMDCCXVI September
MCMXCIII in <URL:news:slrn97vant.79s.rgarciasuarez@rafael.kazibao.net>:
^^ Daniel Pfeiffer wrote in comp.lang.perl.misc:
^^ > 
^^ > When treating a number passed in as a scalar, I need to do nothing if it
^^ > is an int, split it up if it is a float, transform it and possibly split
^^ > it up if it is a string.  Question is, how can I tell what it is _very_
^^ > efficiently, i.e. without potentially casting it to a string and then
^^ > parsing that.
^^ > 
^^ > Background is that I am currently rewriting Math::BigInt, which was
^^ > lousy and has now become faster by a varying (enormous in some cases)
^^ > factor.  And I need this for an optimal "new" method.
^^ 
^^ Your goal is pretty unclear. Do you know that there is a FAQ in the docs:
^^ 
^^   "How do I determine whether a scalar is a number/whole/integer/float?"
^^ 
^^ You can benchmark various methods with the Benchmark module.
^^ 
^^ To determine if a scalar $x holds an integer, you can try
^^   $x eq 0 + $x


Since when is 1.3 an integer?

    $ perl -wle '$x = 1.3; print "Yes" if $x eq 0 + $x'
    Yes
    $

Perhaps at the same time +2 no longer was an integer?

    $ perl -wle '$x = "+2"; print "Nope" unless $x eq 0 + $x'
    Nope
    $


Representation of integers is not unique, and the integers aren't the only
group for which 0 is a null element.



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


------------------------------

Date: Tue, 06 Feb 2001 07:50:11 GMT
From: "Paul J. Lucas" <pjl@best.com>
Subject: Making an lvalue subroutine for a tied scalar in XS
Message-Id: <T0Of6.12546$1%2.615266@sjc-read.news.verio.net>

	I want to return an lvalue to a C++ string& from withing XS.
	I'm currently doing:

		string*
		MyClass::text()
		CODE:
			RETVAL = &THIS->my_string;
		OUTPUT:
			RETVAL

	where string* is in the typemap as:

		string&	TIED_STRING

		OUTPUT
		TIED_STRING
		    string4perl *const s = new string4perl( *$var );
		    SV *sv = sv_newmortal();
		    sv_setref_pv( sv, "string4perl", s );
		    sv_magic( $arg, sv, 'q', 0, 0 );

	where string4perl is a wrapper as:

		struct string4perl {
			string4perl( string &s ) : s_( s ) { }
			string &s_;
		};

	and has these defined in XS:

		void
		string4perl::DESTROY()

		char const*
			string4perl::FETCH()
		CODE:
			RETVAL = THIS->s_.c_str();
		OUTPUT:
			RETVAL

		void
		string4perl::STORE(value)
			char const* value
		CODE:
			THIS->s_ = value;

	But when I tried to assign like:

		$obj->text = 'foo';

	I get:

		Can't modify non-lvalue subroutine call at test.pl line 62.

	How can I make the function return an lvalue that is a tied
	scalar?

	- Paul


------------------------------

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 V10 Issue 220
**************************************


home help back first fref pref prev next nref lref last post