[15494] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2904 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 29 11:10:20 2000

Date: Sat, 29 Apr 2000 08:10:13 -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: <957021012-v9-i2904@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 29 Apr 2000     Volume: 9 Number: 2904

Today's topics:
    Re: Perl to Java Bytecode Compiler? (Randal L. Schwartz)
        Premature end of script headers (G.A.D.Miles)
    Re: Premature end of script headers <rootbeer@redcat.com>
    Re: Print Just Once When in (<>)? <morbus@disobey.com>
    Re: purpose of use vars ()  ? (M.J.T. Guy)
    Re: Random number (Randal L. Schwartz)
    Re: Response from perlbug@perl.com (M.J.T. Guy)
        Retrieving data from another server crtdude@my-deja.com
    Re: Should a class that exports no symbols provide an e (M.J.T. Guy)
    Re: String to scalar (Bart Lateur)
    Re: subname from subref (M.J.T. Guy)
    Re: why is thi not working? <flavell@mail.cern.ch>
    Re: Write format to string <mhughes@nyx.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 29 Apr 2000 05:16:41 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl to Java Bytecode Compiler?
Message-Id: <m1snw5t846.fsf@halfdome.holdit.com>

>>>>> "Sydney" == Sydney Lu <slu_2@altavista.net> writes:

Sydney> I didn't find anything about this in the FAQs, but apologies in
Sydney> advance if it was. I read an interview that Larry did a while ago, in
Sydney> which he talked about the possibility of a Perl to Java Bytecode
Sydney> 'compiler,' of sorts. 

It's in the CPAN at B::JVM.  A work in progress.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 29 Apr 2000 10:01:10 GMT
From: usad@gadnet.com (G.A.D.Miles)
Subject: Premature end of script headers
Message-Id: <390ab1a1.73415488@news.newsguy.com>

My system error log sometimes shows the error: "access to
/usr/..../bpwork2.cgi failed for 216......205, reason: Premature end
of script headers".

Most of the time the script works fine. Does anyone know what might
cause this error on some occasions and not others?

Thanks,

Drummond Miles
BannerPlus Banner Exchange Software
http://www.gadnet.com/bplus



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

Date: Sat, 29 Apr 2000 07:57:22 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Premature end of script headers
Message-Id: <Pine.GSO.4.10.10004290753540.21722-100000@user2.teleport.com>

On Sat, 29 Apr 2000, G.A.D.Miles wrote:

> Subject: Premature end of script headers

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.cpan.org/
   http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html
   http://www.cpan.org/doc/manual/html/pod/

> Most of the time the script works fine. Does anyone know what might
> cause this error on some occasions and not others?

Hundreds of reasons! But perl should (almost) always give a vital clue in
its dying words. Your most important task should be to find a way to
capture those; you may wish to search for the docs, FAQs, and newsgroups
about webservers in general and your webserver in particular for more
information.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 29 Apr 2000 09:56:38 -0400
From: Morbus Iff <morbus@disobey.com>
Subject: Re: Print Just Once When in (<>)?
Message-Id: <morbus-69B845.09563829042000@news.totalnetnh.net>

In article <8ec5jp$2s7$1@wanadoo.fr>, "Elisa Roselli" 
<e.roselli@volusoft.com> wrote:

> # The problem line. If I put it here, it prints to screen rather than in 
>
>          print "# This program has already been run on this file\n";
> 
>          while (<>)
>
>          #print "# This program has already been run on this file\n";
> 
>
> So my question is, where to put my problem line? After the (<>) it prints 
> every block, before the (<>) it prints to screen.

I have absolutely no clue. I know nothing abou the Korn shell. You could 
cheat though, and do something like:

   while (<>) {

      unless ($printed) { 
         print "# This program has ...";
         $printed = 1;
      }

      . . .

Again, cheating, but hey <g>...

Morbus Iff
http://www.disobey.com/


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

Date: 29 Apr 2000 14:11:26 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: purpose of use vars ()  ?
Message-Id: <8eeqie$a3j$1@pegasus.csx.cam.ac.uk>

Jonathan Stowe  <gellyfish@gellyfish.com> wrote:
>
>It is used mostly when 'use strict' or 'use strict "vars"' is in operation.
>
>It causes package global variables to be predeclared in such a way that
>you dont have to supply an explicit package name to to the variable.

It's also used to frighten away the

Name "main::y" used only once: possible typo at - line 4.

error messages.


Mike Guy


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

Date: 29 Apr 2000 05:06:17 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Random number
Message-Id: <m1zoqdt8li.fsf@halfdome.holdit.com>

>>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:

Larry>      rand < 0.5

Nope.  Thanks to the DWIMming overload on "<", you get this:

        $ perl -e 'print rand < 0.5'
        Warning: Use of "rand" without parens is ambiguous at -e line 1.
        Unterminated <> operator at -e line 1.
        $

Doh!  I hate that when that happens.  And weirdly enough, one fix
is "rand > 0.5". :)  Another would be "rand() < 0.5".

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 29 Apr 2000 14:30:47 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Response from perlbug@perl.com
Message-Id: <8eermn$b5o$1@pegasus.csx.cam.ac.uk>

