[9674] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3268 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 27 17:07:22 1998

Date: Mon, 27 Jul 98 14:00:23 -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           Mon, 27 Jul 1998     Volume: 8 Number: 3268

Today's topics:
    Re: [Q] Multiplexing STDOUT to  already opened  Filehan <mishra.aditya@emeryworld.com>
        argv <mmcw@worldonline.nl>
    Re: Arrays n Patterms (Tad McClellan)
    Re: Building and sorting a list of records <sto41@wanadoo.fr>
        Calling a dll from Perl <johnc@interactive.ibm.com>
    Re: Children from a fork call do not exit. <mishra.aditya@emeryworld.com>
    Re: EOF, EOT and END_OF_TEXT error messages (Michael J Gebis)
    Re: How can I anonymous array ref from split? <jdporter@min.net>
    Re: How Do I Access my Modules? <tturton@cowboys.anet-dfw.com>
        Memory Safe Hashes (Jeffrey Horn)
        Mongers, Pumpkinholders, Porters birgitt@my-dejanews.com
    Re: OFF-TOPIC: Hosting svcs, which is best? <jdporter@min.net>
    Re: OFF-TOPIC: Hosting svcs, which is best? <thomas@daimi.aau.dk>
    Re: perl 5.004_04 - cygwin32: make problems (Nathan V. Patwardhan)
    Re: perl and setuid via WEB (apache) <jhi@alpha.hut.fi>
    Re: Perl Beautifier Home Page <lehman@javanet.com>
        REQ: tpj ray tracer ".map" files (Steve McNabb)
        Search Script? Please Help <impulse@usa.net>
    Re: Submit only Once <jdw@dev.tivoli.com>
        three perl questions for the experts (KHeise)
    Re: three perl questions for the experts <jdporter@min.net>
    Re: Variable interpolation in a hash key (Mike Stok)
    Re: Y2K problem in PERL with localtime() (Matt Knecht)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 27 Jul 1998 12:20:14 -0700
From: "Mishra Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: [Q] Multiplexing STDOUT to  already opened  Filehandle(s)
Message-Id: <6pijto$1c5i@news.cnf.com>

Thanks for replying and taking the time to read it,
I had mistakenly assumed that freopen would do the multiplexing of
filehandles for me.
What I was really looking for was a perl module/function which does the
equivalent
of the
    ioctl(filedesctomultiplex, I_LINK,multiplexedfiledesc) call.

This requires a "multiplex driver" for which I don't have any
documentation.
I know filehandle multiplexing without adding extra processes to the system
can be done(I have seen reference to it in streams manual and  man
streamio.)

I just did not know how to do it in perl.
Thanks anyway
Adi







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

Date: Mon, 27 Jul 1998 22:07:37 +0200
From: Michel Weegerink <mmcw@worldonline.nl>
Subject: argv
Message-Id: <35BCDE08.12CE04DB@worldonline.nl>


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

Hello,

Does anybody know how to use the argv argument. I know how to use the
first argv.
It works something like this:

if ($ARGV[0] eq "form") {$testing;}

you call it something like this:
http://www.testing.com/cgi-bin/test,pl?form

But how to call a second argument???

I have tryed argv[1] , but no succes!!

What am I wrong???

Please Email to mmcw@worldonline.nl

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

<HTML>

<BLOCKQUOTE TYPE=CITE>
<PRE></PRE>
</BLOCKQUOTE>
Hello,

<P>Does anybody know how to use the argv argument. I know how to use the
first argv.
<BR>It works something like this:

<P>if ($ARGV[0] eq "form") {$testing;}

<P>you call it something like this: <A HREF="http://www.testing.com/cgi-bin/test,pl?form">http://www.testing.com/cgi-bin/test,pl?form</A>

<P>But how to call a second argument???

<P>I have tryed argv[1] , but no succes!!

<P>What am I wrong???

<P>Please Email to mmcw@worldonline.nl</HTML>

--------------46943AF77A2F05DBA8A6721A--



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

Date: Mon, 27 Jul 1998 06:39:48 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Arrays n Patterms
Message-Id: <4uohp6.6i7.ln@localhost>

Mark Simonetti (se96ms@english.iielr.dmu.ac.uk) wrote:
: Is there a nicer way to do this ?

