[9710] in Perl-Users-Digest

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

Resend: Perl-Users Digest, Issue: 3303 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 1 20:47:19 1998

Date: Sat, 1 Aug 98 17:39:05 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 1 Aug 1998     Volume: 8 Number: 3303

Today's topics:
        Problem returning multiple hashes from a procedure (Phil Taylor)
    Re: Problem returning multiple hashes from a procedure <dgris@rand.dimensional.com>
    Re: Problem returning multiple hashes from a procedure (Josh Kortbein)
    Re: Problem returning multiple hashes from a procedure (Michael J Gebis)
    Re: Problem returning multiple hashes from a procedure (Kelly Hirano)
    Re: Problem using timelocal.pl - possible perl bug? (Kjetil Skotheim)
    Re: Problems building 5.005_01 on NT4, sp3 <jimbo@soundimages.co.uk>
        Problems making perl compiler <agy@macgreg.com>
    Re: Programmer's Editor <camerond@mail.uca.edu>
    Re: Programmer's Editor <joneil@cks.ssd.k12.wa.us>
    Re: Programmer's Editor <thomas@daimi.aau.dk>
    Re: Programmer's Editor (Andrew M. Langmead)
    Re: Programmer's Editor (Michael J Gebis)
    Re: Programmer's Editor <jdporter@min.net>
    Re: Programmer's Editor (Gabor)
    Re: Programmer's Editor <jdporter@min.net>
    Re: Programmer's Editor (Abigail)
    Re: Q: @argv with PerlW32? (Jeffrey R. Drumm)
    Re: Q: lpd / sockets / perl / HP750 plotters (Roger Brooks)
    Re: QUERY_STRING sometimes missing from GET using CGI.p <thomas@daimi.aau.dk>
    Re: QUERY_STRING sometimes missing from GET <thomas@daimi.aau.dk>
        random number <peter@richmd.demon.co.DELETE.uk>
    Re: random number <maierc@chesco.com>
    Re: random number (Michael J Gebis)
        re-using code in .pm files <m.grimshaw@music.salford.ac.uk>
    Re: re-using code in .pm files <jdporter@min.net>
        Re[3]: QUERY_STRING sometimes missing from GET using CG christopher@tokpela.com
        Rearange text <ophir@saifun.com>
        recv function <ruben@spin.ch>
        redirecting STDOUT to a file from a detached process on mmuller@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 31 Jul 1998 21:37:37 GMT
From: phil@ackltd.demon.co.uk (Phil Taylor)
Subject: Problem returning multiple hashes from a procedure
Message-Id: <35c2391b.5232799@news.demon.co.uk>

I am having problems returning multiple hashes from a procedure, see
the code sample below.

On return %team_names contains the %team_divs data and  %team_divs is
empty? Is what I am trying to do legal in Perl?

Any thoughts would be appreciated

Thanks

Phil



MAIN PROCESSING 
 ...........
(%team_names, %team_divs) = load_team_data();
 .........

END OF MAIN PROCESSING

# ----------------
sub load_team_data
# ----------------
{

my (%team_names, %team_divs, $fname, $team_name, $team_cde, $div_cde);

$fname	= $data_path . nwcsl->FN_TEAM;

open (TEAM, "< $fname") || bail("cannot open $fname: $!");
while (<TEAM>)	{
	chop();
	($team_cde, $team_name, $div_cde) = split (/:/);	
	$team_names{$team_cde} = $team_name;
	$team_divs{$team_cde} = $div_cde;	
	}
close (TEAM) || bail("cannot close $fname: $!");

return (%team_names, %team_divs);

}



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

Date: Sat, 01 Aug 1998 00:16:58 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: Problem returning multiple hashes from a procedure
Message-Id: <6ptm37$2pc$1@rand.dimensional.com>

[posted to comp.lang.perl.misc and mailed to the cited author]

In article <6ptkbc$197@Xenon.Stanford.EDU>
hirano@Xenon.Stanford.EDU (Kelly Hirano) wrote:

>well, actually, isn't it better style to pass in references to these hashes?
>even though you don't have to declare memory in perl and it does garbage
>collecting for you, it is a bad habit to return a reference to a variable
>that is going out of scope.

Hmmmm... not in perl, it isn't.  Perl's ability to hang onto variables
as long as _any_ references to them remain is a feature.  Without
it, lots of things (modules) would be much more difficult and some
things (closures) would be impossible.

>you'd be screwed if you got into the habit of returning references and you
>start programming in c.

No, only if you try to write perl code in c.

dgris
-- 
Daniel Grisinger           dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
                           Dave Clark


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

Date: 31 Jul 1998 21:59:02 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Problem returning multiple hashes from a procedure
Message-Id: <6pten6$1sm$1@news.iastate.edu>

Phil Taylor (phil@ackltd.demon.co.uk) wrote:
: I am having problems returning multiple hashes from a procedure, see
: the code sample below.

: On return %team_names contains the %team_divs data and  %team_divs is
: empty? Is what I am trying to do legal in Perl?


: return (%team_names, %team_divs);



You do understand that this will flatten out the hashes, into
one big list with no key/value distinctions, right?

To do it the right way read the perlref manpage and then return
references to hashes.




Josh

--

____________________________________________________________________
An organization that treats its programmers as morons will soon have
programmers that are willing and able to act like morons only.
				- Bjarne Stroustrup



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

Date: 31 Jul 1998 23:22:38 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Problem returning multiple hashes from a procedure
Message-Id: <6ptjju$bki@mozo.cc.purdue.edu>

phil@ackltd.demon.co.uk (Phil Taylor) writes:

}I am having problems returning multiple hashes from a procedure, see
}the code sample below.

}On return %team_names contains the %team_divs data and  %team_divs is
}empty? Is what I am trying to do legal in Perl?

}Any thoughts would be appreciated

You need to use references to do this.  The Camel, Page 117, is one
place that explains the hows and whys.


-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 31 Jul 1998 16:35:08 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
Subject: Re: Problem returning multiple hashes from a procedure
Message-Id: <6ptkbc$197@Xenon.Stanford.EDU>

In article <6pten6$1sm$1@news.iastate.edu>,
Josh Kortbein <kortbein@iastate.edu> wrote:
>Phil Taylor (phil@ackltd.demon.co.uk) wrote:
>: I am having problems returning multiple hashes from a procedure, see
>: the code sample below.
>
>: On return %team_names contains the %team_divs data and  %team_divs is
>: empty? Is what I am trying to do legal in Perl?
>
>
>: return (%team_names, %team_divs);
>
>You do understand that this will flatten out the hashes, into
>one big list with no key/value distinctions, right?
>
>To do it the right way read the perlref manpage and then return
>references to hashes.

well, actually, isn't it better style to pass in references to these hashes?
even though you don't have to declare memory in perl and it does garbage
collecting for you, it is a bad habit to return a reference to a variable
that is going out of scope.