Mike Fry <nospam.yrfekim@nospam.acirfai.com> wrote:
>
>Actually, one of the bugs was indirectly about perlbug, which is why I 
>couldn't use it to report my errors. Guess I'll have to do as you 
>advised and search through the perlbug database. I seem to recall trying
>to do this previously without much success. Has anyone any tips on 
>searching when you don't have a bug ticket number?

All perl bug reports go to the perl5-porters mailing list, so you can
do keyword searches in the archive:

    http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters

And if by "about perlbug" you mean the perlbug script (rather than the
bug database), note that you don't *need* to use it  -  it's just a
convenience.    You can just send mail to   perlbug@perl.org.    But
make sure you include the output from "perl -V" (or the myconfig script)
in your message.    And of course use a correct From: address.   :-)


Mike Guy


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

Date: Sat, 29 Apr 2000 10:52:45 GMT
From: crtdude@my-deja.com
Subject: Retrieving data from another server
Message-Id: <8eeetq$bkm$1@nnrp1.deja.com>

Gotta little problem here for a REAL EXPERT. Hope to get some help.

I have a flatfile database controlled Perl login script controlling access to
a particular area of my web site. Works great with no problems. However, the
site is using frames and one of the accessible content pages is a
reservations page for meeting space bookings. This page is controlled by a
third party and transacts all of the credit card info and whatnot.

I collect some of the data which is required on the space booking form when
the user registers in my Perl script. I am trying to fill out (as much as I
can) for the user by clicking a Javascript button on the third party's page. 
I ran a Javascript as shown, in the booking page, to access a page on my web
server so the users information could write to the document.  I got it to
work in Netscape however I am having a problem in IE.

Code examples are below. Can anyone help???

Regards to all,

Ralph

==>SCRIPT ON 3RD PARTY FORM
=======================================================
<SCRIPT LANGUAGE="JavaScript">
<!-- hide it

function openDataRetrievalWindow() { // create a variable under the window
object for the named form.  window.bookfrm = document.bookfrm;

window.open( "http://BLAH-BLAH.html",
"data_retrieval", "height=75,width=250,resizable=no" ); }

// --></SCRIPT>
=======================================================
==> BLAH-BLAH.HTML ON MY SERVER

<html>
<head>
<script language="JavaScript">

// page onLoad event handler.
function evt_onLoad() {
var error_message = "__ERROR_MESSAGE__"

// if error_message set, display it; otherwise populate form fields.  if (
error_message != "" ) alert( error_message ); else populateFormFields();

// close this window.
window.parent.close();
}

// populates the form fields on the opening page.
function populateFormFields() {
var wnd_opener = window.parent.opener;
var state_code =    "__STATE_CODE__";
var country_code =  "__COUNTRY_CODE__";

// set field values. with ( window.parent.opener ) { // text fields:
bookfrm.fname.value  = "__FNAME__"; bookfrm.lname.value  = "__LNAME__";
bookfrm.phone.value  = "__PHONE__"; bookfrm.freq_guest_id.value =
"__FREQ_GUEST_ID__";  bookfrm.email_addr.value	= "__EMAIL_ADDR__";
bookfrm.addr_1.value  = "__ADDR_1__"; bookfrm.addr_2.value  = "__ADDR_2__";
bookfrm.addr_3.value  = "__ADDR_3__"; bookfrm.addr_4.value  = "__ADDR_4__";
bookfrm.city.value  = "__CITY__"; bookfrm.postal_code.value  =
"__POSTAL_CODE__";

// select fields: setSelectValue( bookfrm.state_code,  "__STATE_CODE__" ); 
setSelectValue( bookfrm.country_code, "__COUNTRY_CODE__" );  } }

// sets the selected option in a select field.
function setSelectValue( field, selected_value ) {
for ( var i = 0; i < field.options.length; i++ ) {
if ( field.options[ i ].value == selected_value ) {
field.selectedIndex = i;
break;
}
}
}