: $_ =~ /$patt/;
: @$line = ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12);

: Basically, I want all the results from the pattern match to go into the
: "line" array.


   @line = /$patt/;


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 27 Jul 1998 22:11:16 +0200
From: "Stephane Barizien" <sto41@wanadoo.fr>
Subject: Re: Building and sorting a list of records
Message-Id: <6pimva$cgr$1@platane.wanadoo.fr>

Andrew M. Langmead wrote in message ...
>"Stephane Barizien" <sto41@wanadoo.fr> writes:
>
>>I want to build a list of records in a loop, then sort that list according
>>to a given field.
>
>>push @lines, (field1 => $somevalue, field2 => $anothervalue);
>
>This pushes four elements to the array @lines. I don't think that is
>what you want.  You also never store the line itself anywhere, but you
>may not need that (you may only want the two records and recreat the
>line from there.) It seems that you either need to create parallel
>arrays for each element or a multidimentional array.

What do you mean by "parallel arrays"?


What I want to do is just the equivalent of the following shell construct:


while ...
do
    ...
    echo "$field1\t$field2\t$field3"
    ...
done | sort -1 # or 'sort -k 2,2' with POSIX-compatible sort

(which is how I current work around my Perl ignorance -- by calling the Perl
script from a Korn Shell script: 'foo.pl | sort -k 2,2')



Thanx for your detailed suggestions. I will give them a try.






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

Date: Mon, 27 Jul 1998 15:03:11 +0000
From: John Call <johnc@interactive.ibm.com>
Subject: Calling a dll from Perl
Message-Id: <35BC96AE.509E588D@interactive.ibm.com>

I am writing some code for a NT project and need to call a dll. I have
Learnng Perl on Win32 Systems and did not see a reference to this.

>From what I have seen I need the Win32::API module. Is this correct. I
looked on CPAN and could not find it and then saw a note on DejaNews
that said that Win32::API was not on CPAN. Who knows?

If anyone has done this I would like to know how you went about it.

Thanks,

John Call



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

Date: Mon, 27 Jul 1998 13:38:34 -0700
From: "Mishra Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: Children from a fork call do not exit.
Message-Id: <6piogc$k1o@news.cnf.com>

perldoc perlfaq





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

Date: 27 Jul 1998 19:42:54 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: EOF, EOT and END_OF_TEXT error messages
Message-Id: <6pil7u$8nk@mozo.cc.purdue.edu>

"Justin M. 'Bedtime for' Bonzo" <jbonzo@home.com> writes:

}I'm trying to implement a new postcard script I downloaded from the web. 
}Everything is working fine except I get the following messages.  Can anyone
}help?  

}# Can't find string terminator "EOT" anywhere before EOF.
}File 'Desktop Folder:postcards:postcard.pl'; Line 274

}# Can't find string terminator "END_OF_TEXT" anywhere before EOF.
}File 'Desktop Folder:postcards:cgi-lib.pl'; Line 91

I'll bet you dollars to donuts that you downloaded the scripts
improperly, and the end-of-line symbol is hosed.

Check the FAQ on this one, it's mentioned.

If you want to try to fix it, take a look at this:
-----------------------------------------------------------------------------
print <<FOO;

This is one of those films where the people are so stupid that you
start rooting for aliens to blow up the world, and there aren't even
aliens in the movie. 

FOO[*]
-----------------------------------------------------------------------------

Ok, you see the asterik?  That represents some funky (maybe even
invisible) character that's not supposed to be there.  This means perl
never sees "FOO", it sees "FOO[funkychar]" and thus you get the
warning above.  So pop up a good editor and fix it.


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


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

Date: Mon, 27 Jul 1998 19:29:17 GMT
From: John Porter <jdporter@min.net>
Subject: Re: How can I anonymous array ref from split?
Message-Id: <35BCD686.1189@min.net>

Joe Davison wrote:
> 
> What I want, almost:
> 
> my($pstring, %daPerms);
> 
> while(<>) {
>         chomp();
>         $pstring=$_;  # For instance, $pstring="13254";
>         @aPerm = split "", $pstring;
>         $daPerms{$pstring} = \@aPerm;
> }
> 
> I want to build a hashtable with values that are references to arrays of
> small integers (permutations), and keys that are the external
> representations.
> 
> What I wrote doesn't work, because all the values are references to the
> single array @aPerm, which gets overwritten each new line.