you'd be screwed if you got into the habit of returning references and you
start programming in c.
-- 
Kelly William Hirano	                    Stanford Athletics:
hirano@cs.stanford.edu	                 http://www.gostanford.com/
hirano@alumni.stanford.org      (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20


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

Date: 31 Jul 1998 18:50:37 GMT
From: kjetil.skotheim@usit.uio.no (Kjetil Skotheim)
Subject: Re: Problem using timelocal.pl - possible perl bug?
Message-Id: <6pt3lt$4ud$2@readme.uio.no>

In article <35c2772f.592031@ispc-news.cableinet.net>, stew@webworlds.net 
says...
 .
 .
 .
>The results show that timelocal.pl returns either the same value for
>the last day of one month as for the first day of the next month
>(31st Aug, 98 & 1st Sep, 98 are the same value) or it returns a
>value for the first day of the next month 172800 seconds different
>from the last day of the previous month (i.e 2 days apart!) (this
>applies to 30th Sep, 98 & 1st Oct, 98)
>
>For example :
>==========
>
>August 31st, 98 Midnight & September 1st, 98 Midnight :
>
>&timelocal(0,0,0,31,8,98,0,0,1)   -> 907200061
>&timelocal(0,0,0,1,9,98,0,0,1)     -> 907200061
>
>September 30th, 98 Midnight & Octobe 1st, 98 Midnight :
>
>&timelocal(0,0,0,30,9,98,0,0,1)    -> 909702061
>&timelocal(0,0,0,1,10,98,0,0,1)    -> 909874861
>
>(172800 seconds difference = 2 days)
>


You seem to forget that months in timelocal and localtime
start with 0, not 1. January is 0, February is 1 and so on.

timelocal(0,0,0,31,8,98,0,0,1) will try to get September 31st,
which of course should give an error in my opinion, but it is
handled just as October 1st instead is seems.

Kjetil Skotheim, kjetilsk@usit.uio.no



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

Date: 01 Aug 1998 08:40:39 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Problems building 5.005_01 on NT4, sp3
Message-Id: <uaf5pcfpk.fsf@jimbosntserver.soundimages.co.uk>

David Coldrick <davidc@selectst.com> writes:

> However, when I do the nmake, I get down to building Internet.c and it
> falls in a heap with:

It may have failed because you didn't have all the required libraries
installed to build the Internet module. Make sure you have
wininet.dll, WinINelt.lib and wininet.h available to the compiler to
build Win32::Internet. I went through a similar problem and that was
what it was for me. Got all the requireed library files and the
problem was solved.

Additional information for this module can be found at
'http://www.divinf.it/dada/perl/', which is the authors web site for
this and several other useful Win32 modules.

HTH.

Jim Brewer



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

Date: Thu, 30 Jul 1998 10:52:56 -0400
From: "Adam Graham-Yooll" <agy@macgreg.com>
Subject: Problems making perl compiler
Message-Id: <6pq1b4$rnf$1@client2.news.psi.net>

I am having problems trying to install Malcolm Beattie's perl compiler that
came with 5.005.  Current perl -v is 5.005.

the "perl Makefile.PL" step seemed to go okay.
Can anyone tell me what I am doing wrong or where I can just get I binary
version for my platform?

Thanks,
Adam.

% uname -mrsv
SunOS 4.1.3_U1 1 sun4m

% make byteperl
t_findenv: file ENV not found in or above current directory,
 and $HOME/.toolenv not found.
Continuing anyway.
gcc   -L/usr/local/lib -target sun4 -o byteperl byteperl.c
byteperl.c:1: EXTERN.h: No such file or directory
byteperl.c:2: perl.h: No such file or directory
byteperl.c:4: patchlevel.h: No such file or directory
*** Error code 1
make: Fatal error: Command failed for target `byteperl'
warf55% make /usr/local2/bin/byteperl
t_findenv: file ENV not found in or above current directory,
 and $HOME/.toolenv not found.
Continuing anyway.
make: Fatal error: Don't know how to make target `/usr/local2/bin/byteperl'

But those files it couldn't find are there...

% find /usr/local2 -name EXTERN.h -print
/usr/local2/lib/perl5/5.005/sun4-sunos/CORE/EXTERN.h
% find /usr/local2 -name perl.h -print
/usr/local2/lib/perl5/5.005/sun4-sunos/CORE/perl.h
% find /usr/local2 -name patchlevel.h -print
/usr/local2/lib/perl5/5.005/sun4-sunos/CORE/patchlevel.h





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

Date: Thu, 30 Jul 1998 08:13:48 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
To: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Programmer's Editor
Message-Id: <35C0718C.6D278323@mail.uca.edu>

[cc'd to tc]

Tom Christiansen wrote:
> 
>  [snip]
> Several questions unrelated to your product's alleged technical wizardry:
> 
>     Is this free?
>     Is source available?
>     Does it run on Unix?
> 
> If the answers to these are no, why are you advertising here? :-(

IMHO, Questions 1 and 2 are valid, but with all due respect, this ain't
comp.lang.perl.unix, and Question 3 is irrelevant.

Cameron
camerond@mail.uca.edu


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

Date: Fri, 31 Jul 1998 16:01:55 -0700
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
To: jdporter@min.net
Subject: Re: Programmer's Editor
Message-Id: <35C24CE3.91610C26@cks.ssd.k12.wa.us>

John Porter wrote:
> 
> Gabor wrote:

> Brings up a good point.  As if there weren't already enough
> predisposition in our society toward the century error,
> the largest, most powerful software company in the galaxy
> has to go naming their products 95, 97, 98.

Just think, in three years we'll have to deal with Windows 1 all over
again!

Jerome






 .


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

Date: Sat, 01 Aug 1998 02:34:46 +0200
From: Thomas Jespersen <thomas@daimi.aau.dk>
Subject: Re: Programmer's Editor
Message-Id: <35C262A6.A06D259A@daimi.aau.dk>

Gabor wrote:

> So, what happens in 99?  We need a new modern OS?

which reminds me that microsoft's new namescheme for windows has a y2k
bug :)


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

Date: Fri, 31 Jul 1998 17:54:30 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Programmer's Editor
Message-Id: <Ewz0Eu.4sF@world.std.com>

lr@hpl.hp.com (Larry Rosler) writes:

>In article <Ewyo56.6IB@world.std.com> on Fri, 31 Jul 1998 13:29:30 GMT, 
>Andrew M. Langmead <aml@world.std.com> says...

>"...common unix tools (... C like operators, so many functions being C 
>library functions, ..."

>I was busy agreeing until you slipped from the Perl == UNIX fallacy into 
>the C == UNIX fallacy!

The Unix C library functions that Perl has borrowed is not only in the
subset of those functions found in Standard C. Looking back, I should
have said POSIX library. 


And for the C operators, since they were adopted when needed into the
rest of the Unix toolbox, I say Unix can claim them. If someone with
experience in Unix is creating an expression to pass to some sort of
tool, and wants to logically negate that expression, they'll likely
guess to use the "!" character, and they'll be right. (If its in the
context of an expression that can be negated. If not, they may guess
that it is the character to use to create a subshell.) I'm talking
about "test", "find", "tcpdump", and who knows were else.

>As has been discussed here, with the notable exception of robust IPCs, 
>Perl on Windows/DOS *does* have the rest of the Unix environment to 
>interact with (file model, shell and commands).

What good are Perl's piping constructs when there are so few tools
available for it to pipe to or from? For example, what is easier to
use if you want to make a script that munges data from a machines
performance stats "vmstat" or "System Monitor"?

>No hablo Mac.

Actually, if you take a look the Mac and Windows together, you can
come up with a compelling argument against "Perl==Unix". (I know I'm
sounding like I'm flip flopping here.) Windows has OLE for
communicating between programs. The Macintosh has AppleEvents. In a
broad view, they could be viewed as the GUI equivalent of the Unix
toolbox concept. The ports to each of these other systems have the
mechanisms to talk to other programs using the OS's idea on how
programs should talk. Perl shows its advantages as a glue language
when it can be useful even though its built-in idea of the glue
formula changes.

But unless I can say something like:

open WSHEET, 'excel filename.xls |' or die;
while(<WSHEET>) {
  @row = split /\t/;
}

Then a good chunk of perl is missing.

-- 
Andrew Langmead


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

Date: 31 Jul 1998 06:57:59 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Programmer's Editor
Message-Id: <6prptn$pbo@mozo.cc.purdue.edu>

lr@hpl.hp.com (Larry Rosler) writes:

}If you replaced the word 
}'Unix' in your statement by 'a modern OS' it would be true (and might be 
}a truism).

