[7026] in Perl-Users-Digest
Perl-Users Digest, Issue: 651 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 24 07:27:16 1997
Date: Tue, 24 Jun 97 04: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 Tue, 24 Jun 1997 Volume: 8 Number: 651
Today's topics:
Re: CSV Files (Tad McClellan)
DF_File, abort routines - Novice question <guys@best.com>
Re: File Permissions - 'nobody' can't open file (Nathan V. Patwardhan)
Re: File Permissions - 'nobody' can't open file (Abigail)
Help me!!! (Wayne Smith)
Re: help on global variables (King M. Lee)
Re: Help with pushing user to a page <rootbeer@teleport.com>
Re: interprets as shell instead of perl <esupu@warwick.ac.uk>
IO module? Which Perl? (Hank Lee)
Re: IO module? Which Perl? (Michael Fuhr)
long file rename to 8.3 (bigham)
microsoft personal web server parsing perl scripts (Ralf =?iso-8859-1?Q?L=F6ffler?=)
msqlPERL - comon' baby! (professor katz)
Re: Need a script that checks SUID = ROOT <rra@stanford.edu>
Re: Ouputting a Simple GIF Image <bildun@vci.net>
Perl CGI passing a file <alex@smilie.com>
Re: perl cgi script can't load an applet <rmlynch@best.com>
POssibly Dumb Question: qq() and qw()... (professor katz)
Re: Q: an alternative to this use of "goto"? (jared still)
Re: regular expressions (Tad McClellan)
Re: uc function for PERL4 (Abigail)
Re: Very Basic Perl Question on Array <loconnor@conctrls.com>
Re: When do I call srand? (Abigail)
Why do i get text/octet-stream download when i try to c <labah@algonet.se>
Re: Win 32 port of Comm.pl by Eric Arnold (Eric Arnold)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 21 Jun 1997 19:02:04 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: CSV Files
Message-Id: <s1qho5.1m4.ln@localhost>
Christopher Kings-Lynne (chriskl@tartarus.uwa.edu.au) wrote:
: Has anybody got a Perl script which can read in CSV files?
You mean like the Text::CSV perl module?
: Otherwise, can anybody tell me what the syntax error in the following code
: is? (Near the if apparently)
I cannot tell you where the syntax error is, because there is no
syntax error in the code below.
If there had been a syntax error, then we would want to see the
error message that perl gave you in order to help fix it...
I do see a logic error in there though.
: while (($line eq &read_file("FILE1"))) {
^ ^^ ^
You are testing to see if the string returned from read_file() is
the same as the string in $line.
You don't need one of those sets of parenthesis either:
: while ($line = &read_file("FILE1")) {
^
^ assignment operator...
: # split the fields at the , character
: @tabledata = split(/,/,$line);
^^^^^
You should REALLY be using the -w switch to enable compiler warnings,
you know.
It would have told you that $line was never assigned a value...
: if ( ($tabledata[0] ge $start) && ($tabledata[0] le $stop) ) {
: print "<TR>\n";
: foreach $data (@tabledata) {
: print "<TD><B>$data</B></TD>\n";
: }
: print "</TR>\n";
: $counter++;
: }
: }
: The $start and $end are read in from the GET call. The tabledata things
: are read in from a file.
: Please reply by email if possible.
Ask it here, get the answer here.
: ps. I'm really new to the whole Perl thing.
Then use the -w switch to allow perl to help you debug your programs.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Sun, 22 Jun 1997 15:53:12 -0700
From: Guy Smith <guys@best.com>
Subject: DF_File, abort routines - Novice question
Message-Id: <33ADACD8.60C5@best.com>
Two related questions:
1) Is it my imagination, or are DB_File created databases a bit
fragile? While experimenting I have had two situations where the
resulting database was unusable after it was closed (one was a process
abort when I hit my disk quota during a write operation, and the other
was a programming bug where by I was not closing a direct open of the
file along with the untie). I hesitate proceeding with my project if
simple situations like these cause the entire database to become
unusable.
2) Is there a global exit routine for Perl5? Id like unexpected
errors to force a call to a custom routine (i.e., close_all_files) but
cannot find a reference to any such feature.
Thanks in advance, and if possible, please answer via e-mail since my
schedule for the next few weeks is uncertain.
Guy Smith
NationalPulse
------------------------------
Date: 22 Jun 1997 19:09:11 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: File Permissions - 'nobody' can't open file
Message-Id: <5ojt8n$eoq@fridge-nf0.shore.net>
J. Linder (jann@jann.com) wrote:
: Sorry, abigail...this is a perl question...seeing as how their cgi is
: written in perl.
It wasn't a Perl question, since the answer was to fix their
permissions. Sure, people write CGI programs in Perl, but their
question wasn't about Perl syntax, or a Perl language issue. If you
*really* want to answer all the CGI / file permissions / webserver
questions, go ahead, but I suspect you'll feel the same way most of us
do after having read (and answered) the same question a million times.
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Sun, 22 Jun 1997 20:31:08 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: File Permissions - 'nobody' can't open file
Message-Id: <EC72Bw.HJI@nonexistent.com>
J. Linder (jann@jann.com) wrote on 1391 September 1993 in
<URL: news:jann-2206971322580001@usr2-dialup60.mix2.boston.mci.net>:
++ In article <EBsInM.6yq@nonexistent.com>, abigail@fnx.com wrote:
++
++ >Mission Hills Association (mha@dunraven.com) wrote on 1383 September 1993
++ >in <URL: news:33A31586.23AE@dunraven.com>:
++ >++ Hi -
++ >++
++ >++ I'm running a CGI script that needs to open a file and append data.
++ >++ It works fine from the shell, but not when it's invoked from a
++ >++ browser.
++ >++
++ >++ I think the problem must be that 'nobody' doesn't have permission
++ >++ to create a file in the cgi-bin directory, or in my own (I've tried
++ >++ both.)
++ >
++ >Bingo! 99.9% of the cgi "problems" is failing to see this.
++ >
++ >++ Can someone let me know a good workaround?
++ >
++ >Yes. Read a faq. Or ask it in a CGI group.
++ >It's not a Perl question.
++ >
++
++ Sorry, abigail...this is a perl question...seeing as how their cgi is
++ written in perl.
++
++ I get tired of lazy people who, instead of answering, give a smart-alek
++ reply.
++
++ The answer is simple. chmod the directory to 755. That will allow nobody
++ access...just ensure that you move the file later to a secure directory or
++ chmod the structure afterwards with your cgi script if the data is
++ sensitive.
++
Of course. How stupid of me! File permissions in Unix are only their
for Perl programs. Had the CGI program be written in another
language, then the problem wouldn't have happened.
I'm glad you gave the sensible answer 'chmod 755', that'll give
"nobody" permission to create files! Never mind what's in the FAQ.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Sun, 22 Jun 1997 16:24:25 GMT
From: gnu@netcom.com (Wayne Smith)
Subject: Help me!!!
Message-Id: <gnuEC6qwp.GyM@netcom.com>
I have this script to add users from a file with the format firstname
lastname. What I would like to do is modify the script to read from a
file that has just the userID an run the output through the userdel
command. The end result is to delete a list of 1200 users from the
passwd/shadow file. Please help it'll take forever to do it by hand.
Script is as follows:
#!/usr/local/bin/perl
print "#!/bin/csh\n\n";
while (<>) {
chop($_);
s/\s(\w)\.//;
$mi = $1;
/(\w+)\s+(\w+)/;
$fname = $1;
$finit = substr($fname,0,1);
$lname = $2;
$trimname = substr($lname,0,7);
$uname = "\L${finit}$trimname";
$fullname = "$fname $lname";
system("useradd -s/bin/tcsh -gstaff -d /export/home -m -c
\"$fullname\" $uname\n");
}
TIA
smitty
------------------------------
Date: 22 Jun 1997 04:52:48 GMT
From: klee@sally.nas.nasa.gov (King M. Lee)
Subject: Re: help on global variables
Message-Id: <5oib30$6os$1@cnn.nas.nasa.gov>
I have a question and I wonder if anyone can help.
I have some programs written in version 4 of Perl and I want
to convert to version 5 using modules (mostly as a learning
exercise- I am a relative newbie). I used includes (perl -P foo.pl)
and global variable in the old versions. I planned to first convert
to modules (using packages) and then to objects.
I am having problems getting my packages to see the global
variables. I want to avoid something like $main::foo; I tried
use vars qw(foo);
but that evidently creates a variable inside the package
rather than in main::. Is there an easy way to do this without
objects?
I prefer email as my news reader is not reliable
Thanks in advance
King Lee
king@wilbur.nas.nasa.gov
--
|King Lee * Phone 805-664-3148 |
|California State University,Bakersfield * email: klee@nas.nasa.gov |
|9001 Stockdale Highway * |
|Bakersfield, CA 93309 * |
------------------------------
Date: Sat, 21 Jun 1997 19:49:14 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Philip Wagnert <pwagnert@algonet.se>
Subject: Re: Help with pushing user to a page
Message-Id: <Pine.GSO.3.96.970621194749.18605C-100000@kelly.teleport.com>
On Sat, 21 Jun 1997, Philip Wagnert wrote:
> I'm kind of new to perl but have worked with it a bit the last months.
> But now I would like a script for pushing to a page if some certain
> criteria are met.
Are you wanting to buy one, or are you trying to learn how to write one?
It's not hard to write one; how far have you gotten? Or, how much are you
willing to spend? :-)
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 22 Jun 1997 20:15:45 +0100
From: mike mah <esupu@warwick.ac.uk>
To: AtaruM76 <atarum76@aol.com>
Subject: Re: interprets as shell instead of perl
Message-Id: <Pine.SOL.3.95.970622200836.3938B-100000@crocus>
On 20 Jun 1997, AtaruM76 wrote:
>
> I am having a problem, I have the following test cgi:
>
> #!/usr/bin/perl
>
> print "this is a test"
> exit (0);
>
> and what is happening is that the os keeps trying to interpret it as a
> shell script, and doesn't call perl!
First of all, how do you know it didn't call perl?
Secondly, you must check which perl is used in your system. Use
command
which perl
to find out. Sometimes, perl interpreter is keep in different directory.
For my system, perl are keep in both /usr/bin/perl and
/usr/local/bin/perl. When I declare #!/usr/bin/perl, it didn't work. On
the other hand, It work when I declare #!/usr/local/bin/perl. That might
be your problem.
> That is the correct location of the perl program, I can't figure this out.
> Something must have broken when I wasn't looking.
> I am using redhat linux 3.0.3, and perl 5.
> Maybe this is a unix administration problem, but if someone knows, what
> is going on, please let me know. I do have root access, but I did not
> originally set this up.
>
> thanks
>
> Chris Buchholz
> chrisb@issoln.com
>
>
Let's strike for exellent.
Yours sincerely,
mike mah
------------------------------
Date: 22 Jun 1997 21:10:45 GMT
From: rand@mictlan.sfsu.edu (Hank Lee)
Subject: IO module? Which Perl?
Message-Id: <5ok4cl$62a@news.csus.edu>
Keywords: CPAN,perl
Pardon me for asking, but which version of perl has the IO module
bundled with it? I was trying to install the CPAN module, but it
requires Net::FTP to function. The libnet package requires the IO
module. I was not able to run the Makefile.PL simply because the
system that I am on lacks the IO module. I believe we're running
Perl 5.003. Thanks in advance for any help!
--
Hank Lee
------------------------------
Date: 22 Jun 1997 16:05:04 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: IO module? Which Perl?
Message-Id: <5ok7ig$otj@flatland.dimensional.com>
Keywords: CPAN,perl
rand@mictlan.sfsu.edu (Hank Lee) writes:
> Pardon me for asking, but which version of perl has the IO module
> bundled with it? I was trying to install the CPAN module, but it
> requires Net::FTP to function. The libnet package requires the IO
> module. I was not able to run the Makefile.PL simply because the
> system that I am on lacks the IO module. I believe we're running
> Perl 5.003. Thanks in advance for any help!
IO is bundled with 5.004; it's also available on CPAN.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Tue, 24 Jun 1997 02:18:57 GMT
From: bigham@ix.netcom.com (bigham)
Subject: long file rename to 8.3
Message-Id: <5onap8$scf@dfw-ixnews3.ix.netcom.com>
I need to
1) rename a large number of long filenames to be consistent with a DOS 8.3
format (e.g. unsigned_integer.ada ==> uns_int.ada)
2) track the filename changes and modify the references to the long filenames
to the newer 8.3 equivalent in an index/build file.
Is there anything that currently does the filename rename?
thanks,
tim (bigham@ix.netcom.com)
------------------------------
Date: 20 Jun 1997 19:07:28 GMT
From: hexe_lenggries@t-online.de (Ralf =?iso-8859-1?Q?L=F6ffler?=)
Subject: microsoft personal web server parsing perl scripts
Message-Id: <5oekdg$k9p$1@news00.btx.dtag.de>
Can't find any documentation how to configure the microsoft personal web
server, so it parses .pl files. Must be some registry keys. Any hints
will be appreciated
ralf
------------------------------
Date: Sun, 22 Jun 1997 12:56:23 -0800
From: prof@katz.com (professor katz)
Subject: msqlPERL - comon' baby!
Message-Id: <prof-ya02408000R2206971256230001@snews.zippo.com>
Is it me, or is the documentation for msqlperl woefully inadequate? I'm a
SQL newbie to be sure, but I just want a list of functions and usage. I've
checked through ALL of the documentation, but there is just some confusing
stuff, and it's not at all clearly laid out.
For instance the documentation points out:
# Now we create two tables that are certainly not in the test database
# If you don't understand the trickery here, just skip this section, No big
deal.
{
my $goodtable = "TABLE00";
my(%foundtable,@foundtable);
@foundtable = $dbh->listtables;
@foundtable{@foundtable} = (1) x @foundtable; # all existing tables are
now keys in %foundtable
my $limit = 0;
for ($firsttable, $secondtable) {
while () {
next if $foundtable{++$goodtable};
my $query = qq{
create table $goodtable (
she char(32),
him char(32) not null,
who char (32)
)
};
unless ($dbh->query($query)){
die "Cannot create table: query [$query] message
[$Msql::db_errstr]\n" if $limit++ > 1000;
next;
}
$_ = $goodtable;
last;
}
}
# For the tests in this script we have two tablenames that we can
# peruse: $firsttable and $secondtable
}
Well, I don't understand the trickery, but I really need to! That qq{}
business really throws me. But I'm new to PERL object-oriented stuff. The
thing that really throws me, is that I can create a table just by typing:
$sth = $dbh->query("create table test_table (
name char(32),
rank char(32),
sn char(32)
));
So what's the big whoop here? But one thing that I can't figure out is how
to make a keyfield using msqlperl. There's no mention anywhere that I can
find.
Any help, support, or hints to finding more material would be greatly
appeciated. BTW, I already found the mailing list archives, and I have
subscribed to the mailing list. Most of my problems are pretty basic
programming issues, and not related to setting up the programs on the
server. LIke I said, I am fairly new to this stuff but I am struggling to
find decent documentation. Also, If you're in my position, respond to my
post and we'll start a mutual support group via email or something.
Thanks,
Katz
------------------------------
Date: 23 Jun 1997 06:59:40 -0700
From: Russ Allbery <rra@stanford.edu>
To: sdcote@lci.net
Subject: Re: Need a script that checks SUID = ROOT
Message-Id: <m3d8pdifn7.fsf@windlord.Stanford.EDU>
[ Posted and mailed. ]
Stephan D Cote <sdcote@lci.net> writes:
> I was wondering if anyone has a perl script that would scan a file
> system and check which files were suid = root.
Don't use Perl. Use find. That's what find's for.
find / -xdev -perm +4000 -print
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sat, 21 Jun 1997 20:42:24 -0500
From: "Bill Dunn" <bildun@vci.net>
Subject: Re: Ouputting a Simple GIF Image
Message-Id: <5ohvsf$lo3$2@news.accessus.net>
Have you tried the GD.pm library for making GIFs on the fly?
http://www-genome.wi.mit.edu/ftp/pub/software/WWW/GD.html
Bear wrote in article <33a31e13.44427503@news.ucsc.edu>...
>Hi, I have no idea of were to start but I want to be able to output
>some farily basic GIF 87a files with Perl 5 to my web browser. I have
>Perl set up with my server and all that fine. I just need some quick
>code that outputs a gif file that, let's say, is 10x10 in size and
>every other pixel is black.
>
>Also, this is a general GIF question, do you have to use LZW
>compression?
>
>I am also interested in not-so basic (transparent BGs, LZW
>compression, etc) code for outputting GIFs, but thats for the future.
>
>Thanks for any help,
>
> Aran Clary
> clary@mapcruzin.com
>
------------------------------
Date: Sun, 22 Jun 1997 19:50:57 +0100
From: "Alex" <alex@smilie.com>
Subject: Perl CGI passing a file
Message-Id: <867005399.20778.0.nnrp-1.9e98d36c@news.demon.co.uk>
Hi,
I need to write a perl program to take 2 arguments, a file name and a file
and save it out. I have written one that will take a name and a line of
text
and keep appending the line of text to the file, but I really would like
to
send it the whole file. I'm accessing the perl program via java.
Any ideas?
alex@smilie.com
------------------------------
Date: Sat, 21 Jun 1997 22:33:40 -0700
From: Robert Lynch <rmlynch@best.com>
To: Slava Zimine <zimine@mail.cern.ch>
Subject: Re: perl cgi script can't load an applet
Message-Id: <33ACB934.63FC13C9@best.com>
You're using:
> <applet code = myApplet.class base = /fullpath >
but you should do:
<applet code = myApplet.class
codebase="http://full_path_to_directory"...
because 1) you need to use a codebase, and 2) it helps to be sure the
codebase is full and correctly pointed to your your applet's html....
I've seen this work many times with just your problem.
Hope this helps.
Bob L.
--
Robert Lynch-Berkeley CA USA-rmlynch@best.com
http://www.best.com/~rmlynch/
--
Slava Zimine wrote:
>
> Hi.
>
> I ve got the following problem:
> my perl cgi script writes at stdout an html code which loads an applet.
> I need perl to read a variable number of files in directories which
> change daily
> and pass the texts in applet parameters.
> and while executing script i got "myApplet.class not found.
>
> if press on "view source" button the script produces a right code
> with
> <applet code = myApplet.class base = /fullpath >
>
> and i know that the html source is right becose the applet perfectly
> loads with an html file which i produce by :>perl myApplScript.pl >
> myApplet.html and then load this myApplet.html file in netscape.
>
> So, anybody could have any idea why my cgi poses such a problem??
>
> Thank you in advance
>
> Slava
>
> --
> ***********************************
> Slava Zimine zimine@mail.cern.ch
> zimines3@cuimail.unige.ch
------------------------------
Date: Sun, 22 Jun 1997 12:47:57 -0800
From: prof@katz.com (professor katz)
Subject: POssibly Dumb Question: qq() and qw()...
Message-Id: <prof-ya02408000R2206971247570001@snews.zippo.com>
I see this a lot:
qq{} and qw{} and qq() and qw()...
What is it? I'm trying to find it in documentation, but I can't find it
anywhere. Just a hint to where to look would be appreciated.
Thanks
------------------------------
Date: Tue, 24 Jun 1997 05:20:07 GMT
From: jkstill@teleport.com (jared still)
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <33af58c8.193148961@news.teleport.com>
On Mon, 23 Jun 1997 11:21:08 -0700, Tom Phoenix
<rootbeer@teleport.com> wrote:
>
>the future of goto is much more in doubt. Hope this helps!
>
>-- Tom Phoenix http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com PGP Skribu al mi per Esperanto!
>
What happened to 'There's more than one way to do it.' ?
------------------------------
Date: Mon, 23 Jun 1997 23:28:10 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: regular expressions
Message-Id: <qcino5.du9.ln@localhost>
Tri Tram (tram@olympic.seas.ucla.edu) wrote:
: Can somebody please help me with the regular expressions? I have the
: following:
: text #(text)
: text #(more test)
: test #(text and more text)
: I want to change it to:
: text add_text(text)
: text add_text(more_text)
: test add_text(text_and_more_text)
------------------------------
#! /usr/bin/perl -w
$_=<<ENDTEXT;
text #(text)
text #(more test)
test #(text and more text)
ENDTEXT
s/#\(/add_text(/g;
1 while s/( # remember what we matched, so we can put it back
\( # match an opening parenthesis
[^)]* # match zero or more of any char that is not a paren
) # stop remembering
\s # match one white space (space, tab or newline)
/$1_/gx;
print;
------------------------------
: thanks for your help.
You're welcome.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Sun, 22 Jun 1997 03:45:39 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: uc function for PERL4
Message-Id: <EC5rs3.1DG@nonexistent.com>
Bruno Pagis (pagib@aur.alcatel.com) wrote on 1389 September 1993 in
<URL: news:33AA835A.7169@aur.alcatel.com>:
++ I've written a uc (capitalize) function for PERL4.
++ There is more than one way to do it. Anybody wloud have a better idea ?
Except for installing perl5.004:
sub uc {
$_ [0] =~ tr/a-z\xe0-\xf6\xf8-\xfe/A-Z\xc0-\xd6\xd8-\xde/;
$_ [0];
}
which uses the ISO 8859-1 locale.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: 24 Jun 1997 02:05:01 GMT
From: "Lance O'Connor" <loconnor@conctrls.com>
Subject: Re: Very Basic Perl Question on Array
Message-Id: <01bc8043$248b3bc0$06808080@lance>
You can actually have arrays be dynamic by using the shift()/unshift() and
push()/pop() functions. For Example:
#Add an element to the begining of an array, or start a new one...
unshift(Array, "Element1");
#Get first element in array...
$Element1 = shift(Array);
#Add an element to the end of an array, or start a new one...
push(Array, "ElementX");
#Get last element in array...
$ElementX = pop(Array);
hcchan@wellsfargo.com wrote in article <867111149.17930@dejanews.com>...
> Hi,
>
> I am new to Perl and have a very basic question.
>
> How do I write up a perl program which will create an array.
> I have a file which contains the name of tablespaces in Oracle and
> will be insert into the array.
>
> The size of tablespace grows/shrink dynamcially, so it
> may be different each day. And I don't know how big
> an array I should set aside.
>
> Any ideas,
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
>
------------------------------
Date: Sun, 22 Jun 1997 04:03:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: When do I call srand?
Message-Id: <EC5sLL.2MC@nonexistent.com>
Tom Phoenix (rootbeer@teleport.com) wrote on 1390 September 1993 in
<URL: news:Pine.GSO.3.96.970621133024.24220B-100000@kelly.teleport.com>:
++
++ > and both need random numbers, should I call srand() in the require()'ed
++ > program, or only the outer program?
++
++ Once for each process is sufficient. In 5.004, Perl even calls srand() for
++ you if it sees that you haven't done so before you first use rand().
++
This actually raises an annoying issue.
Suppose you have a module X.pm, that needs the output of rand().
But since you want to do the proper implementation abstraction,
you don't require the user of the module to call srand(), but
you call srand() in the initialization routine of the module.
You follow the suggestion in the camel and call
srand (time ^ ($$ + $$ << 15));
Now, the person in the next cubicle is writing Y.pm, also needing
the output of rand(). Being an as clean programmer as you are,
she also calls srand (time ^ ($$ + $$ << 15)) from the initialization
routine of Y.pm.
Everything goes fine.
Until the guy upstairs thinks, wow, X.pm and Y.pm are just the
modules I need. I use them both. And things break down.
It would be real nice if there was a way to find out if srand()
was already called or not.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Mon, 23 Jun 1997 05:44:32 +0200
From: Jonas Thvrnvall <labah@algonet.se>
Subject: Why do i get text/octet-stream download when i try to create html document with perl?
Message-Id: <33ADF120.99@algonet.se>
I'm creating a simple guestbook that work excellent on my pc with http
server, but when i try to configure it for my hompage server at
www.algonet.se i dont get any documents, netscape just ask me i wan't to
save the text/octet-stream. Can someone tell me how to fix this, or what
the problem is?
This is the string i use in perl to create the document
print "<!--Content-type: text/html-->\n\n";
Jonas T
------------------------------
Date: 23 Jun 97 04:46:58 GMT
From: eric.arnold@sun.com (Eric Arnold)
Subject: Re: Win 32 port of Comm.pl by Eric Arnold
Message-Id: <ERIC.97Jun23044658@m-e-ir1.sun.com>
In message <866667709.30082@dejanews.com> you write:
>I'm just wondering if anyone has ever done a Win 32 PERL port of Eric
>Arnold's Comm.pl module. I'd really appreciate it if someone could let me
>know by email where I can acquire such a port. Thanks.
>
>Derek Winters
>derek.winters@arris-interactive.com
>
>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
I don't know of anyone who has. Comm.pl is much based on the existence
of pseudo-ttys to run a subprocess under. I don't know much about what
exists for Win* that would do this. However, since programs for Win*
aren't designed for TTY control (as far as I know, and I don't know
much), it might not be necessary. You can use Open3 to start a
subprocess, and "expect()" it, though you must handle when you have
gone past the end of available data (look for a TIMEOUT as a last
resort).
-Eric
require "Comm.pl";
&Comm'init( 1.6 );
use IPC::Open3;
$|=1;
open3( WTR, RDR, ERR, "/bin/sh" ) || die "open3 failed";
select(WTR);$|=1;select(STDOUT);
print WTR "who\n";
{
( $match, $err, $before, $after ) = &expect( *RDR, 1, '.*\n' );
print "($match)\n";
if ( not defined $match )
{
print "err=$err, breaking loop\n" if $err;
last;
}
redo;
}
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 651
*************************************