This is exactly why temp vars inside a loop should be declared as
lexical to the loop, using 'my'.  Like this:

    while(<>) {
        chomp();
        my $pstring = $_;
        my @aPerm = split "", $pstring;
        $daPerms{$pstring} = \@aPerm;
    }

It doesn't matter for $pstring in this case, but Do The Right Thing.

As it happens, you don't need $pstring; you can just use $_:

    while(<>) {
        chomp;
        my @aPerm = split '';
        $daPerms{$_} = \@aPerm;
    }

You can further simply by using the [] constructor for anonymous
array:

    while(<>) {
        chomp;
        $daPerms{$_} = [ split '' ];
    }

Now you're real close to defining the hash in one statement.
To do it, use map:

    my %daPerms = map { chomp; $_ => [ split '' ] } <>;

You might not want to do this if the input file is very
large, because this method reads the entire file into
memory, unlike the while loop.

-- 
John Porter


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

Date: Mon, 27 Jul 1998 15:20:52 -0500
From: Tom Turton <tturton@cowboys.anet-dfw.com>
To: Ralph Jaeger <jaeger@deepfx.com>
Subject: Re: How Do I Access my Modules?
Message-Id: <35BCE124.E5D504C5@cowboys.anet-dfw.com>



Ralph Jaeger wrote:

> Hi,
>
> you can either extend the @inc or you can use
>
> use lib 'mydirectorywheremyperllibsarein';

Still getting same behavior.
Added:

push (@INC,"/home/tturton/PERL/MyPerlLib");
use MyPerlLib::Airline;

When running from /home/tturton/PERL,  what_airline.pl (located in
/home/tturton/PERL) works fine, but when I run what_airline.pl from any other
directory, it "Can't locate MyPerlLib/Airline.pm in @INC"

Any additional clues?

Thanks,
---Tom



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

Date: 27 Jul 1998 19:44:36 GMT
From: horn@beaner.cs.wisc.edu (Jeffrey Horn)
Subject: Memory Safe Hashes
Message-Id: <6pilb4$7le@spool.cs.wisc.edu>

I am writing a script that can potentially process ver large numbers of
records through a hash.  On a given machine, when the number of records
in the hash is too large, Perl dies with an "out of memory" error.

I've tried things like reducing key size and that helps some, but still
I can get the problem to occur.  I can tie the hash to a DBM file or Btree
file, and that allows things to run, but much more slowly!

What I am looking for is a structure which can keep a large  window of
data in a "in memory" data structure, but will keep data not in that
window on disk... sort of a pageable DBM file.

Barring that, is there any way I can detect an out of memory state before
it crashes my program?

-- Jeff Horn

-- 
Jeffrey Horn (horn@cs.wisc.edu)        |BELZER,BERNHARDT,BOETTCHER,DRAVIS,FETTER
PHONE:(608) 846-1932                   |GAPINSKI,GAUGER,HARMS,HIRSCHINGER,HORNE
FAX:  (608) 846-1934                   |JUECH,KLAJBOR,KROIS,KRONING,LEMKE,RUNGE
http://www.cs.wisc.edu/~horn/horn.html |STOCK,TAUBERT,TRESKE,WILLMERT,ZILLMER


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

Date: Mon, 27 Jul 1998 20:09:43 GMT
From: birgitt@my-dejanews.com
Subject: Mongers, Pumpkinholders, Porters
Message-Id: <6pimq7$c9k$1@nnrp1.dejanews.com>

I am just wondering where these names came from, if they are used
only in the Perl community and what and who the Perl Mongers,
Pumkinholders and Porters really are.

Birgitt Funk

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


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

Date: Mon, 27 Jul 1998 20:44:12 GMT
From: John Porter <jdporter@min.net>
Subject: Re: OFF-TOPIC: Hosting svcs, which is best?
Message-Id: <35BCE813.2DD4@min.net>

Soren Andersen wrote:
> 
> Sorry in advance to all those who may think that
> this is a misuse of the group or of the news server bandwidth.