And I'm sure we can all agree what constitues 'a modern OS' without
the discussion turning into a religious flame war.

P.S. I think a modern OS should have "98" somewhere in its name.
P.P.S. I also like to shout "FIRE" in crowded theaters.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Fri, 31 Jul 1998 18:56:02 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Programmer's Editor
Message-Id: <35C213DC.4754@min.net>

Andrew M. Langmead wrote:
> 
> But unless I can say something like:
> 
> open WSHEET, 'excel filename.xls |' or die;
> while(<WSHEET>) {
>   @row = split /\t/;
> }
> 
> Then a good chunk of perl is missing.

Even then it's missing something.
It won't be complete until you can say:

open WSHEET, 'excel filename.xls |' or die;
while(<WSHEET>) {
  @row = @$_;
}

-- 
John Porter


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

Date: 31 Jul 1998 21:17:21 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: Programmer's Editor
Message-Id: <slrn6s4d7o.1p2.gabor@localhost.vmunix.com>

In comp.lang.perl.misc, Michael J Gebis <gebis@fee.ecn.purdue.edu> wrote :
# lr@hpl.hp.com (Larry Rosler) writes:
# 
# }If you replaced the word 
# }'Unix' in your statement by 'a modern OS' it would be true (and might be 
# }a truism).
# 
# And I'm sure we can all agree what constitues 'a modern OS' without
# the discussion turning into a religious flame war.
# 
# P.S. I think a modern OS should have "98" somewhere in its name.

