[10817] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4418 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 14 10:24:38 1998

Date: Mon, 14 Dec 98 07:16:18 -0800
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, 14 Dec 1998     Volume: 8 Number: 4418

Today's topics:
        ActivePerl507 install problem <tgray@smlny.com>
        Bug (array ref in a "void" context) (Bart Lateur)
    Re: Bug (array ref in a "void" context) (Bart Lateur)
    Re: Calling API's <ebohlman@netcom.com>
    Re: CGI.pm vs. old way I'm used to? (I R A Aggie)
    Re: clearing the screen in perl? <jules@crisp.nl>
        convert C-filedescriptot into filehandle? <schweika@isa.de>
        convert file contents to uppercse <chris@nospam.com>
    Re: convert file contents to uppercse <Tony.Curtis+usenet@vcpc.univie.ac.at>
        disable ^C ??? <swampmidget@hotmail.com>
    Re: disable ^C ??? (I R A Aggie)
        disable ^C ????? <swampmidget@hotmail.com>
    Re: Flock (semi-long) (John Klassa)
        flock for append (was: Re: getting http-referer) (Larry Rosler)
        Get an Html page from another server <dd@internet-consultants.com>
    Re: Get an Html page from another server (I R A Aggie)
    Re: how can I get this hash references? dave@mag-sol.com
    Re: how can script get file http://... <e.christensen@nertjob.dk>
    Re: How do I allow File-uploading into database (Bradley K. Farrell)
    Re: localtime () - perl's  bug ? (r j huntington)
        Net::POP3 2 (La vendetta) <lscom@tin.it>
    Re: Perl and FTP - without modules <merlyn@stonehenge.com>
        perl movie yves.tremolet@par.sita.int
    Re: Perl, ORacle & Linux <Marcin.Kasperski@softax.com.pl>
        preserving case insensitive after splitting a string (Jason Q.)
    Re: Programming Prob <ebohlman@netcom.com>
        renaming an array with a number at the end (Jason Q.)
    Re: renaming an array with a number at the end <stuart@dune-concept.com>
    Re: renaming an array with a number at the end <ebohlman@netcom.com>
    Re: renaming an array with a number at the end (Philipp)
        script documentation <stuart@dune-concept.com>
    Re: script documentation <ebohlman@netcom.com>
        sorting hashes cnsxxx@my-dejanews.com
    Re: sorting hashes <Allan@due.net>
    Re: sorting hashes (Larry Rosler)
        Writing in a file ... <yoann.lecorvic@inrfasoft-civil.com>
    Re: Writing in a file ... <stuart@dune-concept.com>
    Re: Writing Perl with Notepad dturley@pobox.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 14 Dec 1998 08:57:49 -0500
From: "Tim Gray" <tgray@smlny.com>
Subject: ActivePerl507 install problem
Message-Id: <ZL8d2.7070$5V.7558922@newse1.twcny.rr.com>

I downloaded the latest from activestate.com APi507e.exe.  When I run the
install it gets to 80% and then it dies with the message "failed to create
PerlEz object in ConfigureComponents()"   Any ideas?  Thanks.

Tim Gray




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

Date: Mon, 14 Dec 1998 11:35:25 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Bug (array ref in a "void" context)
Message-Id: <3676f786.14836231@news.skynet.be>

  #! perl -w
  $aryref ||= $updated++,[1,2,3];
  ($\,$,) = ("\n","/");
  print $aryref,$updated;

Result:

> Useless use of scalar ref constructor in void context at voidref.t line 2.
> 0/1

Note that $ayref does get set to a proper array reference if you drop
the "$updated++," part.

p.s. Is there a "perlbug" online? I can't run it on my system. Besides,
Perl doesn't have access to my e-mail system. I can always copy anything
perl -v returns, if necessary.

	Bart.


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

Date: Mon, 14 Dec 1998 13:48:50 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Bug (array ref in a "void" context)
Message-Id: <36761668.22705171@news.skynet.be>

Bart Lateur wrote:

>  $aryref ||= $updated++,[1,2,3];

>> Useless use of scalar ref constructor in void context at voidref.t line 2.

Argh! It turns out that the comma operator has a lower precedence than
the assignment. What a strange world.

	Bart.


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

Date: Mon, 14 Dec 1998 09:59:27 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Calling API's
Message-Id: <ebohlmanF3y934.DLD@netcom.com>

Gernot Homma <gernot@cat.at> wrote:
: HI there
: please don't kill me but i have some platform-specific question.

: 1. is there a possibility to start a perl-program as a service in WinNT

I believe there is, but you'll have to do a DejaNews search on this group 
to find out, as it's not something I've gotten involved with.

: 2. Is it possible to access api's or procedures in DLL's  in Perl on the
: WinNT-Platform.

Yes, using Aldo Calpini's Win32::API module.



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

Date: Mon, 14 Dec 1998 09:51:11 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: CGI.pm vs. old way I'm used to?
Message-Id: <fl_aggie-1412980951110001@aggie.coaps.fsu.edu>

In article <751o2n$8p4@slip.net>, emclean@slip.net (Emmett McLean) wrote:

+  If you know what your environmental variables are you  can
+  run your cgi's from the command line anyway by assigning
+  the environmental variables at the top of your script.

Even in a POST form?

+  If that is the major feature it's not a big deal. The old way
+  appears much faster.

Its a damn teaser to get someone to look at the damn docs. Perhaps you
should contemplate doing that before passing final judgement.

James


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

Date: Mon, 14 Dec 1998 11:34:46 +0100
From: jules <jules@crisp.nl>
Subject: Re: clearing the screen in perl?
Message-Id: <3674E9C6.37C8D83A@crisp.nl>



Jim Matzdorff wrote:

>
> Is there a way to clear the screen in perl?  Such as "clear" in a shell?  I
> can't backtick it and run clear, since that clears the shell's screen, not the current
> screen.  Am I (and I know I am) missing something simple here?
>
> --jim

The following worked for me:

system("clear");

clear?

Z.




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

Date: Mon, 14 Dec 1998 14:03:51 +0100
From: "Andreas Schweikardt" <schweika@isa.de>
Subject: convert C-filedescriptot into filehandle?
Message-Id: <753206$ae8$1@newton.isa.de>

Hi,

I have a problem:

I start a perl script (via fork/exec) from a C program.
The perl program has to inform the parent about
its progress.
I thought about pipes. I open the pipe before the fork().
But how will I access to the pipe?
I tried to give the filedescriptor as an argument to the
perl script. I have no idea to write a filedescriptor.
With fileno() I'll get the filedescriptor of filehandle, but
I can't figure out the other way.

Any idea? Or better solutions than pipes?

Thanks
    Andreas







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

Date: Mon, 14 Dec 1998 13:18:38 -0000
From: "Chris" <chris@nospam.com>
Subject: convert file contents to uppercse
Message-Id: <75337j$1nl$1@newsreader2.core.theplanet.net>

Request for a bit of code that converts a files contents to uppercase

cheers





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

Date: 14 Dec 1998 14:23:36 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: convert file contents to uppercse
Message-Id: <83r9u23lif.fsf@vcpc.univie.ac.at>

Re: convert file contents to uppercse, Chris
<chris@nospam.com> said:

Chris> Request for a bit of code that converts a
Chris> files contents to uppercase cheers

print uc <FH> while () { } close die

rearrange into a well-known phrase or saying :-)

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Mon, 14 Dec 1998 09:35:20 -0500
From: Mark Draper <swampmidget@hotmail.com>
Subject: disable ^C ???
Message-Id: <36752228.5B51@hotmail.com>

How can I disable the control C from terminating a script?
Thanx in advance,
              mark


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

Date: Mon, 14 Dec 1998 09:47:14 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: disable ^C ???
Message-Id: <fl_aggie-1412980947140001@aggie.coaps.fsu.edu>