Sorry don't cut it.

> i think that the question is relevant 

You think wrongly.  And your anarchist attitude stinks.

-- 
John Porter


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

Date: Mon, 27 Jul 1998 22:57:47 +0200
From: Thomas Jespersen <thomas@daimi.aau.dk>
Subject: Re: OFF-TOPIC: Hosting svcs, which is best?
Message-Id: <35BCE9CB.825FA405@daimi.aau.dk>

Soren Andersen wrote:

>   I would like to solicit from readers some recommendations for Web site
> hosting providers (NOT necessarily Dial-up ISPs) with whom readers feel

try:

http://www.webhostlist.com/


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

Date: 27 Jul 1998 20:43:16 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: perl 5.004_04 - cygwin32: make problems
Message-Id: <6piop4$7t0@fridge.shore.net>

Reini Urban (rurban@sbox.tu-graz.ac.at) wrote:

: I followed "README.cygwin32" and it compiles until

Are you using Sergei's coolview?  If you'd be interested in native
(win32) sockets support, I'd also suggest perusing the Cygwin GCC FAQ
about using -lwsock32.

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


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

Date: 27 Jul 1998 22:46:58 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: perl and setuid via WEB (apache)
Message-Id: <oeeg1fnnkjx.fsf@alpha.hut.fi>


Bernd Zimmermann <berni@ping-net.de> writes:

> 
> Hi !
> 
> I have perl 5.004_04, Apache 1_3_0 and want to execute a script
> with suid root..

No, you don't.  You really don't.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Mon, 27 Jul 1998 20:41:38 GMT
From: Todd Lehman <lehman@javanet.com>
Subject: Re: Perl Beautifier Home Page
Message-Id: <35BCF5F0.98460AE2@javanet.com>

> http://www.consultix.wa.com/yumpy/cgi-pvt/pbeaut.cgi.

Ack!  God help us if this isn't a late April Fools joke!  :-)

Here is the first code snippets I fed it...

--Todd L.

______________________________________________________________________________

ORIGINAL PROGRAM

%entities =
(
   "quot"  =>"\042",  "amp"   =>"\046",  "lt"    =>"\074",  "gt"    =>"\076",
   "nbsp"  =>"\240",  "iexcl" =>"\241",  "cent"  =>"\242",  "pound" =>"\243",
   "curren"=>"\244",  "yen"   =>"\245",  "brvbar"=>"\246",  "sect"  =>"\247",
   "uml"   =>"\250",  "copy"  =>"\251",  "ordf"  =>"\252",  "laquo" =>"\253",
   "not"   =>"\254",  "shy"   =>"\255",  "reg"   =>"\256",  "macr"  =>"\257",
   "deg"   =>"\260",  "plusmn"=>"\261",  "sup2"  =>"\262",  "sup3"  =>"\263",
   "acute" =>"\264",  "micro" =>"\265",  "para"  =>"\266",  "middot"=>"\267",
   "cedil" =>"\270",  "sup1"  =>"\271",  "ordm"  =>"\272",  "raquo" =>"\273",
   "frac14"=>"\274",  "frac12"=>"\275",  "frac34"=>"\276",  "iquest"=>"\277",
   "Agrave"=>"\300",  "Aacute"=>"\301",  "Acirc" =>"\302",  "Atilde"=>"\303",
   "Auml"  =>"\304",  "Aring" =>"\305",  "AElig" =>"\306",  "Ccedil"=>"\307",
   "Egrave"=>"\310",  "Eacute"=>"\311",  "Ecirc" =>"\312",  "Euml"  =>"\313",
   "Igrave"=>"\314",  "Iacute"=>"\315",  "Icirc" =>"\316",  "Iuml"  =>"\317",
   "ETH"   =>"\320",  "Ntilde"=>"\321",  "Ograve"=>"\322",  "Oacute"=>"\323",
   "Ocirc" =>"\324",  "Otilde"=>"\325",  "Ouml"  =>"\326",  "times" =>"\327",
   "Oslash"=>"\330",  "Ugrave"=>"\331",  "Uacute"=>"\332",  "Ucirc" =>"\333",
   "Uuml"  =>"\334",  "Yacute"=>"\335",  "THORN" =>"\336",  "szlig" =>"\337",
   "agrave"=>"\340",  "aacute"=>"\341",  "acirc" =>"\342",  "atilde"=>"\343",
   "auml"  =>"\344",  "aring" =>"\345",  "aelig" =>"\346",  "ccedil"=>"\347",
   "egrave"=>"\350",  "eacute"=>"\351",  "ecirc" =>"\352",  "euml"  =>"\353",
   "igrave"=>"\354",  "iacute"=>"\355",  "icirc" =>"\356",  "iuml"  =>"\357",
   "eth"   =>"\360",  "ntilde"=>"\361",  "ograve"=>"\362",  "oacute"=>"\363",
   "ocirc" =>"\364",  "otilde"=>"\365",  "ouml"  =>"\366",  "divide"=>"\367",
   "oslash"=>"\370",  "ugrave"=>"\371",  "uacute"=>"\372",  "ucirc" =>"\373",
   "uuml"  =>"\374",  "yacute"=>"\375",  "thorn" =>"\376",  "yuml"  =>"\377"
);