So, what happens in 99?  We need a new modern OS?



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

Date: Fri, 31 Jul 1998 21:32:51 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Programmer's Editor
Message-Id: <35C2389C.4B9@min.net>

Gabor wrote:
> 
> Michael J Gebis <gebis@fee.ecn.purdue.edu> wrote :
> # P.S. I think a modern OS should have "98" somewhere in its name.
> 
> So, what happens in 99?  We need a new modern OS?

Brings up a good point.  As if there weren't already enough
predisposition in our society toward the century error,
the largest, most powerful software company in the galaxy
has to go naming their products 95, 97, 98.

Maybe it's a wry joke: 
"Yes, our products are antiquated, by about, oh, 1900 years."

-- 
John Porter


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

Date: 31 Jul 1998 22:35:35 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Programmer's Editor
Message-Id: <6ptgrn$ged$1@client3.news.psi.net>

Gabor (gabor@vmunix.com) wrote on MDCCXCV September MCMXCIII in
<URL: news:slrn6s4d7o.1p2.gabor@localhost.vmunix.com>:
++ In comp.lang.perl.misc, Michael J Gebis <gebis@fee.ecn.purdue.edu> wrote :
++ # lr@hpl.hp.com (Larry Rosler) writes:
++ # 
++ # }If you replaced the word 
++ # }'Unix' in your statement by 'a modern OS' it would be true (and might be 
++ # }a truism).
++ # 
++ # And I'm sure we can all agree what constitues 'a modern OS' without
++ # the discussion turning into a religious flame war.
++ # 
++ # P.S. I think a modern OS should have "98" somewhere in its name.
++ 
++ So, what happens in 99?  We need a new modern OS?


No. Renaming the old one will do. ;)



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-


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

Date: Fri, 31 Jul 1998 12:59:26 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Q: @argv with PerlW32?
Message-Id: <35c4bead.4632391@news.mmc.org>

[ posted to comp.lang.perl.misc and a courtesy copy was mailed to the cited
author ]

On Fri, 31 Jul 1998 11:02:25 +0200, Uwe Segelbacher <uwe.segelbacher@desy.de>
wrote:

>Hi all
>
>propably this question has been answered a lot of times, but
>unfortunately I didn't find any real documentation or faqs on PerlW32.
>
>PerlW32 seams not to read command line arguments in @argv. How do I get
>these arguments?

Well, they're not in @argv . . . they're in @ARGV.

If you're using the standard (Sarathy) distribution of Perl 5.004_02 for Win32,
you have a very serviceable perldoc facility available:

C:\> perldoc perltoc

And if you're not using the Sarathy port, you should . . .

http://www.perl.com/CPAN-local/ports/nt/Standard/x86/perl5.00402-bindist04-bc.zip