In article <36752228.5B51@hotmail.com>, swampmidget@hotmail.com wrote:

+ How can I disable the control C from terminating a script?

perldoc sigtrap contains this information.

James


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

Date: Mon, 14 Dec 1998 09:37:44 -0500
From: Mark Draper <swampmidget@hotmail.com>
Subject: disable ^C ?????
Message-Id: <367522B8.5B06@hotmail.com>

How can i disable control C user input so they can not terminate the
script?

Thanx in advance,
             mark


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

Date: 14 Dec 1998 14:32:27 GMT
From: klassa@aur.alcatel.com (John Klassa)
Subject: Re: Flock (semi-long)
Message-Id: <7537hr$a9m$1@aurwww.aur.alcatel.com>

On Sun, 13 Dec 1998 16:22:31 GMT, Randal Schwartz <merlyn@stonehenge.com> wrote:
  > In general, it's a good idea to seek() after a flock() (even if it's
  > seek(HANDLE,0,1)) to ensure that your buffer looks like the current
  > file.  In this case, we're ensuring that we're at the end of the file
  > even after we might have been waiting for a while, so yes, it's a good
  > idea.
  >
  > Some systems enforce that type of seek before every write if you open
  > in append mode (like ">>file"), but you still don't get the automatic
  > buffer resynchronization, which could trip you up if you're doing
  > normal print()s.

I've been running into a problem that's related to this...  In trying to
make sure that flock will work in my environment, I wrote a couple of
test scripts.  One runs from the command line, the other as a CGI script.
Both lock a file, write to it, sleep for a bit and then close the file.
Interestingly, despite doing a seek, the output isn't nicely segregated
like it ought to be...  One process tends to start writing over the output
of the other.

I get things like this as the two scripts duke it out (where "process1"
represents the output of the first process, for example):

	% cat testfile
	process1

followed by

	% cat testfile
	process1
	process2

followed by

	% cat testfile
	process1
	process1

(Note that the second line, which was "process2", is now "process1".)

My code appears below.  Am I hosing some part of the sequence or is there a
glitch in the way my OS is handling things?  It's also important to note,
I think, that if I run two copies of the command-line version (as me), the
output is as expected.  The glitch only occurs when I run one copy from the
command line (as me) and the other from the web server (as "nobody").

(FWIW, the file has its permissions set to 666...)

	% perl -v
	This is perl, version 5.004_04 built for sun4-solaris

	% uname -a
	SunOS aursgh 5.5.1 Generic_103640-18 sun4u sparc SUNW,Ultra-2

The command-line version (vertical whitespace removed):

	#!/homes/klassa/.x/perl -w
	 
	use strict;
	use vars qw( $oldfh );
	 
	$| = 1;
	 
	require 'ctime.pl';
	 
	my $idx = 0;
	 
	while ($idx++ < 100000)
	{
	    print "$$: opening ", ctime(time);
	    open OUP, '+</homes/klassa/testfile' or die "open: $!\n";
	    local $oldfh = select(OUP); $| = 1; select($oldfh);
	    print "$$: locking ", ctime(time);
	    flock OUP, 2;
	    print "$$: seek ", ctime(time);
	    seek OUP, 0, 2;
	    print "$$: printing ", ctime(time);
	    print OUP $$, " ", ctime(time);
	    print "$$: sleeping ", ctime(time);
	    sleep 5;
	    print "$$: closing (unlocking) ", ctime(time);
	    close OUP;
	}

The CGI version is identical except that I've got:

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

at the top.

-- 
John Klassa / Alcatel / Raleigh, NC, USA / $perl_monger{Raleigh}[0] / <><


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