BEAUTIFIED PROGRAM

%entities =
(
    "quot" => "\042", "amp" => "\046", "lt" => "\074", "gt" => "\076",
    "nbsp" => "\240", "iexcl" => "\241", "cent" => "\242", "pound" => "\243",
    "curren" => "\244", "yen" => "\245", "brvbar" => "\246", "sect" => "\247",
    "uml" => "\250", "copy" => "\251", "ordf" => "\252", "laquo" => "\253",
    "not" => "\254", "shy" => "\255", "reg" => "\256", "macr" => "\257",
    "deg" => "\260", "plusmn" => "\261", "sup2" => "\262", "sup3" => "\263",
    "acute" => "\264", "micro" => "\265", "para" => "\266", "middot" => "\267",
    "cedil" => "\270", "sup1" => "\271", "ordm" => "\272", "raquo" => "\273",
    "frac14" => "\274", "frac12" => "\275", "frac34" => "\276", "iquest" =>
"\277",
    "Agrave" => "\300", "Aacute" => "\301", "Acirc" => "\302", "Atilde" =>
"\303",
    "Auml" => "\304", "Aring" => "\305", "AElig" => "\306", "Ccedil" => "\307",
    "Egrave" => "\310", "Eacute" => "\311", "Ecirc" => "\312", "Euml" => "\313",
    "Igrave" => "\314", "Iacute" => "\315", "Icirc" => "\316", "Iuml" => "\317",
    "ETH" => "\320", "Ntilde" => "\321", "Ograve" => "\322", "Oacute" => "\323",
    "Ocirc" => "\324", "Otilde" => "\325", "Ouml" => "\326", "times" => "\327",
    "Oslash" => "\330", "Ugrave" => "\331", "Uacute" => "\332", "Ucirc" =>
"\333",
    "Uuml" => "\334", "Yacute" => "\335", "THORN" => "\336", "szlig" => "\337",
    "agrave" => "\340", "aacute" => "\341", "acirc" => "\342", "atilde" =>
"\343",
    "auml" => "\344", "aring" => "\345", "aelig" => "\346", "ccedil" => "\347",
    "egrave" => "\350", "eacute" => "\351", "ecirc" => "\352", "euml" => "\353",
    "igrave" => "\354", "iacute" => "\355", "icirc" => "\356", "iuml" => "\357",
    "eth" => "\360", "ntilde" => "\361", "ograve" => "\362", "oacute" => "\363",
    "ocirc" => "\364", "otilde" => "\365", "ouml" => "\366", "divide" => "\367",
    "oslash" => "\370", "ugrave" => "\371", "uacute" => "\372", "ucirc" =>
"\373",
    "uuml" => "\374", "yacute" => "\375", "thorn" => "\376", "yuml" => "\377"
);


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

Date: 27 Jul 1998 20:51:07 GMT
From: smcnabb@interlog.com (Steve McNabb)
Subject: REQ: tpj ray tracer ".map" files
Message-Id: <6pip7r$cut$1@goblin.uunet.ca>

Hi:

can someone please email me the .map files from the current issue of the perl 
journal?  I'm itching to try it, but my (clueless) browser seems to think they 
are image map files, and all I can get it to "save link as" is an irritating 
error message -- no matter how much I swear at it. :)

Many thanks in advance.

Steve
smcnabb@interlog.com

p.s. :  MJD :  if you happen to see this, that was one of the best, easist
to understand discussions on ray-tracing I've read thusfar -- great article!

p.p.s. : if you don't read tpj (the perl journal), you should.




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

Date: Mon, 27 Jul 1998 14:53:06 -0600
From: Daniel Newman <impulse@usa.net>
Subject: Search Script? Please Help
Message-Id: <35BCE8B2.80A2732D@usa.net>

I've got a quick question, how could i do the following?

i want a big text file that has different seperated "paragraphs" each
with its own "keywords".  After
          a user inputs some sentences i want a script to find the
keywords and then output a HTML page with
          the paragraphs from the text file that apply.
          For example:
          a user types in:

          "I want to go to a medium sized college. I want to major in
computer science. I have  a 4.0
          GPA and I got  a 1480 on my SATs."

          the HTML page would display the 4 paragraphs titled(the full
paragraphs, not links to them):

          MEDIUM SIZED COLLEGES
          COMPUTER SCIENCE
          GPA INFORMATION
          SAT SCORE INFORMATION

Thank you very much!

-Daniel Newman
impulse@usa.net



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

Date: 27 Jul 1998 13:07:18 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: Submit only Once
Message-Id: <obd8ar6ucp.fsf@alder.dev.tivoli.com>

"Sam Irion" <persoft@concentric.net> writes:

> Can anyone give me any advice or direction on how to prevent the user from
> using the browser's back button to go back to a form and repost it?

You can't stop them from going back and reposting, but just because
it's reposted, doesn't mean you have to accept it... :)

You could generate a random number, store it in a hidden field (which
would need to be recalculated on a form reset), then store that
hidden/random number in a database when they submit a *good* form.

The first thing you'd check on a form is whether or not the hidden
field matches anything in the database, if it does, you send them a
message saying the need to hit "reset" if they want to submit a new
form.

You might also want to save the random number initially, so the user
can't modify the form and put in his/her own random numbers, but that
seems a bit excessive

This of course assumes that the actual form is also a cgi-script, but
even if it's currently static, it's trivial to make a static form a
cgi-form...

-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@tivoli.com


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

Date: 27 Jul 1998 19:02:52 GMT
From: kheise@aol.com (KHeise)
Subject: three perl questions for the experts
Message-Id: <1998072719025200.PAA28162@ladder03.news.aol.com>

i am a perl novice who has read a couple of books on the subject, but couldnt
seem to find the answers to any of these questions.

1) how can i direct output to a printer (for a printed report) using perl? i
suspect it has to do with redirecting STDIO, but i have not been able to find
any info on how to accomplish this.

2) i use perl to do file processing on large fixed length customer lists.
recently found out how to read each record in the list as binary data. so
here's what i am doing:  a) reading x number of bytes of binary data into
memory (x=record length)  b) performing some sort of processing on this chunk
of data  c) writing the chunk to hard disk into another file. i perform these
kinds of tasks daily as a dierect mail programmer, and perl does a fine job for
most files i receive, but i noticed something perl is doing to some of my data
which is unacceptable for my purposes:  when a line-feed character (hex 0A)
falls in the middle of one of my records a carriage-return character (hex 0D)
is inserted before the line-feed, thus adding a charcter to my record. i cannot
have this happen, because the work that i do requres that the file MUST be a
fixed number of characters. does anyone know how i can avoid this? is it in a
module that can be edited?

3) lastly, if there is an end of file marker (hex 1A) in a file i am
processing, it stops my program dead in its tracks. is this the same sort of
problem as question 2? is there any way to get around this?