-- 
                               Jeffrey R. Drumm, Systems Integration Specialist
                       Maine Medical Center - Medical Information Systems Group
                                                            drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me


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

Date: Fri, 31 Jul 1998 22:55:43 GMT
From: rsb@liverpool.ac.uk (Roger Brooks)
Subject: Re: Q: lpd / sockets / perl / HP750 plotters
Message-Id: <EwzECv.F0o@liverpool.ac.uk>

Neal P. Murphy (murphyn@orca.cig.mot.com) wrote:
: wtm001@anadarko.com (Will Morse) writes:

: >Hi,

: >As I have previously posted, I am writing a specialized plotter
: >interface to some HP 750 plotters that have a Jet Direct card in
: >them.  The JetDirect has an lpd interface so I am trying to write 
: >to that.  I am writing the interface in perl 5.004_03.

: >I have written a "test rig" to try to copy files to the plotter
: >via the socket interface, and that program is shown below.

: >The problem I am having is that about 380 characters into the
: >third message (the "data" file) I lose the connection and the perl
: >program exitis with "Broken Pipe".  I have dummied up a file less
: >than 380 characters which seems to go through, although you can't
: >hardly get a good rtl file in less than 380 characters.


You've probably hit the "Idle Timeout" of the JetDirect card.  This
defaults to 20 seconds (AFAIR), and if the plotter stops to digest the
data for more than this time, the JetDirect clears the connection.

To set the Idle Timeout to something more sensible you need to use
BOOTP/TFTP to configure the JetDirect.  The bootptab entry specifies a
config file to be downloaded, and this contains a line to set the Idle
Timeout.  You can also specify which IP addresses the plotter will accept
connections from (otherwise anthing on the big wide internet can start
churning out plots :-)).

What should go in the config file is documented in the JetDirect manual
(or at least it used to be), also should be in the Unix JetDirect software.

With some versions of the JetDirect you may also be able to set Idle
Timeout by telneting into the card, but I've never used this method.

The Idle Timeout can be set from 0 (no timeout) to 3600 sec.  On our
DJ650C with PostScript some plots still time out at 3600...


--
Roger



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

Date: Sat, 01 Aug 1998 01:40:05 +0200
From: Thomas Jespersen <thomas@daimi.aau.dk>
Subject: Re: QUERY_STRING sometimes missing from GET using CGI.pm
Message-Id: <35C255D5.D87D47ED@daimi.aau.dk>

christopher@tokpela.com wrote:
> 
> Thanks for your response - but I am already using CGI.pm
> 
> Is there a case where the QUERY_STRING variable is not set or somehow missed?

what version are you using?

if you look at the description for v2.17 it says:

"Fixed bad bug in query_string() method that caused some parameters to
be silently dropped."

maybe that is the problem, if you are using an earlier version


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

Date: Thu, 30 Jul 1998 15:42:48 +0200
From: Thomas Jespersen <thomas@daimi.aau.dk>
Subject: Re: QUERY_STRING sometimes missing from GET
Message-Id: <35C07858.7976A1C0@daimi.aau.dk>

tokpela@my-dejanews.com wrote:
> 
> Hi,
> 
> I have an index.cgi script written in Perl (running w/Apache) that parses the
> QUERY_STRING for information and then logs this to a file.  It works *most*
> of the time (and always when I try debug it) but sometimes I get blank
> entries even though my HTTP_REFERER variables shows the QUERY_STRING present
> in the URL.
> 
> I thought that this might be a browser problem - but it seems to happen with
> newer browsers as well.
> 
> Any help is greatly appreciated!


I recommend that you go to CPAN and get CGI.pm.


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

Date: Sat, 01 Aug 1998 03:01:32 +0100
From: Peter Richmond <peter@richmd.demon.co.DELETE.uk>
Subject: random number
Message-Id: <35C276FC.C16C41BF@richmd.demon.co.DELETE.uk>

Hi,

Could sell me tell me how I could create a random number - between 1
and 1,000,000

