[19346] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1541 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 16 14:05:50 2001

Date: Thu, 16 Aug 2001 11:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <997985110-v10-i1541@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 16 Aug 2001     Volume: 10 Number: 1541

Today's topics:
    Re: "shifting" values of the @_ array?? <ren@tivoli.com>
    Re: behavior in a while loop -thanks! (djcabz)
        CGI Parser (Nick Paszty)
    Re: CGI Parser (Malcolm Dew-Jones)
    Re: Comma's at end of list can break program?? <ren@tivoli.com>
    Re: downloading files from the web <ubl@schaffhausen.de>
    Re: downloading files from the web <johndporter@yahoo.com>
    Re: downloading files from the web <flavell@mail.cern.ch>
    Re: Evaluation order of object methods <johndporter@yahoo.com>
    Re: Evaluation order of object methods <djberge@uswest.com>
    Re: File Locations (Anno Siegel)
    Re: File Locations <john@trumpetweb.co.uk>
    Re: How replace (Anno Siegel)
        How to get the name of executing perl script? (Stan Brown)
    Re: How to get the name of executing perl script? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: How to get the name of executing perl script? (Stan Brown)
        Multi-part HTML (Bob)
    Re: Newbie Activeperl Win2k <bcaligari@fireforged.com>
    Re: OT: Why is there so much white space in perl docume <ren@tivoli.com>
    Re: OT: Why is there so much white space in perl docume <miscellaneousemail@yahoo.com>
        Passing single reference into a sub assigning @_ into a <miscellaneousemail@yahoo.com>
    Re: Passing single reference into a sub assigning @_ in <jasper@guideguide.com>
    Re: Perl and JVM <arnuga@earthlink.net>
        Perl dup broken? <joe+usenet@sunstarsys.com>
    Re: Perl OO needs the opposite of SUPER:: <comdog@panix.com>
    Re: Problems starting a child-process using "system" (Anno Siegel)
    Re: regex question... <strawSPAM_BEGONEman@plexi.com>
    Re: SQL (MySQL) Windows <bart.lateur@skynet.be>
        test post <john@trumpetweb.co.uk>
        Text::Wrap/ANSI proplem <philip@zaynar.demon.co.uk>
        What's the Problem locating Files? <john@trumpetweb.co.uk>
    Re: Why is there so much white space in perl documentat <ren@tivoli.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 16 Aug 2001 09:44:13 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: "shifting" values of the @_ array??
Message-Id: <m38zgk3w02.fsf@dhcp9-161.support.tivoli.com>

On 16 Aug 2001, demerphq@hotmail.com wrote:

> sub bar {
>   $_="Hello!";

Should be:

    $_[0] = "Hello!";

> }
> 
> my $s="Dude!";
> bar($s);
> print $s; #prints Hello!

-- 
Ren Maddox
ren@tivoli.com


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

Date: 16 Aug 2001 10:36:54 -0700
From: c_barbet@hotmail.com (djcabz)
Subject: Re: behavior in a while loop -thanks!
Message-Id: <4256dfd1.0108160936.6fba9128@posting.google.com>

> Yves
> Ps (They really are nice people, just a bit testy at times, especially
> when they think someone hasnt put in the effort before they ask for
> help.)

Tad, Ren, and Yvon:

This is alot to chew on..  And I shall.

Tad, maybe *I* was having the bad day and felt you were attacking
after re-reading I realized it was all in good humor... Again, thanks
for your time!

Yves, I'll work on the google formatting... =)


Regards,
Carlos


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

Date: 16 Aug 2001 09:36:11 -0700
From: paszty@xoma.com (Nick Paszty)
Subject: CGI Parser
Message-Id: <14ce1c21.0108160836.48873373@posting.google.com>

hello.

we have perl installed on vms and i'm trying to get my html form field
parser to work. i've been using the following form parser on unix
without a problem (different path to interpreter).

#!lardat4disk:[perl]

print "Content-type: text/html\n\n";

$contentLength=$ENV{'CONTENT_LENGTH'};
   read(STDIN,$formData,$contentLength);