i hope these questions can be answered, and truly appreciate ANY input (ex.
"Read page $pageNumber in $bookName, rookie.).

thanks,

jay o'neill

kheise@pgicompanies.com



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

Date: Mon, 27 Jul 1998 20:46:51 GMT
From: John Porter <jdporter@min.net>
Subject: Re: three perl questions for the experts
Message-Id: <35BCE8B2.10FF@min.net>

KHeise wrote:
> 
> kinds of tasks daily as a dierect mail programmer, and perl does a fine job for

I'd love to answer these questions, but I don't help spammers.  Too bad.

-- 
John Porter


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

Date: 27 Jul 1998 20:38:05 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Variable interpolation in a hash key
Message-Id: <6piofd$2pb@news-central.tiac.net>

In article <6pi9nk$rf9$1@msunews.cl.msu.edu>,
Dan Nguyen  <nguyend7@egr.msu.edu> wrote:

>Your problem is with $query_hash{"c",$x,"black"}.  You probably mean
>$query_hash{"c".$x."black"}.  Hashes are only stored by one key.

Using commas in the subscript of a hash is perfectly reasonable, it was
the way perls before perl 5 emulated multidimensional array indexing -
the effect is to join the indices with a character that's unlikely to be
in the indices, $;

  DB<1> $x = 'banana' 

  DB<2> $query_hash{"c", $x, "black"} = 1

  DB<3> X query_hash
%query_hash = (
   "c\c\banana\c\black" => 1
)

$; is documented in the perlvar page.

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Mon, 27 Jul 1998 19:39:15 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <DH4v1.7$NJ5.182329@news2.voicenet.com>

John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>I fail to see how using a function that fails on a format overflow (that
>does not yet exist) could kill existing code.

I'll give you an example that I depend on in *many* of my own programs.
I have the need to print out a certain amount of log data from my
programs.  There are times when a certain portion of the data may range
from (For example) 5 characters to 30 characters.  If I want my data
easy to glance over, I'll try and line up similar fields.  I also want
to stay as close to 80 columns as possible.  So, I look at my data, and
figure out my expected output.  I see that a 30 character field only
comes up, say, 1% of the time.  I'll often use a printf that has 
precision set *lower* than my know max output.  I don't mind 1% of the
lines not formatting correctly.  I do mind 99% of the file filled with
pointless spaces, and a file that looks like it's gone through a blender
because nothing lines up.

>>: If I use a format of "%2d", I am asking for two characters to be
>>: returned. I am not asking for at least two digits. If I were, then the
>>: system would have failed to comply when it returns " 1" for the number
>>: 1.
>>
>>Wrong.  
>
>Which part of my statement is wrong? "%2d" is asking for two characters.
>It is NOT asking for two digits. And if "%2d" really were asking for two
>digits, then the system has failed when it returns " 1", since " " is
>not a digit.

I think you're missing the point.  %2d is not asking for two digits, nor
2 characters.  It's asking for an arbitrarily long integer *in* *a*
*minimum* **field** *width* *of* *two*.

But why take my word for it?  Why not look at the documentation?

$ perldoc -f sprintf
[snip]
   number  minimum field width
  .number "precision": digits after decimal point for floating-point,
          max length for string, minimum length for integer
[snip]

The docs don't mention anything about requesting a certain number of
characters or digits (Excepting floating point and string, which is not
the argument).  The only specification is for *minimum* field width.

>>The '2' is a minimum field width specifier, not a minimum digit
>>count specifier.
>
>I'm not the one who said it was a minimum digit count. In fact, I think
>I proved that it wasn't.

Digits, characters... it doesn't matter.  It applies to neither.

>I would think a module to either replace the core of printf or create a
>error-handling printf under a new name would be better.

printf is reasonably complex already, and you want to add a new level of
complexity with what you're asking.

printf('%d', $x); # Simple enough

printf('%6d', $x); # Minimum width!

printf('%-6d', $x); # Aligned left

printf('%+-6d', $x); # Make sure positive numbers come out with a '+'
                     # appended.  This is starting to get ugly!

# What happens if we want arbitrary trimming?
# Hopefully we can find an unused character for this...

printf('%~+-6d', $x); # Perhaps a ~ means trim left of the argument

printf('%=+-6d', $x); # Perhaps an = means trim right of the argument


I have one thing to say about that.  Yuck!  If I ever needed that sort
of trimming, I certainly wouldn't ask it of printf.  Better to use
substr and tell it exactly what to print out (And, at that point, I
could use print.).

-- 
Matt Knecht - <hex@voicenet.com>


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

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

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