Date: Mon, 14 Dec 1998 06:02:26 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: flock for append (was: Re: getting http-referer)
Message-Id: <MPG.10deba484b99368989959@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <8c1zm3qug1.fsf@gadget.cscaper.com> on Mon, 14 Dec 1998 
03:22:21 GMT, "RS" == Randal Schwartz <merlyn@stonehenge.com> says...
> >>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:
> 
> John> AFAIK, locking is *not* needed when you *append*
> John> to a file (single line), it's an atomic operation.
> 
> RS>> Only if you use sysopen and syswrite.  Which you didn't.
> 
> Larry> I think that using $|++ to force line-flushing for 'print'
> Larry> would work as well, provided each line is small enough for a
> Larry> single write(2), which is extremely likely.
> 
RS> *unless* the small line (no matter how small) crosses a BUFSIZ (8K?)
RS> boundary, in which case you'll most likely get two write(2)'s
RS> instead of one.  Bad news.

Please pardon my continued failure to understand this situation, and 
help correct my mental model.

Without looking into the perl sources, I assume that 'print "foobar\n"' 
might be implemented as a call to fwrite(3S).  'fwrite' copies its data 
string into a STDIO buffer and then, because the string has a "\n" and 
$| is set, calls fflush(3S), which calls write(2) -- which does the 
actual output after seeking to EOF because the file was opened with 
'append'.  'fflush' then resets the buffer pointer to the beginning of 
the buffer.

If that model is correct, then the buffer can never contain more than 
one line of output, so it cannot cross a BUFSIZ booundary, and write(2) 
gets called once only per line of output.

RS> Again, either use flocking, or bypass STDIO, which is almost
RS> certainly gonna ruin your day.

I still don't see why either of these choices is necessary.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 14 Dec 1998 15:34:46 +0100
From: Daniel Droetto <dd@internet-consultants.com>
Subject: Get an Html page from another server
Message-Id: <36752206.94E9383F@internet-consultants.com>

Hi
My question seems very simple.
I want to get an html page from the web (store on a server different
from which I run my script), and put it on a $variable.

Any idea.
Thanks from a beginner.

Please answer directly to my email : droetto@intershop.fr



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

Date: Mon, 14 Dec 1998 09:47:56 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Get an Html page from another server
Message-Id: <fl_aggie-1412980947560001@aggie.coaps.fsu.edu>

In article <36752206.94E9383F@internet-consultants.com>, Daniel Droetto
<dd@internet-consultants.com> wrote:

+ Hi
+ My question seems very simple.
+ I want to get an html page from the web (store on a server different
+ from which I run my script), and put it on a $variable.

perldoc LWP contains the information you seek.

James


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

Date: Mon, 14 Dec 1998 09:49:07 GMT
From: dave@mag-sol.com
Subject: Re: how can I get this hash references?
Message-Id: <752muj$i4g$1@nnrp1.dejanews.com>

In article <3674149e.2855115@news.active.ch>,
  j123ender123@gmx.net wrote:
> Hi all
>
> I try to get shared resources from remote Win32 hosts with the
> function:GetSharedResources(\@Resources,dwType) from the
> Win32::NetResource modul.
> Now I don't know how I can get this resources.
> I found only the following sentence in the help:"Creates a list in
> @Resources of %NETRESOURCE hash references."
>
> In the Array @Resources I have some values like this:
> HASH(0x88bce0)HASH(0x893454)
>
> How can I get the real list of shared resources now?
>
> I'm very grateful for every help!

Looks like @resources contains a list of hash references. You should revisit
perldoc perlref and perldoc perldsc to work out how to access the actual
hashes and hence the data within them.

Dave...

--
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 14 Dec 1998 13:04:11 +0100
From: Ernst Christensen <e.christensen@nertjob.dk>
Subject: Re: how can script get file http://...
Message-Id: <3674FEBB.706159E7@nertjob.dk>

Hi
You can use the http-lib.pl

mv
Ernst

Gleb Ekker wrote:

> Hi all
>
> Is it possible to get some file (http://www.somehost.com/file.html) from
> another server without using CPAM library?
>
> Thanks.
>
> Gleb.



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

Date: Mon, 14 Dec 1998 10:34:29 GMT
From: bradley@iinet.net.au (Bradley K. Farrell)
Subject: Re: How do I allow File-uploading into database
Message-Id: <3674e8c9.321201930@news.m.iinet.net.au>

cgi@higherlove.com wrote:
>I want to allow users to upload graphics into an field in a
>ASCII-based database file. Anywhere I can find out how to do this?

Use the power search at dejanews. Try
search string: file upload
forums       : *perl*

This might give you some useful start points.

HTH
-- 
Bradley K. Farrell
bradley@iinet.net.au


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

Date: 14 Dec 1998 14:43:19 GMT
From: wolph@merlin.albany.net (r j huntington)
Subject: Re: localtime () - perl's  bug ?
Message-Id: <753868$g76$1@news.monmouth.com>

Russ Allbery (rra@stanford.edu) wrote:
: Clive Newall <crn@itga.com.au> writes:
: 
: > New at this game, aren't you? When these decisions were made, every
: > clock cycle saved made significant difference. As did every byte of
: > precious memory saved. Often forgotten in these days of software bloat
: > and 100+MHz processors.
: 
: I disbelieve this.  struct tm was cast into its current form in the 1970s,
: yes?  I find it hard to believe the cost of an extra few bytes of memory
: to offset the array by one element, or the cost of a subtraction, was that
: overriding of a concern for machines even in the 1970s.

You must be very young (no blame, of course). Let me assure you that
the above is quite true. Almost no one had megabytes to work with then.
Memory and CPU time were VERY VERY EXPENSIVE. Code was deliberately
tight as could be made to conserve those precious resources. That's
why we have a Y2K problem now. No one could afford the extra two bytes
then. Memory was a good 1,000 times more expensive - not even adjusted
for infaltion, which makes the ratio even more extreme. Take it from
one who was there.	-rh-



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

Date: Mon, 14 Dec 1998 10:33:33 +0100
From: "Lorenzo Cataldi" <lscom@tin.it>
Subject: Net::POP3 2 (La vendetta)
Message-Id: <752m05$so7$1@nslave1.tin.it>






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

Date: Mon, 14 Dec 1998 14:30:35 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Perl and FTP - without modules
Message-Id: <8caf0qpzia.fsf@gadget.cscaper.com>


First off, your subject line translates for me as:

"I'm willing to beat my head against the wall senselessly for
some large number of minutes or hours because I don't understand
that libnet can be installed by mortals."

So, having said that, my very FIRST advice to you is:

	## Don't Reinvent the Wheel ##
	use Net::FTP;

So please please PLEASE stop trying to reinvent this.  Graham has put
a lot of work in so that this should be a no-brainer for you.

>>>>> "Martin" == Martin  <minich@globalnet.co.uk> writes:

Martin> print $remote "STOR 1.foo\n";
Martin> &output;
Martin> &output;

Where are you opening the data connection and sending the data?  That
happens separately from the control connection (which never passes the
actual data, just control).

Again, if that's mysterious, consider the obvious.... use Net::FTP.

print "Just another Perl hacker (and CPAN user),"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Mon, 14 Dec 1998 13:42:33 GMT
From: yves.tremolet@par.sita.int
Subject: perl movie
Message-Id: <7534k8$sp5$1@nnrp1.dejanews.com>

Hello,

I am looking for a perl program that was posted here around 94 95.
It was a 2-3 pages perl code program with compressed ascii screens which, when
launched in an xterm, played a movie entitled "vestale sous contraintes,
exercice ludique en courrier 10". Anybody has it ?

yves.tremolet@sita.int

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 14 Dec 1998 10:48:15 GMT
From: Marcin Kasperski <Marcin.Kasperski@softax.com.pl>
Subject: Re: Perl, ORacle & Linux
Message-Id: <3674FBA3.A1C82644@softax.com.pl>

> 
> There exists Oracle 8.0.5 for Linux. Go strainght to www.oracle.com
> and find a trial version there. It includes client libraries (known as
> OCI). Then go to CPAN and fetch DBI and DBD::Oracle. Read docs. Compile them.
> Enjoy.
> 

I received Oracle beta CD from Oracle and found that it lacks some
libraries and headers. I was unable to compile any OCI program. 

Maybe they improved it until now.

-- 
Marcin Kasperski
Marcin.Kasperski@softax.com.pl


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

Date: Mon, 14 Dec 1998 14:45:17 GMT
From: pigs_can_fly@mindless.com (Jason Q.)
Subject: preserving case insensitive after splitting a string
Message-Id: <36771c83.42747338@news.cyberway.com.sg>

PROBLEM 1

I have a case insensitive (?i)$string.
If I split that string into an @array, every element no longer remain
case insensitive.

I manage to reverse this by placing each $array[n] in a loop which
makes them case insensitive again but is there an easy way to force
the element to remain case insensitive when splitting them?

**************************

PROBLEM 2

@array = (bird, hand, worth, bush);
$string = "bird in hand is worth two in bush";

If ($string contains every element in @array)
	{
	do this;
	}

problem is elements in arrays are variable so I suppose I have to put
them through a loop. How?

**************************

Thank you.


Jason Q.
http://www.generationterrorists.com


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

Date: Mon, 14 Dec 1998 10:30:33 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Programming Prob
Message-Id: <ebohlmanF3yAIx.HEs@netcom.com>

Eric Umehara <momiji@slip.net> wrote:
: I'm learning Perl.
: I had this wild idea about a problem that would often occur if it is
: real.

Nothing wild about it in the slightest.

: If you have a form which is accessed a lot and one person submits it,
: the script opens a file to input the data whiile at the same time
: another person submits the same form that would require the same output
: file what would happen. Would each sumbit have to wait in line for the
: one prebious to it to go or can  Perl/CGI scrits run simoltaniously?

If your script doesn't make arrangements otherwise, just about anything 
could happen.  Your output file could contain output from the two forms 
interspersed randomly, or you could lose one form.

The issue of how to deal with multiple, simultaneously executing 
processes (like CGI scripts) that need to use the same resources (such as 
output files) is called "concurrency control."  It's commonly dealt with 
by means of file locking, and I'd suggest that you look at perlfaq5, 
which has several sections dealing with how to lock files.

: Another problem. I'm program a script that is like a online shopping
: cart. I have figured out how to overcome the problem with people who use
: proxy servers and share IP addresses by assiging each person a ID
: alphnumberic character string that they carry around in through out
: their use. The problem is that what are the chaces of 2 people getting
: the same ID character which are all lowercase alph char and is their a
: way to aviod this problem?

The simple way to deal with this is to keep track of the identifiers 
you've generated.  You could also generate an identifier based on a 
combination of the current time, your process ID, the user's IP address, 
or what have you, that would be guaranteed to be unique.



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

Date: Mon, 14 Dec 1998 10:13:30 GMT
From: pigs_can_fly@mindless.com (Jason Q.)
Subject: renaming an array with a number at the end
Message-Id: <3674e353.28105082@news.cyberway.com.sg>

I have this seemingly simple task but am new to Perl so if any one
would help...

Within a while loop, I need to rename an array each time it goes
through the loop. @array0 changes to @array1 changes to @array2...

this is what I have but my syntax at @array[$y] is wrong. How should I
'phrase' it?

*********************

$y = 0;

while (a certain condition)
	{
	@array[$y];
	$y++;
	}

********************


Thank you.


Jason Q.


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

Date: Mon, 14 Dec 1998 11:47:34 +0100
From: "Stuart Thorn" <stuart@dune-concept.com>
Subject: Re: renaming an array with a number at the end
Message-Id: <752qg5$160j$1@buggy.easynet.fr>

Not sure if I fully understood your question but look at this:

foreach( @array ) {
 if ($_ == 745) { // or some condition testing here
   print "$_ meets condition"\n;
   last;
 }
}

The foreach loop iterates values of @array affecting each one to the default
$_ variable every time. Just do your testing on $_

Otherwise do it your way but notice commented error.
while (a certain condition)
 {
 @array[$y];    # Should read $array[$y]; The $ before to show we're looking
 $y++;          # for a scalar variable in the array.
 }

Hope that helps,
Stuart Thorn,
stuart@dune-concept.com
Dune Concept, Paris, France.

>Within a while loop, I need to rename an array each time it goes
>through the loop. @array0 changes to @array1 changes to @array2...
>
>this is what I have but my syntax at @array[$y] is wrong. How should I
>'phrase' it?
>
>*********************
>
>$y = 0;
>
>while (a certain condition)
> {
> @array[$y];
> $y++;
> }
>
>********************
>
>
>Thank you.
>
>
>Jason Q.




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

Date: Mon, 14 Dec 1998 12:34:26 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: renaming an array with a number at the end
Message-Id: <ebohlmanF3yG9E.5D0@netcom.com>

Jason Q. <pigs_can_fly@mindless.com> wrote:
: I have this seemingly simple task but am new to Perl so if any one
: would help...

: Within a while loop, I need to rename an array each time it goes
: through the loop. @array0 changes to @array1 changes to @array2...

Do you need to iterate through multiple *arrays*, or multiple *elements* 
of a single array?  If the latter, see the other responses.  If the 
former, the best approach is to use a multidimensional array (which Perl 
actually implements as an array of references to other arrays) rather 
than a bunch of separate arrays.  See the perldata, perldsc, perlref and 
perllol (man pages | HTML files | POD files) to learn how to do this.  
Getting your data structures right is just as important as getting your 
algorithms right.



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

Date: Mon, 14 Dec 1998 14:56:50 GMT
From: philipp999@gmx.net (Philipp)
Subject: Re: renaming an array with a number at the end
Message-Id: <3675241c.18707219@news.hamburg.netsurf.de>

On Mon, 14 Dec 1998 10:13:30 GMT, pigs_can_fly@mindless.com (Jason Q.)
wrote:

>Within a while loop, I need to rename an array each time it goes
>through the loop. @array0 changes to @array1 changes to @array2...

Hi Jason,

this might be a bit unefficient, but: use a multidimensional array....
when you want to "rename" your array just copy the content in @array
[0..n] [i++]

hope that helps....

-philipp


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

Date: Mon, 14 Dec 1998 11:34:34 +0100
From: "Stuart Thorn" <stuart@dune-concept.com>
Subject: script documentation
Message-Id: <752pnr$15gp$1@buggy.easynet.fr>

Hi,

I need to document my scripts in XML format. Nothing fancy, just tags like

##<function name="init" comment="To initialize variables"
## author="Stuart Thorn" version="1.0">
sub init {
##<variable="$cgi" scope="global"/>
   $cgi = new CGI;
}
##</function>

I know XML is going against the grain when it comes to perl documentation
but it suits my purposes...
Could someone tell me if there is some source documenting package available
already. Wouldn't need to be XML specific. For example a script that will
create skeleton pod documentation for a *.pl/*.pm file. It would help me
along the way.

Thanks,
Stuart Thorn,
stuart@dune-concept.com
Dune Concept, Paris, France.




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

Date: Mon, 14 Dec 1998 12:37:20 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: script documentation
Message-Id: <ebohlmanF3yGE8.5K1@netcom.com>

Stuart Thorn <stuart@dune-concept.com> wrote:
: Could someone tell me if there is some source documenting package available
: already. Wouldn't need to be XML specific. For example a script that will
: create skeleton pod documentation for a *.pl/*.pm file. It would help me
: along the way.

h2xs will do that if given the appropriate options (h2xs -XA -n <module 
name>).



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

Date: Mon, 14 Dec 1998 10:54:31 GMT
From: cnsxxx@my-dejanews.com
Subject: sorting hashes
Message-Id: <752qp6$l1n$1@nnrp1.dejanews.com>

Hi,

I have an associative array/hash (%myhash) as follows

key  val
---  ---
abc  1
def  12
ghi  6

How do I sort the hash to print out both the keys and values
sorted by the values?

TIA

Chris - chrisNOSPAMPLEASE@atg-design.co.uk
-----


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 14 Dec 1998 08:12:56 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: sorting hashes
Message-Id: <7532it$tp5$1@samsara0.mindspring.com>

cnsxxx@my-dejanews.com wrote in message <752qp6$l1n$1@nnrp1.dejanews.com>...
>Hi,
>I have an associative array/hash (%myhash) as follows
>key  val
>---  ---
>abc  1
>def  12
>ghi  6
>How do I sort the hash to print out both the keys and values
>sorted by the values?


Assuming there are only unique values, one simple way might be to just
reverse your hash:

#!/usr/local/bin/perl -w
use strict;
#assuming only unique values in the hash;

my %myhash =
       qw(abc 1
           def  12
           ghi  6);

my %mirror = reverse %myhash;

my @sorted = sort {$a <=> $b} keys %mirror;

foreach my $value (@sorted) {
    print "Key is $mirror{$value}, Value is $value\n";
}



HTH

AmD




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

Date: Mon, 14 Dec 1998 06:06:50 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sorting hashes
Message-Id: <MPG.10debb55f37d1d8e98995a@nntp.hpl.hp.com>

In article <752qp6$l1n$1@nnrp1.dejanews.com> on Mon, 14 Dec 1998 
10:54:31 GMT, cnsxxx@my-dejanews.com <cnsxxx@my-dejanews.com> says...
 ... 
> How do I sort the hash to print out both the keys and values
> sorted by the values?

perlfaq4:  "How do I sort a hash (optionally by value instead of key)?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 14 Dec 1998 10:30:24 +0000
From: Yoann Le Corvic <yoann.lecorvic@inrfasoft-civil.com>
Subject: Writing in a file ...
Message-Id: <3674E8BF.765C007@inrfasoft-civil.com>

Hello, I'm looking for a way to append a file, but not at the end of the

file. I want to modify dynamically a HTML File from the input of user of

my web site. I would like for example to add a line in a table of a file

when a user fill one of our form.

Does anyone knows how to do this,  is there a way to use "flags" or
something of the same kind ???


Thanks

Yoann
Internet Admin





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

Date: Mon, 14 Dec 1998 12:04:30 +0100
From: "Stuart Thorn" <stuart@dune-concept.com>
Subject: Re: Writing in a file ...
Message-Id: <752rk0$16kd$1@buggy.easynet.fr>


Hi Yoann,

>Hello, I'm looking for a way to append a file, but not at the end of the
>
>file. I want to modify dynamically a HTML File from the input of user of
>
>my web site. I would like for example to add a line in a table of a file
>
>when a user fill one of our form.
>
>Does anyone knows how to do this,  is there a way to use "flags" or
>something of the same kind ???


Yes in a file you could have a table like

<table>
<tr>
  <td>one two three</td>
  <td>one two three</td>
</tr>
<!--%%ROW_INSERT-->
</table>


and then read all your file into $file and do a simple :

$file =~ s(<!--%%ROW_INSERT-->)(<tr><td
colspan="2">Footnote</td></tr>\n<!--%%ROW_INSERT-->);


Hope that helps,
Stuart Thorn,
stuart@dune-concept.com
Dune Concept, Paris, France.




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

Date: Mon, 14 Dec 1998 13:27:02 GMT
From: dturley@pobox.com
Subject: Re: Writing Perl with Notepad
Message-Id: <7533n5$ruv$1@nnrp1.dejanews.com>

In article <36751e8b.1289858@news.skynet.be>,
  bart.lateur@skynet.be (Bart Lateur) wrote:

> You are supposing the files move from CP (Windows) to Linux through FTP.
> I am assuming that both systems can be local, that Linux and Windows
> actually share a hard disk.

Ah, I see. I never could understand the line break problem since I've written
scripts on local Macs, Windows 3* and 9*, and Linux machines, without ever
having to deal with line breaks.

There's always *that* possibility. :-)

cheers,

____________________________________
David Turley
dturley@pobox.com
http://www.binary.net/dturley/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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