[31098] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2343 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 16 09:09:44 2009

Date: Thu, 16 Apr 2009 06:09:08 -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           Thu, 16 Apr 2009     Volume: 11 Number: 2343

Today's topics:
    Re: (newbie) need help understanding a few lines of cod <ben@morrow.me.uk>
        Hash refs and printing to FD <january.weiner@gmail.com>
    Re: Hash refs and printing to FD <1usa@llenroc.ude.invalid>
    Re: Hash refs and printing to FD <january.weiner@gmail.com>
        If not match and naked block question <alfonso.baldaserra@gmail.com>
    Re: If not match and naked block question <smallpond@juno.com>
    Re: monitoring oracle rac services <alfonso.baldaserra@gmail.com>
        new CPAN modules on Thu Apr 16 2009 (Randal Schwartz)
        no $ENV{'CONTENT_LENGTH'} <someone@somewhere.nb.ca>
    Re: no $ENV{'CONTENT_LENGTH'} <noreply@gunnar.cc>
    Re: no $ENV{'CONTENT_LENGTH'} <glennj@ncf.ca>
    Re: no $ENV{'CONTENT_LENGTH'} <ben@morrow.me.uk>
    Re: no $ENV{'CONTENT_LENGTH'} <someone@somewhere.nb.ca>
    Re: no $ENV{'CONTENT_LENGTH'} <tadmc@seesig.invalid>
    Re: no $ENV{'CONTENT_LENGTH'} <1usa@llenroc.ude.invalid>
    Re: using SSH without modules <tadmc@seesig.invalid>
    Re: UTF-32 and Regular Expressions on Binary Data  (was sln@netherlands.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Apr 2009 03:10:14 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: (newbie) need help understanding a few lines of code
Message-Id: <6lgib6-1e91.ln1@osiris.mauzo.dyndns.org>


Quoth tmcd@panix.com:
> In article <qn0ib6-f181.ln1@osiris.mauzo.dyndns.org>,
> Ben Morrow  <ben@morrow.me.uk> wrote:
> >
> >Quoth tmcd@panix.com:
> >> Turning on autoflush with an increment is ridiculous, when they
> >> could just as easily do
> >>     $| = 1;
> >> and have it actually work in all cases (assuming autoflush is
> >> implemented at all).  It makes me want to start the program with
> >>     $| = -1;    # sets $| to a true value, so it should autoflush
> >> just to show how bad an increment is.
> >
> >Oh, but it *does* work in all cases. $| is magical, remember.
> >
> >    ~% perl -le'$| = -1; print $|'
> >    1
> >    ~% perl -le'$| = 1; $|++; print $|'
> >    1
> >    ~% perl -le'$| = -1; $|++; print $|'
> >    1
> 
> You.  MUST.  Be.  Shitting.  Me.
> 
> [checking]
> It does just that under Perl 5.00502 and 5.010000.  Gahhh ...

What you have to realise is that $| is actually just a single bit
somewhere inside the IO structure of the current output filehandle. It's
impossible for it to have any value other than 0 or 1: any other value
assigned is mapped to one of these.

> >Whether your find this amusing or obscene probably depends on your
> >sense of humour
> 
> Obscene, highly counter-intuitive, and undocumented:
> 
>     $| If set to nonzero, forces a flush right away and after every
>        write or print on the currently selected output channel.
>        Default is 0 (regardless of whether the channel is really
>        buffered by the system or not; $| tells you only whether you've
>        asked Perl explicitly to flush after each write). ...

Well, it's documented that using the magic punctuation variables for
anything other than their intended purpose is unsupported and may
produce weird results. Assigning -1 to $| and expecting ++ to increment
it to 0 falls into that category.

I must admit I don't much like either $| itself or the $|++ idiom. Both
are obscure and lead to weird action at a distance: selecting a new
output filehandle magically causes $| to refer *its* autoflush bit
instead, leading to bizarre idioms like the standard

    select((select($FH), $|++)[0]);

which are extremely hard to pick apart and basically have to be
recognised as a whole. IO::Handle->autoflush is a much saner interface,
once you've got your head round the whole 'filehandles are IO::Handle
objects... sometimes' issue and the related question of how perl decides

    STDOUT->autoflush(1);

is a method call on the STDOUT filehandle (strictly, on *STDOUT{IO},
since \*STDOUT isn't usually blessed, and even if it is dispatch is on
the IO object not the glob) rather than on the STDOUT class.

In short: here be dragons :). Perl's IO system is something of a mess,
having been extended in several different ways at different times while
having to maintain backwards compatibility. The only safe course if you
don't want to get your head round all the gory details is to stick to
straightforward and commonly-used constructions, and not try and be too
clever.