Thanks! 
-- 
Peter Richmond.
--
Home : Fulwell, Sunderland, England
Web  : www.richmd.demon.co.uk
Pager: 01426 281 367


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

Date: Sat, 01 Aug 1998 03:03:28 GMT
From: Charles Maier <maierc@chesco.com>
Subject: Re: random number
Message-Id: <35C28627.89F5CA03@chesco.com>

Peter Richmond wrote:
> 
> Hi,
> 
> Could sell me tell me how I could create a random number - between 1
> and 1,000,000
> 
> Thanks!
> --
> Peter Richmond.
> --
> Home : Fulwell, Sunderland, England
> Web  : www.richmd.demon.co.uk
> Pager: 01426 281 367

try..

$randnum = rand(1000000)+1;


-- 
Chuck Maier
CDM Consulting Services
http://www.cdmcon.com
(610) 942-2726


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

Date: 1 Aug 1998 02:52:39 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: random number
Message-Id: <6ptvtn$f9e@mozo.cc.purdue.edu>

Peter Richmond <peter@richmd.demon.co.DELETE.uk> writes:

}Could sell me tell me how I could create a random number - between 1
}and 1,000,000

Please, read the perlfunc man page, for "rand".  www.perl.com should have
a copy if you don't have your own.

Also, I feel it's my duty to point out that you've burned a lot
of karma on quite a trivial question.  Sorry 'bout that, but the
universe has its rules.  

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Wed, 29 Jul 1998 06:49:01 +0100
From: Mark Grimshaw <m.grimshaw@music.salford.ac.uk>
Subject: re-using code in .pm files
Message-Id: <35BEB7CD.A8B2EFA6@music.salford.ac.uk>

Dear all,

Please bear in mind that I'm a relative beginner and do not use classes,
methods etc.
Please reply to my email if possible - m.grimshaw@music.salford.ac.uk

I'm trying to re-use subroutines by placing them in *.pm files.  Some of
the subroutines I call from perl scripts work fine but one is a
problem.  In the script that calls the external subroutine (and that
returns results to Netscape) I place:

BEGIN {unshift(@INC, '/music/cgi-bin/studio/modules');
}
use CGI; use POSIX; use DB_File; use My_Modules; use SB;

where 'use SB' refers to SB.pm found under the path
'/music/cgi-bin/studio/modules'

In this particular script that uses SB, there is no problem calling a SB
subroutine with:

$html = sb_adduser('manage');

so I can send a variable to that external subroutine and receive a
string back.  However if I wish to use another subroutine found in SB
by:

$html = sb_browsehtml('manage');

I simply get a blank page returned to my browser.  I've run SB.pm
locally by changing it to SB.pl to test if my sb_browsehtml subroutine
works and it does.  If I try:

$html = sb_browsehtml;
 and then print $html to the browser I get:

sb_browsehtml

printed to Netscape.

I can use (declare, define?) the sb_browsehtml subroutine directly in my
calling script and I get the results I want but I wish to re-use the
code efficiently.

Any help and advice would be most appreciated.



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

Date: Fri, 31 Jul 1998 18:30:48 GMT
From: John Porter <jdporter@min.net>
Subject: Re: re-using code in .pm files
Message-Id: <35C20DF1.4E5A@min.net>

Mark Grimshaw wrote:
> 
> BEGIN { unshift(@INC, '/music/cgi-bin/studio/modules'); }

The proper way to do that is:

	use lib ('/music/cgi-bin/studio/modules');

However, from the description of your symptoms, I'm not sure
that will help you much.

-- 
John Porter


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

Date: Fri, 31 Jul 1998 18:11:13 GMT
From: christopher@tokpela.com
Subject: Re[3]: QUERY_STRING sometimes missing from GET using CGI.pm
Message-Id: <6pt1c0$2mm$1@nnrp1.dejanews.com>

Thanks for your response - but I am already using CGI.pm

Is there a case where the QUERY_STRING variable is not set or somehow missed?


In article <35C07858.7976A1C0@daimi.aau.dk>,
  thomas@daimi.aau.dk wrote:
> tokpela@my-dejanews.com wrote:
> >
> > Hi,
> >
> > I have an index.cgi script written in Perl (running w/Apache) that parses
the
> > QUERY_STRING for information and then logs this to a file.  It works *most*
> > of the time (and always when I try debug it) but sometimes I get blank
> > entries even though my HTTP_REFERER variables shows the QUERY_STRING present
> > in the URL.
> >
> > I thought that this might be a browser problem - but it seems to happen with
> > newer browsers as well.
> >
> > Any help is greatly appreciated!
>
> I recommend that you go to CPAN and get CGI.pm.
>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 30 Jul 1998 18:15:43 +0300
From: Ophir Marko <ophir@saifun.com>
Subject: Rearange text
Message-Id: <35C08E1F.914FDE62@saifun.com>

I have a file that looks like this:

aa b ccc d
1 2 3 4


I made a script that rearanges the file to look like this:
aa === 1
b === 2
ccc === 3
d ===4


What I want to have as an output is this:

aa......1
b.......2
ccc.....3
d.......4

How do I write that kind of script?

MY current script looks like this :

#! /home1/ophir/perl5/perl
$index=0;
while(?>){
 $i=0;
 split;
 while ($i ?= $#_){
  @maaraj[$i+$index]=$_[$i];
  $i++;
 }
$index=$index+$#_+1;
}
$t=0;
$info = while ($t?=$index/2-1){
         print @maaraj[$t],"  =====  ", @maaraj[$index/2+$t], "\n";
  $t++;
 }



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

Date: Thu, 30 Jul 1998 16:20:41 +0200
From: Ruben Unteregger <ruben@spin.ch>
Subject: recv function
Message-Id: <35C08139.A3EF1265@spin.ch>

is it possible, that the recv() function restricts the
buffer to a certain length?
when i receive the data, the length 
of the buffer is max 53584.

cia0


ruben


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

Date: Fri, 31 Jul 1998 16:12:11 GMT
From: mmuller@my-dejanews.com
Subject: redirecting STDOUT to a file from a detached process on NT
Message-Id: <6psqcr$o95$1@nnrp1.dejanews.com>



I'm having trouble redirecting standard output to a file
from a detached process on Windows NT.

Here's the perl code that runs in a detached process:

    open(STDOUT, ">c:\\mmuller\\foo.txt") || explode("can't open.");
    select(STDOUT);
    $| = 1;
    print "testing.\n" || explode("can't print.");
    close(STDOUT);

    sub explode { system("say $_[0]"); exit(0); }

When I run this program from the command line, it creates
a foo.txt file with the word "testing" in it.  When it runs
as a detached process, the files gets opened (created),
but nothing gets written into the file.  The print command
does not return zero.

The following C program works just fine when it runs in a
detached process (it creates a text file and writes "testing"
into it):

    #include <stdio.h>

    int main(int argc, char* argv[])
    {
	    FILE* fp = freopen("c:\\mmuller\\foo.txt","w",stdout);

	    printf("testing.\n");

	    fflush(stdout);
    }

Here's the program that creates a detached process:

    use Win32::Process;

    $flags = NORMAL_PRIORITY_CLASS |
             CREATE_NEW_PROCESS_GROUP |
             DETACHED_PROCESS;

    if ($use_c_exe) {

        Win32::Process::Create($proc_obj,
            "c:\\mmuller\\freopen.exe",
            "c:\\mmuller\\freopen.exe",
            1,
            $flags,
            "c:\\mmuller");
    }
    else {

        Win32::Process::Create($proc_obj,
            "c:\\perl\\bin\\perl.exe c:\\mmuller\\redirect.pl",
            "c:\\perl\\bin\\perl.exe",
            1,
            $flags,
            "c:\\mmuller");
    }

Can anyone help?

I'm running Windows NT SP 3 and perl -v tells me this:

This is perl, version 5.004_02

Copyright 1987-1997, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3303
**************************************

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