foreach $pair(split(/&/,$formData)){
	# for each pair, split $key (name) and $value variables;
	($key,$value)=split(/=/,$pair);
	# get rid of the pesky %xx encodings;
	$key=~ tr/+/ /;
        $key=~ s/%([\da-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	$value=~ s/%([\da-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        $value=~ tr/+/ /;
	# use the $key as an index for $parameter hash table, $value as the
value;
	$parameters{$key}=$value;
}

since we're on vms, i've changed the read line to the following

read(SYS$INPUT,$formData,$contentLength);

here is the error

Missing comma after first argument to read function at test_parser.pl
line 6, near "$contentLength)"
Execution of test_parser.pl aborted due to compilation errors.
%SYSTEM-F-ABORT, abort

i am assuming that SYS$INPUT on vms is analogous to STDIN on unix.i
think i need to mask the $ character in SYS$INPUT.

any suggestions?

thanks,

nick


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

Date: 16 Aug 2001 10:21:38 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: CGI Parser
Message-Id: <3b7c0122@news.victoria.tc.ca>

Nick Paszty (paszty@xoma.com) wrote:
: hello.

: we have perl installed on vms and i'm trying to get my html form field
: parser to work. i've been using the following form parser on unix
: without a problem (different path to interpreter).

(I can't check any of the below right now because it appears that recent
upgrades to our VMS systems have disabled my old perl executable - so I
may be out to lunch).


You could try switching to CGI.pm.  It might work already.

(snip...)

: since we're on vms, i've changed the read line to the following

: read(SYS$INPUT,$formData,$contentLength);

I wouldn't do that if I were you.

 ...
: i am assuming that SYS$INPUT on vms is analogous to STDIN on unix.i
: think i need to mask the $ character in SYS$INPUT.


SYS$INPUT is the *name* of a file, (albeit a somewhat special file).  It
is similar to /dev/tty, and would be used the same way (i.e. you would
need to quote it and use it as a string). It is not in the least analogous
to stdin, which is a handle to an internal data structure within a
programming language.

I am quite sure that perl on VMS still uses the variable called STDIN to
access the terminal and such-like input to the script.



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

Date: 16 Aug 2001 10:18:58 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Comma's at end of list can break program??
Message-Id: <m3y9ok2ftp.fsf@dhcp9-161.support.tivoli.com>

On Thu, 16 Aug 2001, david.bouman@nl.xo.com wrote:

> As for aesthetics, personally I find
> 
>     @list = (
>             ,  "We have one string here"
>             ,  "and one here"
>             ,  "and another string"
>             ,  "this is also a string"
>             ,  "final string is here"
>             )
>     ;
> 
> to look even more pleasing (also, it saves having to re-align when
> adding still wider strings).
> 
> Obviously, as written this won't work as this has something "too
> much".

Not that I recommend it, but sticking a "()" on the first line solves
the problem:

my @list = (()
            ,  "We have one string here"
            ,  "and one here"
            ,  "and another string"
            ,  "this is also a string"
            ,  "final string is here"
            )
;

It seems kind of silly that Perl complains about a leading comma in
this situation since multiple embedded commas works fine.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Thu, 16 Aug 2001 17:49:47 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: downloading files from the web
Message-Id: <3B7BF9AB.CCF0836F@schaffhausen.de>

spurcell schrieb:
> 
> Hello,
> I want to allow users to download some binary images (TIFF and EPS) images
> from the web. I  have code posted below that reads the image into a
> filehandle, and then tries to print the data to the browser. The problem is,
> that I do not know what mime type to use. I have tried:
> application/tiff
> application/octet-stream
> and about every mime type I can find in all my books.

This has absolutely nothing to do with Perl and everything to do with the
browser something is using. Zip the files, and most browsers will show
the 
download dialog. Also, read about redirecting. It will serve your
purpose 
much better than actually reading and printing those files.

->malte


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

Date: Thu, 16 Aug 2001 16:28:24 GMT
From: John Porter <johndporter@yahoo.com>
Subject: Re: downloading files from the web
Message-Id: <3B7BF3D6.F3DD85C1@yahoo.com>

spurcell wrote:
> I do not know what mime type to use. I have tried:
> application/tiff
> application/octet-stream
> and about every mime type I can find in all my books.
> 
> Everytime I print the data to the broswer, it tries to display either the
> asset to the screen, or as a quick time image. I need it to show the
> download prompt (so they can save it to disk).

The problem is you keep trying mime types that the browser knows
how to handle.  If you use a mime type that the browser doesn't
know how to handle, it will (usually) ask the user to save it to
disk.  So try something oddball, like maybe application/x-unknown.

-- 
John Porter


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

Date: Thu, 16 Aug 2001 18:48:05 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: downloading files from the web
Message-Id: <Pine.LNX.4.30.0108161831180.4091-100000@lxplus023.cern.ch>

On Aug 16, John Porter declaimed to the assembled multitude:

> spurcell wrote:

> > I need it to show the
> > download prompt (so they can save it to disk).

Isn't it more a question of not what _you need, but what _they_ need?

Seems to me that anyone who has the competence to accept a downloaded
file and do anything meaningful with it, surely has the competence to
learn what their browser's command for download-this-link might be
(shift-click, 'd' keycommand, right-click-and-menu, or whatever).

If I couldn't trust them to achieve the latter, then I wouldn't trust
them to know how to handle the situation of the browser deciding for
itself to download the file.  I have at least two users who regularly
find themselves inadvertently downloading files and then failing to
discover "where the damned browser has put them".  When they finally
call me in, I usually discover a vast archive of previously downloaded
files in there, that they had no clue was cluttering-up their hard
disks.

The original concept of the web was based on the server sending out an
honest description of the Content-type which they are sending, NOT
trying to second-guess what the user might or might not want to do
with that content.   That still makes sense to me, not /despite/ the
dumbing-down of the user population, but precisely _because_ of it.

> The problem is you keep trying mime types that the browser knows
> how to handle.  If you use a mime type that the browser doesn't
> know how to handle, it will (usually) ask the user to save it to
> disk.  So try something oddball, like maybe application/x-unknown.

That's excellent advice on the technical means to achieve what was
asked.  It is specification-conforming, and will work not only on WWW
browsers, but is also an option that happens to cause MSIE to work
according to the mandate of the specifications.

As I say, my disagreement was not with your advice on how to achieve
it technically, but on the appropriateness of an author wanting to
impose this behaviour on their readers.

all the best

-- 
         "Always remember you're unique, just like everyone else."
               - I'm-no-Lady Polgara, quoting Anonymous





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

Date: Thu, 16 Aug 2001 16:32:37 GMT
From: John Porter <johndporter@yahoo.com>
Subject: Re: Evaluation order of object methods
Message-Id: <3B7BF4CD.AFB13CB8@yahoo.com>

Mr Sunblade wrote:
> if an assignment
> is made, then only return the results of the method call but *don't* actually
> modify the object itself.  Modify the object itself if, and only if, an
> assignment is not made.

Well, then, that's simple.  Just test wantarray:

	if ( wantarray ) {
		local_copy = contents_of_object;
		uniquify local_copy;
		return local_copy;
	}
	else {
		uniquify contents_of_object;
		return object;
	}

-- 
John Porter


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

Date: Thu, 16 Aug 2001 12:34:00 -0500
From: Mr Sunblade <djberge@uswest.com>
Subject: Re: Evaluation order of object methods
Message-Id: <3B7C0408.E08926FC@uswest.com>

John Porter wrote:

> Mr Sunblade wrote:
> > if an assignment
> > is made, then only return the results of the method call but *don't* actually
> > modify the object itself.  Modify the object itself if, and only if, an
> > assignment is not made.
>
> Well, then, that's simple.  Just test wantarray:
>
>         if ( wantarray ) {
>                 local_copy = contents_of_object;
>                 uniquify local_copy;
>                 return local_copy;
>         }
>         else {
>                 uniquify contents_of_object;
>                 return object;
>         }
>
> --
> John Porter

Remember, John, that I want to be able to chain together methods.

my $uniq_length = $so->unique()->length();  # Fails!

If I return anything other than a blessed reference the above code won't work.
That's my whole point.  I want to have my cake and eat it, too. :)  I don't want
to modify the original $so if an assignment is being made (which is why I was
toying with the notion of an 'inline' option but was hoping to avoid it).

I think what I really need is a fictional 'wantmethod' function which would
somehow do a lookahead, checking to see what the next operation on an object is.
The code would be something like:

if(wantmethod){ # return blessed copy of self }
elsif(defined wantarray){ # return a scalar or list }
else{ # return self }

Is this possible?

Regards,

Dan

--
"Evil will always triumph because Good is *dumb*."
-- Dark Helmet, 'Spaceballs: The Movie'





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

Date: 16 Aug 2001 16:03:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: File Locations
Message-Id: <9lgqsf$3em$3@mamenchi.zrz.TU-Berlin.DE>

According to John P <john@trumpetweb.co.uk>:
> Hi there All
> 
> I am distributing scripts which have the line.
> use Digest::MD5 qw (md5_base64);
> 
> Most of the time the scripts are fine but on some systems the users are
> getting the error message
> 
> Can't locate Digest/MD5.pm in @INC (@INC contains:
> /usr/local/lib/perl5/5.6.0/i686-linux /usr/local/lib/perl5/5.6.0
> /usr/local/lib/perl5/site_perl/5.6.0/i686-linux
> /usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)
> 
> I thought that this was a standard module. found in a standard location.
> Does anyone have any ideas please. I have asked them to check their Shebang
> lines are correct but they still get the error. I have some rather irrate
> customers!

Why are you asking this again, ignoring the reply (or replies) you got?

Anno


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

Date: Thu, 16 Aug 2001 17:38:18 GMT
From: "John P" <john@trumpetweb.co.uk>
Subject: Re: File Locations
Message-Id: <eyTe7.3446$ms2.286583@news1.cableinet.net>

Haven't had any replies, and my posting are not showing in my browser.
What's going on?

"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:9lgqsf$3em$3@mamenchi.zrz.TU-Berlin.DE...
> According to John P <john@trumpetweb.co.uk>:
> > Hi there All
> >
> > I am distributing scripts which have the line.
> > use Digest::MD5 qw (md5_base64);
> >
> > Most of the time the scripts are fine but on some systems the users are
> > getting the error message
> >
> > Can't locate Digest/MD5.pm in @INC (@INC contains:
> > /usr/local/lib/perl5/5.6.0/i686-linux /usr/local/lib/perl5/5.6.0
> > /usr/local/lib/perl5/site_perl/5.6.0/i686-linux
> > /usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)
> >
> > I thought that this was a standard module. found in a standard location.
> > Does anyone have any ideas please. I have asked them to check their
Shebang
> > lines are correct but they still get the error. I have some rather
irrate
> > customers!
>
> Why are you asking this again, ignoring the reply (or replies) you got?
>
> Anno




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

Date: 16 Aug 2001 15:32:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How replace
Message-Id: <9lgp34$3em$1@mamenchi.zrz.TU-Berlin.DE>

According to Tad McClellan <tadmc@augustmail.com>:
> Dmitry <sda999@mail.ru> wrote:
> 
> >Source string: "abcebsasaanrart"
> >I want transform in "abcebsasaanraart"
> > i.e. replace last "a" in "aa" (count "a" - arbitrary)
> 
> 
>    s/(.*a)/$1a/s;
> 
> or
> 
>    substr($_, rindex($_, 'a'), 1) = 'aa';

Yes, but it changes the string-final character to "aa" if there is no
"a".

     1 + rindex($_, 'a') and substr($_, rindex($_, 'a'), 1) = 'aa';

But that's hardly attractive.

Anno


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

Date: 16 Aug 2001 13:19:27 -0400
From: stanb@panix.com (Stan Brown)
Subject: How to get the name of executing perl script?
Message-Id: <9lgvav$i62$1@panix3.panix.com>

I'm writing a program, that needs to allow itself to be called again from a
user button.

How can I get the name of the curently executing script, so that I can pass
it to system()?





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

Date: Thu, 16 Aug 2001 19:36:56 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: How to get the name of executing perl script?
Message-Id: <3B7C04B8.5090604@post.rwth-aachen.de>

Stan Brown wrote:
> I'm writing a program, that needs to allow itself to be called again from a
> user button.

Not really sure what this is supposed to become, but anyway...

> How can I get the name of the curently executing script, so that I can pass
> it to system()?

You should have a look at the special variable $0 (as described in 
'perldoc perlvar') which contains the name of the programm currently 
executing.

Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: 16 Aug 2001 13:59:50 -0400
From: stanb@panix.com (Stan Brown)
Subject: Re: How to get the name of executing perl script?
Message-Id: <9lh1mm$k0b$1@panix3.panix.com>

In <3B7C04B8.5090604@post.rwth-aachen.de> Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> writes:

>Stan Brown wrote:
>> I'm writing a program, that needs to allow itself to be called again from a
>> user button.

>Not really sure what this is supposed to become, but anyway...

>> How can I get the name of the curently executing script, so that I can pass
>> it to system()?

>You should have a look at the special variable $0 (as described in 
>'perldoc perlvar') which contains the name of the programm currently 
>executing.
Cool, I knew thhee would be a cute perl hack ofr it. Thanks!


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

Date: 16 Aug 2001 17:29:00 GMT
From: bobberry@aol.com-nospam- (Bob)
Subject: Multi-part HTML
Message-Id: <20010816132900.25880.00002375@mb-mb.aol.com>

I have a perl program which sends:

	Content-Type: multipart/mixed; boundary=oooooooooo

	--oooooooooo
	Content-Type: text/html

	<html>
	<head><title>Sending a zip</title></head>
	<body>Sending a zip</body>
	</html>

	--oooooooooo
	Content-type: application/octet-stream
	Content-length: 12345
	Content-disposition: attachment; filename="my.zip"
	( ... the zip file ... )

	--oooooooooo
	Content-Type: text/html

	<html>
	<head><title>Zip Sent</title></head>
	<body>Zip Sent</body>
	</html>

	--oooooooooo--

Now Netscape does exactly what I expected. It shows the first html, asks for a
destination for the zip, and when the download is completed, it shows the
second html. 

IE, on the other hand, seems brain dead. It reads the first content-type spec,
but ignores "multipart". It displays everything following, including the
subsequent boundaries and content types and the zip file, as though it were a
single html.

I've read through RFC-2045 and RFC-2046 to see if there's something I'm
missing, but haven't found anything. Any idea how to get IE to properly handle
multi-part content?

Bob



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

Date: Thu, 16 Aug 2001 18:05:13 -0000
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Newbie Activeperl Win2k
Message-Id: <9lgqkr064i@enews1.newsguy.com>

"Wayne Lippold" <gwhs@bronxpages.com> wrote in message
news:f9Ie7.14648$Kf4.3391312@news02.optonline.net...
> I just installed activeperl on my Win2k Pro box, and my computer has no
> problem recognizing the .pl extension but it doesn't recognize .cgi
> extention.
>

from command line or from IIS?

IIS has different bindings for .pl (perl.exe) and .plx (perlIIS.dll)
extensions.  Check the ActiveState documentation and IIS help files.  From
the IIS manager you can add another extension, say .cgi, or .foo or
 .bar....whatever, and set all the parameters same as for .plx (as set by the
ActivePerl installer).

hope this helps

B.






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

Date: 16 Aug 2001 11:30:15 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: OT: Why is there so much white space in perl documentation??
Message-Id: <m3lmkk2ciw.fsf@dhcp9-161.support.tivoli.com>

On Wed, 15 Aug 2001, miscellaneousemail@yahoo.com wrote:

> In article <3b7aaf4c$1@news.microsoft.com>, Jürgen Exner at 
> jurgenex@hotmail.com says...
> 
>> Well, what about a right-click on the title bar of the DOS box,
>> select "Properties", select "Colors"? If this doesn't give you
>> enough options then I don't know what would.
>> 
> 
> Nope.  Can't do it Jurgen.  There is no "Colors" in my DOS prompt 
> properties.  

Strange... IIRC, that's been there since Windows 95, at least.  What
*do* you see when you look at "Properties..." of a running DOS prompt?

-- 
Ren Maddox
ren@tivoli.com


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

Date: Thu, 16 Aug 2001 17:36:52 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: OT: Why is there so much white space in perl documentation??
Message-Id: <MPG.15e5b2b7fc1f2f3a989765@news.edmonton.telusplanet.net>

In article <m3lmkk2ciw.fsf@dhcp9-161.support.tivoli.com>, Ren Maddox at 
ren@tivoli.com says...

> Strange... IIRC, that's been there since Windows 95, at least.  What
> *do* you see when you look at "Properties..." of a running DOS prompt?

I see the following tabs in a pop up window...

Program, Font, Memory, Screen, Miscellaneous

Inside the Font tab there is no change color anything.  You can change 
the font.  That's it. 

Even if I could change the color of the background in a DOS prompt I 
don't think I would read through perldocs in a DOS prompt anyway.  Can't 
go back and forth in them like I could in an editor of some kind. I guess 
I had just been making the point that Windows does not have native 
utilities to do as much as UNIX folks have at their disposal.  Which 
makes reading perldoc's at the command line a bit easier and more 
practical on UNIX I think.  

Thanks.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: Thu, 16 Aug 2001 17:30:47 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Passing single reference into a sub assigning @_ into a hash??
Message-Id: <MPG.15e5b0d2a2723e28989764@news.edmonton.telusplanet.net>

Hi everyone,

I am trying to create a sub that will accept an IO handle and printf to 
it.  If the IO handle is not specified I want the sub to print to STDOUT 
by deault. 

Here is the sub so far....

sub print_contents
{
  my %args = (
    IO_HANDLE => *STDOUT,
	@_);

  my ($key, $value);
  while (($key, $value) = each %file_hash)
  { 
    printf { $args{IO_HANDLE} } "%-20.20s %-10.10s %-15.15s %-13.13s %-
12.12s %-3.3s\n", $key, split(/,/,$value);
  }	
}

I called it by either ...

print_contents(\*STDOUT);
print_contents();

%file_hash is a global hash filled with key, value pairs of data.

print_contents is working just fine except for one thing.  Perl warns me 
that I am trying to pass a single value, namely \*STDOUT, to the sub and 
that I am initializing %args to a single value when I do that.  When I 
don't pass in an IO handle, no problem.  

The exact error message is....

D:\www>perl -WT D:\www\~prev-database.pl
Odd number of elements in hash assignment at D:/www/database.pm line 71 
(#1)
    (W misc) You specified an odd number of elements to initialize a 
hash,
    which is odd, because hashes come in key/value pairs.

jack@ardvark.com     Jack       20010812 18:34  Canada        Stony Plain  
Yes
linda@ant.com        Linda      20010812 18:34  France        Paris        
Yes
harry@elephant.net   Harry      20010810 16:00  Chile         Santiago     
No
tammy@kangaroo.com   Tammy      20010812 18:34  United States Chicago      
Yes

I include a copy of the dummy data to show that it is working ok.  Except 
for the warning.  

Should I heed the warning?  Is there a danger in not doing so?  Is there 
a way to rewrite something in print_contents so as to avoid what 
generates the warning?

Thanks for any input on this.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: Thu, 16 Aug 2001 18:50:22 +0100
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: Passing single reference into a sub assigning @_ into a hash??
Message-Id: <3B7C07DE.B4187FBD@guideguide.com>

"Carlos C. Gonzalez" wrote:
> 
> Hi everyone,
> 
> I am trying to create a sub that will accept an IO handle and printf to
> it.  If the IO handle is not specified I want the sub to print to STDOUT
> by deault.
> 
> Here is the sub so far....
> 
> sub print_contents
> {
>   my %args = (
>     IO_HANDLE => *STDOUT,
>         @_);

Why push it into a hash? Why not just:

my ($io_handle) = (@_, *STDOUT);

or

my $io_handle = $_[0] || *STDOUT;

or if a hash is your only choice (?) :

my %args = (
     IO_HANDLE => $_[0] || *STDOUT,
           );

> 
> print_contents is working just fine except for one thing.  Perl warns me
> that I am trying to pass a single value, namely \*STDOUT, to the sub and
> that I am initializing %args to a single value when I do that.  When I
> don't pass in an IO handle, no problem.

This is because @_ is empty, so there are only two elements in the list
you're assigning to the hash. As soon as you supply an argument, you
have three elements  (IO_HANDLE, *STDOUT, $_[0]). Ergo borked hash.


Jasper
-- 
      split//,'019617511192'.
      '17011111610114101114'.
      '21011141011840799901'.
            '17101174';
            foreach(0..
            $#_){$_[$_
            ++]^=$_[$_
            --]^=$_[$_
]^=$_[++    $_]if!($_%
2)}$g.=$_  ,chr($g)=~
 /(\w)/&&($o.=$1and
   $g='')foreach@_;
      print"$o\n"


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

Date: Thu, 16 Aug 2001 16:30:05 GMT
From: David Shultz <arnuga@earthlink.net>
Subject: Re: Perl and JVM
Message-Id: <q8tnntklsnn4k9mohtv0gi01l9crasnrhg@4ax.com>

You might want to check out Inline::Java which only creates 1 JVM and
uses it for all calls, but I'm not sure if this will do exactly what
you want, its worth checking out...

David S.

On 14 Aug 2001 19:31:04 -0700, tsmandel@mediaone.net (Ted) wrote:

>We have an Web App Server that is written in Perl, I have a major
>concern/problem.  When a client session is open, we want to call a
>java client interface (wrapper) that allows connections between Web
>App Server and our software.
> 
>My understanding that if I call this java client within Perl it will
>instantiate the JVM for each client session that is open.  This will
>be a huge problem.
>
>Any ideas in dealing with Perl that calls a java app without creating
>instance of the JVM for each client session.
>
>Thanks



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

Date: 16 Aug 2001 11:46:29 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Perl dup broken?
Message-Id: <m38zgk57oq.fsf@mumonkan.sunstarsys.com>

I've looked at perlfunc's open documentation,
and perlopentut, but I can't figure out how
duping is supposed to work.  The behavior
seems inconsistent across various perl versions 
(w/ and w/o PerlIO), and is surely buggy on 
linux 2.4 + perl 5.6.1 + sfio.

I apologize for the length of the post, but I am unable
to put my finger on exactly where the problem lies.  Any
help in pinning things down would be most appreciated.

To start, consider the following:

  #!/usr/bin/perl -w

  open FOO, "< $0" or die $!;
  open BAR, "<&FOO" or die $!;
  open QUUX, "<&=FOO" or die $!;

  ...

From what I can make out of the documentation,
from this point on I should have three open filehandles;
FOO, BAR and QUUX.  FOO and BAR should behave somewhat
independently, while FOO and QUUX should share some
resources (more or less as if *QUUX = *FOO).

Here's the full script:

% cat dup.pl
#!/usr/bin/perl -w
  open FOO, "< $0" or die $!;
  open BAR, "<&FOO" or die $!;
  open QUUX, "<&=FOO" or die $!;

  #<FOO>,<BAR>,<QUUX>;            # (1)
  #<QUUX>,<BAR>,<FOO>;            # (2)

  $_ = <BAR>;

  #<BAR>;                         # (3)

  close BAR or die $!;
  print;
  $_ = <QUUX>;
  print;

__END__

Commenting and uncommenting the marked lines results in completely
unexpected results.  As written, on perl 5.6.1+sfio I get

  % ./dup.pl 
  Name "main::FOO" used only once: possible typo at ./dup.pl line 2.
  #!/usr/bin/perl -w
    open FOO, "< $0" or die $!;
  %

This seems to suggest that BAR and QUUX are aliased, instead
of FOO and QUUX.  IOW, I would have expected to get

  Name "main::FOO" used only once: possible typo at ./dup.pl line 2.
  #!/usr/bin/perl -w
  #!/usr/bin/perl -w

Removing comments from lines marked (1), (2) or (3) produces
confusing results:

  (1) uncommented:
  % ./dup.pl 
  Use of uninitialized value in print at ./dup.pl line 12.
  Use of uninitialized value in print at ./dup.pl line 14.

  (2) uncommented:
  % ./dup.pl
  Use of uninitialized value in print at ./dup.pl line 12.
  open FOO, "< $0" or die $!;

  (2+3) uncommented:
  Use of uninitialized value in print at ./dup.pl line 12.
  open FOO, "< $0" or die $!;

Upon further testing, it seems the uninitialized values 
are caused by perl attempting to read from arbitrary locations
in the file (making ./dup.pl large enough confirms this).
Also removing QUUX from the picture seems to be of little
help:

#!/usr/bin/perl -w
  open FOO, "< $0" or die $!;
  open BAR, "<&FOO" or die $!;  
  <FOO>;    # confuses BAR; replacing with <BAR>,<FOO> seems ok
  $_ = <BAR>;
  close BAR or die $!;
  print;
__END__

~> Use of uninitialized value in print at ./dup.pl line 7.

Most of these problems appear fixable by adding an explicit seek(),
but that doesn't always work, either:

#!/usr/bin/perl -w
  open FOO, "< $0" or die $!;
  open BAR, "<&FOO" or die $!;
  open QUUX, "<&=FOO" or die $!;

  seek QUUX, 0, 0; # no other 
  seek BAR, 0, 0;  # ordering of these 3 lines
  seek FOO, 0, 0;  # seems to improve the situation

  $_ = <BAR>;
  close BAR or die $!; # uncommenting this line also changes the result
  print;
  $_ = <QUUX>;
  print;
  $_ = <FOO>;
  print;
__END__

~>  #!/usr/bin/perl -w
      open FOO, "< $0" or die $!;
    Use of uninitialized value in print at ./dup.pl line 16.

Any thoughts?  Is there some documentation available that can
explain these results?

TIA.
-- 
Joe Schaefer    "I've come loaded with statistics, for I've noticed that a man
                          can't prove anything without statistics."
                                               --Mark Twain



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

Date: Thu, 16 Aug 2001 11:26:25 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: Perl OO needs the opposite of SUPER::
Message-Id: <comdog-642901.11262516082001@news.panix.com>

In article <a73bcad1.0108160019.2d7b9b81@posting.google.com>, 
johnlin@chttl.com.tw (John Lin) wrote:

> I encounter a problem and figured out that for Perl OO, we need
> an expression which is opposite to SUPER::  (let's say VIRTUAL::)
> 
> SUPER::    inheritor-class calls base-class
> VIRTUAL::  base-class calls inheritor-class

> When I designed a Base class, in Base::init() I want to call the
> inheritor-class's init().

> sub Base::init {
>     my $self = shift;
>     $self->init;  # how can I call the init() of inheritor-class here?

that does call the derived class's init() ;)

> }

if $self is blessed into the derived class, then the derived
class's init() is called.  if there is no init() in the derived
class, Perl rightly walks @ISA looking for one.  the object 
should call the method in the class into which it was blessed.
you don't need extra bells and whistles to make that happen.

if this is not what you want to happen, and you want the
base class's init() called first (but why would you have
overridden a method you didn't really want to override?),
then you can simply not override the method.  the derived
classes will have some other method name that the
base class expects.

    #!/usr/bin/perl

    package MyBase;

    sub new { bless [], shift }

    sub init 
        { 
        print "This is MyBase::Init\n"; 
        $_[0]->_init; 
        print "MyBase::Init again\n" 
        }

    package MyDerived;

    @ISA = qw(MyBase);

    sub _init { print "MyDerived::Init was called\n" }

    ##################

    package main;

    my $object = MyDerived->new->init;

    __END__

-- 
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

Date: 16 Aug 2001 15:59:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problems starting a child-process using "system"
Message-Id: <9lgqlv$3em$2@mamenchi.zrz.TU-Berlin.DE>

According to Daniel Wetzler  <d.wetzler@dawe-computer.de>:
> Hi,
> 
> I want to start a compiled program out of a perl script as a child process
> to make it run after the parent process has ended.
> This works great with the "system"-command because it forks the called
> program into a child process.
> 
> My problem is, that my parent-process (the perl-script) seems to wait
> for the child process for a particular time, doing nothing.
> I don't want it to wait or want to shorten the time while it's waiting to
> a unremarkable time.
> 
> How can I do this ?

You fork/exec the program yourself.  See the appropriate perldocs.

Anno


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

Date: Thu, 16 Aug 2001 11:14:05 -0400
From: A person <strawSPAM_BEGONEman@plexi.com>
Subject: Re: regex question...
Message-Id: <3B7BE33D.DE95F301@plexi.com>



Crystal.

Thanks for taking the time to clue me in.






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

Date: Thu, 16 Aug 2001 16:13:16 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: SQL (MySQL) Windows
Message-Id: <0urnntsmn94uflahfj10888lihqu4pmaob@4ax.com>

Paul Fortescue wrote:

>install_driver(mysql) failed: Can't locate loadable object for module
>SQL::Statement in @INC (@INC contains: C:\Inetpub\scripts C:/Perl/lib
>C:/Perl/site/lib .) at C:/Perl/lib/DBD/mysql.pm line 12
>
>which I assume means that I have to install somthing else. I guessed at SQL
>and SQL::statement neither of which was a great guess! I do have a
>statement.dll file and if I try to install that manually (will I never
>learn?) it looks for Perl.dll which I think it shouldn't. I am getting very
>stuck.

It looks like a faulty installation of SQL::Statement.

There is a SQL::Statement on
<http://www.activestate.com/PPMpackages/5.6plus/MSWin32-x86-multi-thread/SQL-Statement.tar.gz>.
The PPD is one directory up.

Any reason why you don't want to use PPM? If it's a lack of internet
connection, that can be fixed. Download the PPD file and the .tar.gz
file, put them next to each other, and edit the PPD file so that the
HREF attribute for the CODEBASE tag, for the  architecture
"MSWin32-x86-multi-thread", uses a relative path instead of an absoilute
URL. Then you can do a local install.

If you insist on manual installation, note that the DLL files should
come under the directory "auto". Thus:
"site/lib/auto/SQL/Statement.dll".

-- 
	Bart.


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

Date: Thu, 16 Aug 2001 15:32:22 GMT
From: "John P" <john@trumpetweb.co.uk>
Subject: test post
Message-Id: <aIRe7.2505$ms2.202170@news1.cableinet.net>

test post




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

Date: Thu, 16 Aug 2001 16:35:55 +0100
From: Philip Taylor <philip@zaynar.demon.co.uk>
Subject: Text::Wrap/ANSI proplem
Message-Id: <VMcrBEAbh+e7Ewms@zaynar.demon.co.uk>

  I've got some text which needs to be wrapped at 50 columns, and
Text::Wrap does this fine.

  However, there is a problem when the text contains ANSI codes, e.g.
"\e[31mThis line of text should appear in the colour red\e[0m".

  When displayed, the ANSI codes don't take up any space (i.e. the user
sees just "This line [...] colour red", which is 49 characters), but
Text::Wrap doesn't know this and counts the ANSI codes as displayed
characters, making it 58 characters long and wrapping it incorrectly.

  Is there an easy way to make Text::Wrap ignore the codes when
calculating the wrapping, but still include them in the printed output?

-- 
Philip Taylor
philip @ zaynar . demon . co . uk

http://robowarriors.ultrastore.com/legoworld.shtml
  -- If the Earth was made of Lego...


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

Date: Thu, 16 Aug 2001 17:36:07 GMT
From: "John P" <john@trumpetweb.co.uk>
Subject: What's the Problem locating Files?
Message-Id: <bwTe7.3432$ms2.285353@news1.cableinet.net>

Hi there All

I am distributing scripts which have the line.
use Digest::MD5 qw (md5_base64);

Most of the time the scripts are fine but on some systems the users are
getting the error message

Can't locate Digest/MD5.pm in @INC (@INC contains:
/usr/local/lib/perl5/5.6.0/i686-linux /usr/local/lib/perl5/5.6.0
/usr/local/lib/perl5/site_perl/5.6.0/i686-linux
/usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)

I thought that this was a standard module. found in a standard location.
Does anyone have any ideas please. I have asked them to check their Shebang
lines are correct but they still get the error. I have some rather irrate
customers!

Thanks in advance
John P





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

Date: 16 Aug 2001 11:27:03 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Why is there so much white space in perl documentation??
Message-Id: <m3pu9w2co8.fsf@dhcp9-161.support.tivoli.com>

On 15 Aug 2001, ilya@martynov.org wrote:

> 
>>> I'm curious why you can't just do 'perldoc -q array'?
> 
> 
> TM> I can, but it does not do the same thing that my grep(1)s do.
> 
> TM> I want to find FAQs that mention _both_ terms.
> 
> You are right. grep is more powerful.

Well, you could do 'perldoc -q "(?=.*array).*list"', but grepping the
pods directly is certainly more powerful.

-- 
Ren Maddox
ren@tivoli.com


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

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.  

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


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