> >(I don't understand what you mean by 'assuming autoflush is implemented
> >at all'. AFAIK autoflush is always implemented...)
> 
> Weasel-wording: I was afraid that, if I left it out, someone would
> mock my ignorance of the fact that the port to Irish Business Machines
> System/42 did nothing with $|.

Please don't take anything I have posted as mocking. If I post
corrections to something someone has said, it's not to 'score points'
but to correct misunderstandings. IME this applies to all the posters
here that are worth listening to, despite the fact some of us may
sometimes seem a little curt.

Ben



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

Date: Thu, 16 Apr 2009 12:35:20 +0200 (CEST)
From: January Weiner <january.weiner@gmail.com>
Subject: Hash refs and printing to FD
Message-Id: <gs71l8$kum$1@sagnix.uni-muenster.de>

Hi, 

I want to print to a file descriptor that sits in a hash ref:

  my %hash ;
  my $hash_ref = \%hash ;
  open( $hash{fd}, ">test" ) or die "Can't write to file test: $!\n" ;

  print $hash_ref->{fd} "Test\n" ;

This throws the following error:
  syntax error at test.pl line 12, near "} "Test\n""

Why is that so? And what should I do, except for the obvious code below?

  my $fd = $hash_ref->{fd} ;
  print $fd "Test\n" ;

  j.


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

Date: Thu, 16 Apr 2009 10:42:40 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Hash refs and printing to FD
Message-Id: <Xns9BEF44420E864asu1cornelledu@127.0.0.1>

January Weiner <january.weiner@gmail.com> wrote in news:gs71l8$kum$1
@sagnix.uni-muenster.de:

> Hi, 
> 
> I want to print to a file descriptor that sits in a hash ref:
> 
>   my %hash ;
>   my $hash_ref = \%hash ;
>   open( $hash{fd}, ">test" ) or die "Can't write to file test: $!\n" ;
> 
>   print $hash_ref->{fd} "Test\n" ;
> 
> This throws the following error:
>   syntax error at test.pl line 12, near "} "Test\n""
> 
> Why is that so? 

perldoc -f print

Note that if you're storing FILEHANDLEs in an array, or if
you're using any other expression more complex than a scalar
variable to retrieve it, you will have to use a block returning
the filehandle value instead:

> And what should I do

Follow the solution given in the documentation.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Thu, 16 Apr 2009 13:52:07 +0200 (CEST)
From: January Weiner <january.weiner@gmail.com>
Subject: Re: Hash refs and printing to FD
Message-Id: <gs7657$m39$1@sagnix.uni-muenster.de>

On 2009-04-16, A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
> Follow the solution given in the documentation.

Thanks, Sinan!

I was looking for something in the perlre manual...

j.


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

Date: Thu, 16 Apr 2009 04:26:31 -0700 (PDT)
From: alfonsobaldaserra <alfonso.baldaserra@gmail.com>
Subject: If not match and naked block question
Message-Id: <c8b086ae-9d17-416a-a857-8b674580f63a@f1g2000prb.googlegroups.com>

hi all

i am stuck at the following code.  it's basically some error handling
stuff

my $DSPMQ = '/usr/bin/dspmq';
$QUEUE is the argument passed to script

my $DRET = qx( $DSPMQ -m $QUEUE ) if (! ~ /AMQ7048/ ) || {
  print "$QUEUE does not exist";
  exit $return_value{'UNKNOWN'};
}

what i am trying to do is store the value of dspmq -m queue_manager in
$DRET if the output does not match

AMQ7048: The queue manager name is either not valid or not known

otherwise just print $QUEUE does not exist and exit.

any help is appreciated.

thanks


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

Date: Thu, 16 Apr 2009 04:37:25 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: If not match and naked block question
Message-Id: <0bcacf35-99ae-41d3-ac8c-51a995691b7a@p11g2000yqe.googlegroups.com>

On Apr 16, 7:26=A0am, alfonsobaldaserra <alfonso.baldase...@gmail.com>
wrote:
> hi all
>
> i am stuck at the following code. =A0it's basically some error handling
> stuff
>
> my $DSPMQ =3D '/usr/bin/dspmq';
> $QUEUE is the argument passed to script
>
> my $DRET =3D qx( $DSPMQ -m $QUEUE ) if (! ~ /AMQ7048/ ) || {
> =A0 print "$QUEUE does not exist";
> =A0 exit $return_value{'UNKNOWN'};
>
> }
>
> what i am trying to do is store the value of dspmq -m queue_manager in
> $DRET if the output does not match
>
> AMQ7048: The queue manager name is either not valid or not known
>
> otherwise just print $QUEUE does not exist and exit.
>
> any help is appreciated.
>
> thanks

use warnings;
use strict;
use correct syntax!


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

Date: Thu, 16 Apr 2009 02:39:28 -0700 (PDT)
From: alfonsobaldaserra <alfonso.baldaserra@gmail.com>
Subject: Re: monitoring oracle rac services
Message-Id: <1807ba7b-8d95-4d77-9ce8-82bb1770109a@k19g2000prh.googlegroups.com>

PiCgIKAgbXkgJXNlcnZpY2VzID0gKAo+IKAgoCCgIKAgJ29yYS5zcnYwNC5BU00yLmFzbScgPT4g
eyBUWVBFIKAgPT4gJ2FwcGxpY2F0aW9uJywKPiCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAg
oCCgIKAgVEFSR0VUID0+ICdPTkxJTkUnLAo+IKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCg
IKAgoCBTVEFURSCgPT4gJ09OTElORSBvbiBzcnYwNCcsCj4goCCgIKAgoCCgIKAgoCCgIKAgoCCg
IKAgoCCgIKAgoCB9LAo+IKAgoCCgIKAgJ29yYS5zcnY5OS5BU00yLmFzbScgPT4geyBUWVBFIKAg
PT4gJ2FwcGxpY2F0aW9uJywKPiCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgVEFS
R0VUID0+ICdPTkxJTkUnLAo+IKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCBTVEFU
RSCgPT4gJ09OTElORSBvbiBzcnY5OScsCj4goCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAg
oCB9LAo+IKAgoCApOwo+Cj4goCCgIG15ICROQU1FID0gJ29yYS5zcnYwNC5BU00yLmFzbSc7Cj4g
oCCgIG15ICRzdGF0ZSA9ICRzZXJ2aWNlc3skTkFNRX17U1RBVEV9OyCgIyAoT05MSU5FIG9uIHNy
djA0KQoKdGhhbmsgeW91IGFsbCBmb3IgeW91ciBzdXBwb3J0Lg==


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

Date: Thu, 16 Apr 2009 04:42:27 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Apr 16 2009
Message-Id: <KI6Fqr.1642@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Acme-Perl-VM-0.0.1_01
http://search.cpan.org/~gfuji/Acme-Perl-VM-0.0.1_01/
An implementation of Perl5 Virtual Machine in Pure Perl (APVM) 
----
Acme-Perl-VM-0.0.1_02
http://search.cpan.org/~gfuji/Acme-Perl-VM-0.0.1_02/
An implementation of Perl5 Virtual Machine in Pure Perl (APVM) 
----
Apache2-Imager-Resize-0.11
http://search.cpan.org/~kalex/Apache2-Imager-Resize-0.11/
Fixup handler that resizes and crops images on the fly, caching the results, and doesn't require ImageMagick. 
----
Apache2-Imager-Resize-0.12
http://search.cpan.org/~kalex/Apache2-Imager-Resize-0.12/
Fixup handler that resizes and crops images on the fly, caching the results, and doesn't require ImageMagick. 
----
Badge-GoogleTalk-0.0.02
http://search.cpan.org/~shardiwal/Badge-GoogleTalk-0.0.02/
To get your status message/online status/chat link from google talk badge for website live chat. 
----
CPAN-FindDependencies-2.21
http://search.cpan.org/~dcantrell/CPAN-FindDependencies-2.21/
find dependencies for modules on the CPAN 
----
CPAN-FindDependencies-2.22
http://search.cpan.org/~dcantrell/CPAN-FindDependencies-2.22/
find dependencies for modules on the CPAN 
----
Catalyst-Action-Role-ACL-0.02
http://search.cpan.org/~converter/Catalyst-Action-Role-ACL-0.02/
User role-based authorization action class. 
----
Catalyst-Controller-HTML-FormFu-0.04001
http://search.cpan.org/~cfranks/Catalyst-Controller-HTML-FormFu-0.04001/
Catalyst integration for HTML::FormFu 
----
Catalyst-Model-SOAP-0.0.9
http://search.cpan.org/~druoso/Catalyst-Model-SOAP-0.0.9/
Map a WSDL to a catalyst model class. 
----
DBD-SQLite-1.22_06
http://search.cpan.org/~adamk/DBD-SQLite-1.22_06/
Self-contained RDBMS in a DBI Driver 
----
Data-Tabular-Dumper-0.07
http://search.cpan.org/~gwyn/Data-Tabular-Dumper-0.07/
Seamlessly dump tabular data to XML, CSV and XLS. 
----
Devel-CheckOS-1.52
http://search.cpan.org/~dcantrell/Devel-CheckOS-1.52/
check what OS we're running on 
----
Devel-CheckOS-1.53
http://search.cpan.org/~dcantrell/Devel-CheckOS-1.53/
check what OS we're running on 
----
Devel-CheckOS-1.54
http://search.cpan.org/~dcantrell/Devel-CheckOS-1.54/
check what OS we're running on 
----
Devel-CheckOS-1.55
http://search.cpan.org/~dcantrell/Devel-CheckOS-1.55/
check what OS we're running on 
----
Devel-RemoteTrace-0.2
http://search.cpan.org/~pmakholm/Devel-RemoteTrace-0.2/
Attachable call trace of perl scripts 
----
Elive-0.04
http://search.cpan.org/~warringd/Elive-0.04/
Elluminate Live (c) client library 
----
GD-Graph-ohlc-0.9401
http://search.cpan.org/~jettero/GD-Graph-ohlc-0.9401/
----
Geo-Coordinates-GMap-0.01
http://search.cpan.org/~bluefeet/Geo-Coordinates-GMap-0.01/
----
Google-Search-0.021
http://search.cpan.org/~rkrimen/Google-Search-0.021/
Interface to the Google AJAX Search API 
----
HTML-FormFu-0.04001
http://search.cpan.org/~cfranks/HTML-FormFu-0.04001/
HTML Form Creation, Rendering and Validation Framework 
----
HTML-FormWidgets-0.4.163
http://search.cpan.org/~pjfl/HTML-FormWidgets-0.4.163/
Create HTML form markup 
----
IO-EventMux-2.01
http://search.cpan.org/~tlbdk/IO-EventMux-2.01/
Multiplexer for sockets, pipes and any other types of filehandles that you can set O_NONBLOCK on and does buffering for the user. 
----
IPTables-libiptc-0.13
http://search.cpan.org/~hawk/IPTables-libiptc-0.13/
Perl extension for iptables libiptc 
----
Lingua-LinkParser-1.14
http://search.cpan.org/~dbrian/Lingua-LinkParser-1.14/
Perl module implementing the Link Grammar Parser by Sleator, Temperley and Lafferty at CMU. 
----
Locale-Country-Multilingual-0.23
http://search.cpan.org/~graf/Locale-Country-Multilingual-0.23/
mapping ISO codes to localized country names 
----
MP3-Tag-1.00
http://search.cpan.org/~ilyaz/MP3-Tag-1.00/
Module for reading tags of MP3 audio files 
----
Marpa-0.001_009
http://search.cpan.org/~jkegl/Marpa-0.001_009/
General BNF Parsing (Experimental version) 
----
Math-Fraction-Egyptian-0.01
http://search.cpan.org/~jtrammell/Math-Fraction-Egyptian-0.01/
construct Egyptian representations of fractions 
----
Net-ParSCP-0.09
http://search.cpan.org/~casiano/Net-ParSCP-0.09/
Parallel secure copy 
----
POE-Component-Client-DNS-Recursive-0.10
http://search.cpan.org/~bingos/POE-Component-Client-DNS-Recursive-0.10/
A recursive DNS client for POE 
----
POE-Component-Client-DNS-Recursive-0.12
http://search.cpan.org/~bingos/POE-Component-Client-DNS-Recursive-0.12/
A recursive DNS client for POE 
----
POE-Component-Client-DNSBL-1.00
http://search.cpan.org/~bingos/POE-Component-Client-DNSBL-1.00/
A component that provides non-blocking DNSBL lookups 
----
POE-Component-Client-NTP-0.02
http://search.cpan.org/~bingos/POE-Component-Client-NTP-0.02/
A POE Component to query NTP servers 
----
POE-Component-Server-HTTP-KeepAlive-0.0301
http://search.cpan.org/~gwyn/POE-Component-Server-HTTP-KeepAlive-0.0301/
HTTP keep-alive support 
----
POE-Component-Server-HTTP-KeepAlive-0.0302
http://search.cpan.org/~gwyn/POE-Component-Server-HTTP-KeepAlive-0.0302/
HTTP keep-alive support 
----
POE-Filter-KennySpeak-1.00
http://search.cpan.org/~bingos/POE-Filter-KennySpeak-1.00/
Mmm PfmPpfMpp Mpfmffpmffmpmpppff fmpmfpmmmfmp fmppffmmmpppfmmpmfmmmfmpmppfmm fmpppf mmmpppmpm mpfpffppfppm PmpmppppppppffmFmmpfmmppmmmpmp 
----
POE-Session-Multiplex-0.0402
http://search.cpan.org/~gwyn/POE-Session-Multiplex-0.0402/
POE session with object multiplexing 
----
POE-Session-PlainCall-0.0201
http://search.cpan.org/~gwyn/POE-Session-PlainCall-0.0201/
POE sessions with plain perl calls 
----
Path-Dispatcher-0.11
http://search.cpan.org/~sartak/Path-Dispatcher-0.11/
flexible and extensible dispatch 
----
Path-Mapper-0.010
http://search.cpan.org/~rkrimen/Path-Mapper-0.010/
Map a virtual path to an actual one 
----
Pid-File-Flock-0.02
http://search.cpan.org/~lonerr/Pid-File-Flock-0.02/
PID file operations 
----
RTx-From-0.02
http://search.cpan.org/~jpierce/RTx-From-0.02/
Make it easier to find users and their tickets 
----
Test-Builder-Mock-Class-0.0101
http://search.cpan.org/~dexter/Test-Builder-Mock-Class-0.0101/
Simulating other classes for Test::Builder 
----
Test-Mock-Class-0.0101
http://search.cpan.org/~dexter/Test-Mock-Class-0.0101/
Simulating other classes 
----
Test-Reporter-1.53_02
http://search.cpan.org/~dagolden/Test-Reporter-1.53_02/
sends test results to cpan-testers@perl.org 
----
Tie-Concurrent-0.05
http://search.cpan.org/~gwyn/Tie-Concurrent-0.05/
Paranoid tie for concurrent access 
----
Timeout-Queue-1.02
http://search.cpan.org/~tlbdk/Timeout-Queue-1.02/
A priority queue made for handling timeouts 
----
UID-0.23
http://search.cpan.org/~plato/UID-0.23/
? Create unique identifier constants 
----
UUID-Object-0.04
http://search.cpan.org/~banb/UUID-Object-0.04/
Universally Unique IDentifier (UUID) Object Class 
----
Verilog-Perl-3.200
http://search.cpan.org/~wsnyder/Verilog-Perl-3.200/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Wed, 15 Apr 2009 21:25:15 -0300
From: "Guy" <someone@somewhere.nb.ca>
Subject: no $ENV{'CONTENT_LENGTH'}
Message-Id: <49e67ad3$0$5492$9a566e8b@news.aliant.net>

I haven't done any Perl for about 5 years.  I am using Perl to run a web 
site according to the information that it receives from HTML forms. I'm sure 
I was using the following:
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

But it appears that this server is not providing this information.  What is 
the proper way to get this info.

Thanks for all,
G.Doucet

Here is the information that the server is providing:  (PS. I removed the 
customer's info.)

DOCUMENT_ROOT =
GATEWAY_INTERFACE = CGI/1.1
GDFONTPATH = /services/share/fonts
HTTP_ACCEPT = */*
HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_ACCEPT_LANGUAGE = en-us
HTTP_CONNECTION = Keep-Alive
HTTP_HOST =
HTTP_UA_CPU = x86
HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET 
CLR 1.1.4322)
MvCONFIG_LIBRARY = 
/services/websoftware/miva/Empresa/cgi-bin/libmivaconfig.so
PATH = /usr/bin:/bin:/sbin:/usr/sbin:/usr/local/bin
QUERY_STRING = t01=Hello
REMOTE_ADDR =
REMOTE_HOST =
REMOTE_PORT =
REQUEST_METHOD = GET
REQUEST_URI = /cgi-bin/photos.pl?t01=Hello
SCRIPT_FILENAME =
SCRIPT_NAME = /cgi-bin/photos.pl
SERVER_ADDR =
SERVER_ADMIN = or webmaster
SERVER_DOMAIN =
SERVER_NAME =
SERVER_PORT = 80
SERVER_PROTOCOL = HTTP/1.1
SERVER_SIGNATURE =
SERVER_SOFTWARE = Apache





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

Date: Thu, 16 Apr 2009 04:00:10 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: no $ENV{'CONTENT_LENGTH'}
Message-Id: <74nhpcF14335mU1@mid.individual.net>

Guy wrote:
> I am using Perl to run a web site according to the information that 
> it receives from HTML forms. I'm sure I was using the following:
>     read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> 
> But it appears that this server is not providing this information.

Data submitted via forms end up in STDIN only when the request method is 
POST, and then there is a content-length env variable available. I'd be 
very surprised if that's not the case also for your web server.

<snip>

> Here is the information that the server is providing:

<snip>

> QUERY_STRING = t01=Hello

<snip>

> REQUEST_METHOD = GET

You showed us the env variables that are available after a GET request.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 16 Apr 2009 02:04:29 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: no $ENV{'CONTENT_LENGTH'}
Message-Id: <slrngud4he.kbb.glennj@smeagol.ncf.ca>

At 2009-04-15 08:25PM, "Guy" wrote:
>  I was using the following:
>      read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>  
>  But it appears that this server is not providing this information.  What is 
>  the proper way to get this info.
>  
>  Here is the information that the server is providing:  (PS. I removed the 
>  customer's info.)
[...]
>  QUERY_STRING = t01=Hello
[...]
>  REQUEST_METHOD = GET

CONTENT_LENGTH is set only for POST submissions.

-- 
Glenn Jackman
    Write a wise saying and your name will live forever. -- Anonymous


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

Date: Thu, 16 Apr 2009 03:13:08 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: no $ENV{'CONTENT_LENGTH'}
Message-Id: <kqgib6-1e91.ln1@osiris.mauzo.dyndns.org>


Quoth "Guy" <someone@somewhere.nb.ca>:
> I haven't done any Perl for about 5 years.  I am using Perl to run a web 
> site according to the information that it receives from HTML forms. I'm sure 
> I was using the following:
>     read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> 
> But it appears that this server is not providing this information.  What is 
> the proper way to get this info.

    use CGI;

or one of the alternatives to CGI.pm on CPAN. Since you seem confused
about the difference between a GET and a POST, you should *certainly*
not be attempting to roll your own CGI-parsing code.

Ben



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

Date: Wed, 15 Apr 2009 23:26:25 -0300
From: "Guy" <someone@somewhere.nb.ca>
Subject: Re: no $ENV{'CONTENT_LENGTH'}
Message-Id: <49e69739$0$5478$9a566e8b@news.aliant.net>


"Glenn Jackman" <glennj@ncf.ca> a écrit dans le message de news: 
slrngud4he.kbb.glennj@smeagol.ncf.ca...
> At 2009-04-15 08:25PM, "Guy" wrote:
>>  I was using the following:
>>      read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>>
>>  But it appears that this server is not providing this information.  What 
>> is
>>  the proper way to get this info.
>>
>>  Here is the information that the server is providing:  (PS. I removed 
>> the
>>  customer's info.)
> [...]
>>  QUERY_STRING = t01=Hello
> [...]
>>  REQUEST_METHOD = GET
>
> CONTENT_LENGTH is set only for POST submissions.
>
> -- 
> Glenn Jackman
>    Write a wise saying and your name will live forever. -- Anonymous

I had forgotten about GET/POST.  I know I was using GET (where the form data 
is sent in the URL) so I must not have been using the 'CONTENT_LENGTH'.   I 
just noticed that the QUERY_STRING contains what I need so I will use it.
Sorry and thanks.
G.Doucet 




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

Date: Wed, 15 Apr 2009 21:37:15 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: no $ENV{'CONTENT_LENGTH'}
Message-Id: <slrngud6er.lpr.tadmc@tadmc30.sbcglobal.net>

Guy <someone@somewhere.nb.ca> wrote:

> I'm sure 
> I was using the following:
>     read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});


And it was pointed out to you that that was a bad idea.

It was a bad idea in 2001 and it is a bad idea in 2009.


> But it appears that this server is not providing this information.  


It only needs to provide that information sometimes.


> What is 
> the proper way to get this info.


If you had taken the advice from 8 years ago to use CGI.pm, you
would never have noticed a problem, as CGI.pm can correctly
handle both POST and GET.


> Here is the information that the server is providing:

> REQUEST_METHOD = GET


Your code above is for POST requests. This is not a POST request.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Thu, 16 Apr 2009 10:45:29 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: no $ENV{'CONTENT_LENGTH'}
Message-Id: <Xns9BEF44BC72350asu1cornelledu@127.0.0.1>

"Guy" <someone@somewhere.nb.ca> wrote in
news:49e69739$0$5478$9a566e8b@news.aliant.net: 
> 
> "Glenn Jackman" <glennj@ncf.ca> a écrit dans le message de news: 
> slrngud4he.kbb.glennj@smeagol.ncf.ca...
>> At 2009-04-15 08:25PM, "Guy" wrote:
>>>  I was using the following:
>>>      read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>>>
>>>  But it appears that this server is not providing this information. 

 ...

>>
>> CONTENT_LENGTH is set only for POST submissions.
>>
>> -- 
>> Glenn Jackman

Don't quote sigs.

>>    Write a wise saying and your name will live forever. -- Anonymous
> 
> I had forgotten about GET/POST. 

Use CGI.pm or CGI::Simple rather than cargo cult code to decode and 
process requests.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Wed, 15 Apr 2009 21:21:50 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: using SSH without modules
Message-Id: <slrngud5hu.lpr.tadmc@tadmc30.sbcglobal.net>

Nene <rodbass63@gmail.com> wrote:
> On Apr 15, 5:14 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
>> Nene <rodbas...@gmail.com> wrote:
>> > My object is to do a few things without the use of modules,
>>
>> What is wrong with modules?
>
> I, personally, love modules. 


I did not ask how you feel about modules.

I asked why you cannot use modules.


> But my manager doesn't.


Errr, OK then.

What does your manager not like about modules?

If you don't tell us the objections we will not be able to offer
a solution that avoids the objections.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 15 Apr 2009 18:29:32 -0700
From: sln@netherlands.com
Subject: Re: UTF-32 and Regular Expressions on Binary Data  (was Re: XML::LibXML UTF-8 toString() -vs- nodeValue())
Message-Id: <v02du4lir5u1t5o954labaimgd71skl8k5@4ax.com>

On Mon, 13 Apr 2009 13:59:10 -0700, sln@netherlands.com wrote:

>On Sat, 11 Apr 2009 11:59:55 +0200, "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>[snip]
>My goal is to convert 32-bit binary data to Unicode character's that can
>be used as both the data and the pattern in regular expression matching.
>
>I believe I am halfway there, the binary to Unicode (Perl internal utf8) conversion,
>which at least will do (I think) from 0..10FFFF (hex). We need 0..(2**32 - 1), but the
>references I looked at are pretty old (@2002) so this may be possible now.

This should do it. Values from 0..(2**32 - 1) are indeed possible since UTF-32
translates into utf-8 code points (1-6 bytes). I let it run for a while from different
points. Works fine.

Regular expressions work fine as well. I now see this as a good tool that can be
used in various categories, statistics, number series and others.

Enjoy!

-sln

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

## fr10.pl
## --
## Tests cases 1,2.
## 32-bit binary pattern searching using Regexp.
##

use warnings;
use strict;

use Encode;

binmode STDOUT, ':utf8';

#use constant BOM32 => "\x{ff}\x{fe}\x{0}\x{0}"; # L.Endian
use constant BOM32 => 65279;

# :: TEST 1 - just print each array utf32 value with its decoded utf8 ord.

  my @adata1 = (ord('a'), 0 .. 300, BOM32);
  my $str;

  for (@adata1)
  {
	$str = decode("UTF-32", pack 'L*', (BOM32, $_));
	# print "$_ ",ord( $str ),"\n";
  }

# :: TEST 2 - Generate multiple regexps with utf32 decoded chars from the array.
#           - Apply them to a decoded string made up of the array.
#           - This is just to test how the range of all numbers might behave as decoded chars in regexps.
#           - In reality a single regexp would probably be applied across the whole string globally,
#             advancing pos() to $-[0] +1 after each match. 

  my @adata2 = (120000,21,22,23,24,25,26,27,28,29,ord('a'),31, 55..300);
  $str = decode("UTF-32", pack 'L*', (BOM32, @adata2));

  print "\nstr = ",$str,"\nlength = ",length($str),"\n";

  foreach my $val (@adata2) 
  {
	# alternative pattern, identical result
	# my @tt = map {quotemeta} split //, decode("UTF-32", pack 'L*', (BOM32, $val, $val+1, $val+2, $val+7, $val+10));
	# my $pattern = sprintf "(%s%s%s).{0,5}([%s-%s])", @tt;

	my @tt = map {quotemeta} split //, decode("UTF-32", pack 'L*', (BOM32, $val, $val+2, $val+7 , $val+10));
	my $pattern = sprintf "([%s-%s]{3}).{0,5}([%s-%s])",  @tt;

	print "\nval = $val,  params = @tt,  pattern = $pattern\n";

	if ( $str =~ /($pattern)/)
	{
		print "matched:\n";
		print "  1 = '@{[getordsplit ($1)]}',  length = ".length($1). "\n";
		print "  2 = '@{[getordsplit ($2)]}',  length = ".length($2). "\n";
		print "  3 = '@{[getordsplit ($3)]}',  length = ".length($3). "\n";

	}
  }

# split string, return array
sub getordsplit { return map {ord $_} split //, shift if @_; ()}
sub getcharsplit  { return split //, shift if @_; ()}

__END__








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

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 V11 Issue 2343
***************************************


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