</script>
<body onLoad="evt_onLoad();">
</body>
</html>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 29 Apr 2000 13:57:47 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Should a class that exports no symbols provide an empty import method?
Message-Id: <8eepor$9d6$1@pegasus.csx.cam.ac.uk>

Francis Litterio  <franl-removethis@world.omitthis.std.com> wrote:
>"perldoc Exporter" explains:
>
>	As a general rule, if the module is trying to be object
>	oriented then export nothing.
>
>Does this mean I can omit "use Exporter;" from my class and simply
>provide an empty "import" method (as follows)?

Better still  -  you don't need to provide an import method at all.

Or you could use the import method for some entirely different purpose,
such as passing options to the module.    See for example what the
strict.pm module does.


Mike Guy


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

Date: Sat, 29 Apr 2000 11:46:41 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: String to scalar
Message-Id: <390ac1c6.3372230@news.skynet.be>

schnurmann@my-deja.com wrote:

>I know this is a really dumb question, but how does one get from a
>string that contains a number to a scalar?

Perl uses a caching mechanism for scalars, for efficiency. A scalar can
contain multiple representations of the same value. If a new value
assigned to a scalar, all other representations are marked "invalid". As
soon as you need that representation, for example using a string as a
number, or a number as a string, Perl will use the cached
representation, or do the conversion on the fly if it didn't exist yet
(and cache it for the next times).

So, the short answer: just use the string as a number. The conversion
will happen only the first time you do that.

-- 
	Bart.


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

Date: 29 Apr 2000 13:36:58 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: subname from subref
Message-Id: <8eeohq$8ag$1@pegasus.csx.cam.ac.uk>

Dan Sugalski  <dan@tuatha.sidhe.org> wrote:
>
>This isn't a 100% general solution, FWIW. You'll have problems with
>anonymous sybs, subs that've been redefined after the table's built, and
>globs that get localizes. (Though that's not that common) But, then,
>there's no general way to go from a reference to the name of the thing
>being referred to in perl.

The method used by the debugger (in up-to-date Perl versions) is
probably as general as you'll get and of course enormously more efficient:

sub CvGV_name_or_bust {
  my $in = shift;
  return if $skipCvGV;          # Backdoor to avoid problems if XS broken...
  $in = \&$in;                  # Hard reference...
  eval {require Devel::Peek; 1} or return;
  my $gv = Devel::Peek::CvGV($in) or return;
  *$gv{PACKAGE} . '::' . *$gv{NAME};
}

Devel::Peek comes as standard with current Perls.   Pity its
documentation is woefully inadequate.


Mike Guy


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

Date: Sat, 29 Apr 2000 12:48:54 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: why is thi not working?
Message-Id: <Pine.GHP.4.21.0004291240470.5307-100000@hpplus01.cern.ch>

On Fri, 28 Apr 2000, Tad McClellan wrote:

> >print "Content-type: text/html\n\n";
> >print 'hello world';

> You really shouldn't lie to the browser like that.
> 
> Either give it HTML when you say that you are going to
> give it HTML, or say that you are giving it text/plain.

Good point.

> :-)

Smiley or no smiley - the failure to observe your advice produces some
real-life problems.  (I reported such a bug, in an online service
related to Perl, quite recently.)

Note however that MS have decided, according to their online
documentation and in violation of the published IETF standards-track
interworking RFC, 2616, that text/plain means "client should guess",
so you can still fool MSIE (and in some situations provoke a security
compromise) by sending it text/plain that happens to look sufficiently
like HTML.

-- 

Partake of distilled wisdom of Usenet - read the FAQs.
Before you ask.




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

Date: Sat, 29 Apr 2000 07:37:32 -0600
From: Monica Hughes <mhughes@nyx.net>
Subject: Re: Write format to string
Message-Id: <390AE59C.73046A78@nyx.net>

I am a newbie, so take this with a grain of salt.  I believe what you
are looking for is at the end of perlform -- there's a sample sub there
called swrite.  See ("Accessing Formatting Internals"):

http://www.perl.com/pub/doc/manual/html/pod/perlform.html

(I overlooked it, too.)



Anzej Becan wrote:
> 
> Hello!
> 
> How to write formated text do string. Example for formated output:
> 
> $~ = "IZPIS";
> write;
> format IZPIS =
>    @<<<<< @<<<<<<<<<<< @>>>>> @#####.## @#####.## @#########.##
>    $num1, $num2, $num3, $num4, $num5, $num6
> .
> 
> This code outputs text on the screen. How to this output write to string and
> not on the screen.
> 
> Thanks for any advice!
> 
> Anzej Becan


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

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 2904
**************************************


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