[10672] in Perl-Users-Digest
Perl-Users Digest, Issue: 4264 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 20 12:07:20 1998
Date: Fri, 20 Nov 98 09:00:23 -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 Fri, 20 Nov 1998 Volume: 8 Number: 4264
Today's topics:
a very simple question! <ywang@engsoc.carleton.ca>
Aggregate c_b9209@my-dejanews.com
ascending <ours@casema.net>
Re: cannot exit CGI process after forking dzuy@my-dejanews.com
Re: Environment variables.... <flavell@mail.cern.ch>
Re: Environment variables.... <ours@casema.net>
FAQ? <magicfab@hotmail.com>
Hashed array printing ? <dkoleary@tako.wwa.com>
Re: HELP: how to prompt for input from command line? (Andrew M. Langmead)
Re: Help:load unix ls>@array for use in cgi list box dturley@pobox.com
Re: Help:load unix ls>@array for use in cgi list box dave@mag-sol.com
Re: Help:load unix ls>@array for use in cgi list box dturley@pobox.com
How do you pass parameters to Perl script from HTML #ex (Bill Morgan)
Re: HTTPS - I cannot find a module on CPAN for this. dturley@pobox.com
Re: I download ActiveState but don't understand how to (Rich)
NDBM Size (Henry Lifton)
Re: Need equivalent to a sh's export command. haakon.alstadheim@sds.no
Re: PERL for windows 95/NT <perlguy@technologist.com>
Re: PERL for windows 95/NT <Allan@due.net>
PerLDAP Module Help! (Clay Reimer)
Re: PerLDAP Module Help! (Randy Kobes)
Re: Please help on getting username dave@mag-sol.com
Re: Posting FROM Perl (I R A Aggie)
Re: Put your options list in a file, trick for the novi (I.J. Garlick)
puzzler jschueler@detroit.usweb.com
reset one variable? <dropzone@mail.utexas.edu>
Re: Scope question for Perl <Allan@due.net>
Re: scripts similar to hotmail (I.J. Garlick)
Re: Single word ouptu from aa array <j_lampe@bellsouth.net>
Re: Strange Failure <perlguy@technologist.com>
Re: Strange Failure (Clay Irving)
Re: Strange Failure (Clay Irving)
Re: Strange Failure (Larry Rosler)
Sum by group c_b9209@my-dejanews.com
Re: trouble storing array of objects <r28629@email.sps.mot.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Nov 1998 14:50:56 GMT
From: Yue Wang <ywang@engsoc.carleton.ca>
Subject: a very simple question!
Message-Id: <733vkg$8oh$3@bertrand.ccs.carleton.ca>
Subject: a very simple question!
Newsgroups: comp.lang.perl.misc
Summary:
Keywords:
Hi,
I have a very simple question with regard to automatically reload
a HTML page, basically I am trying to redirect to this URL in my cgi
script using
" print $query->redirect('http://www.bagd.com');"
Now, the problem is the page shows up with it's old value field that's
saved in cache. I tried to use
print "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"3; URL=http://www.bagd.com\">\n";
It redirect to the reloaded URL, but there's always this intermediate page
before transferring to the new URL.
I am just wondering if there's anyone who knows how to disable
cache in HTML, or any perl command that will allow me to redirect to an
URL and reload that URL automatically? Thanks a lot.
Yue
--
------------------------------
Date: Fri, 20 Nov 1998 15:53:34 GMT
From: c_b9209@my-dejanews.com
Subject: Aggregate
Message-Id: <73439k$p5f$1@nnrp1.dejanews.com>
Hello!
Have a data file where the first coulmn has group data and the other have
values and I want to clculate the sum and counts by groups and the data file
is realy huge have found I can use hash variabels but I can't get the values
in a array. How I do to calculate the sum for each column by group in the
data file? has anyone a solution of this, please help me this problem make me
crazy here is my script for a small data file
\Claes
sub test{
open IN, "$utdata\\tabel.dat" or die "can't open in: $!";
while (<IN>){
($var,@DATS)=split(" ",$_);
$suml{$var} = [ @DATS ];
$sum0{$var} += $DATS[0];
$sum1{$var} += $DATS[1];
$sum2{$var} += $DATS[2];
$sum3{$var} += $DATS[3];
$sum4{$var} += $DATS[4];
$ant{$var} +=1;
}
foreach $key (sort(keys %sum0)) {
print "$key $ant{$key} $sum0{$key} $sum1{$key} $sum2{$key} $sum3{$key}
$sum4{$key}\n";
}
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 20 Nov 1998 17:01:15 +0100
From: "Casema" <ours@casema.net>
Subject: ascending
Message-Id: <7343r7$lsa$1@sun4000.casema.net>
Hi group,
$SQL = "SELECT * FROM news";
what would be a valid statement to get the output ascending /
descending?????
Oh, by the way, I am using WIN32::ODBC, so this is Perl Related
Thanks,
michel
------------------------------
Date: Fri, 20 Nov 1998 15:01:26 GMT
From: dzuy@my-dejanews.com
Subject: Re: cannot exit CGI process after forking
Message-Id: <73407p$mc6$1@nnrp1.dejanews.com>
In article <3654851A.72224E86@pmel.noaa.gov>,
Jonathan Callahan <callahan@pmel.noaa.gov> wrote:
> We have a perl cgi script which reads some form input, creates an
> initialization file and then execs a program which takes a long time.
> Unfortunately, our cgi doesn't return, and our browser waits, until the
> program is finished. We've tried forking child processes using all the
> methods in the camel book:
>
> if ($pid = fork) { #parent
> exit 0;
> } elsif (defined $pid) { #child
> exec 'cd subdirectory; run_long_program';
> } else {
> die;
> }
>
> -or-
>
> fork && exit;
> exec 'cd subdirectory; run_long_program';
>
> -or-
>
> unless (fork) { #child
> unless (fork) { #grandchild
> sleep 1 until getppid == 1;
> exec 'cd subdirectory; run_long_program';
> exit 0;
> }
> # first child exits quickly
> exit 0;
> }
> wait; #parent reaps first child quickly;
>
> When we print out the $pid in each test section in the first example it
> appears that our CGI is indeed forking. And we are running the long
> program and getting appropriate output. But none of these examples
> allow the cgi process to return before run_long_program is finished
> executing.
>
> Does anyone understand why we're having this problem?
>
> Does it have to do with our server?
>
It's not your server. The parent process apparently waits til the child
process exits. Try
use POSIX;
waitpid(-1, &NOHANG);
This tells the parent not to wait for the child to exit. Read on your
system's waitpid man page for details on different wait.
> Is it something anyone has done successfully?
>
> Frustrated,
>
> -- Jonathan Callahan
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 20 Nov 1998 13:40:09 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Environment variables....
Message-Id: <Pine.HPP.3.95a.981120133742.18569C-100000@hpplus01.cern.ch>
On Fri, 20 Nov 1998, Casema wrote:
> Is there a way to 'read' environment variables such as:
>
> screen resolution
> installed user-name
> domain names
>
> from the $ENV????
Only if somebody's put them there. Did you have a particular
situation in mind? If it was a CGI execution, then your question
belongs on the comp.infosystems.www.authoring.cgi group.
After you've read the group's FAQ and checked the CGI specification,
naturally.
------------------------------
Date: Fri, 20 Nov 1998 15:02:46 +0100
From: "Casema" <ours@casema.net>
Subject: Re: Environment variables....
Message-Id: <733suf$3g4$1@sun4000.casema.net>
I am trying to figure out how to write a counter-script.
I want one that determines the browser and platform. As well as screen res.
I then can optimize my pages!
Thanks for answering.
Michel
Alan J. Flavell wrote in message ...
>On Fri, 20 Nov 1998, Casema wrote:
>
>> Is there a way to 'read' environment variables such as:
>>
>> screen resolution
>> installed user-name
>> domain names
>>
>> from the $ENV????
>
>Only if somebody's put them there. Did you have a particular
>situation in mind? If it was a CGI execution, then your question
>belongs on the comp.infosystems.www.authoring.cgi group.
>
>After you've read the group's FAQ and checked the CGI specification,
>naturally.
>
------------------------------
Date: Fri, 20 Nov 1998 16:00:44 GMT
From: "F Rodriguez" <magicfab@hotmail.com>
Subject: FAQ?
Message-Id: <Mmg52.174$4Y6.563981@198.235.216.4>
Can someone direct me to the Perl FAQ?
Many tx.
MagicFab@bigfoot.com
------------------------------
Date: 20 Nov 1998 16:56:48 GMT
From: "Douglas K. O'Leary" <dkoleary@tako.wwa.com>
Subject: Hashed array printing ?
Message-Id: <73470g$ac8$1@hirame.wwa.com>
Hi;
I'm playing around with references, so hopefully, this
is just a dumb newbie error. I have a hash set up
keyed by disk device driver. The values are a scalar array
with volume group, total disk size, and free space.
When I print the line out on with a one line print statement,
it works:
printf ("%-18s %-5s %5d %5d\n",$disk, $Disks{$disk}[0],$Disks{$disk}[1],$D
isks{$disk}[2]);
results in:
[[display snipped]]
/dev/dsk/c7t1d0 vg04 4384 288
/dev/dsk/c7t1d1 vg05 4384 16
[[display snipped]]
However, when I throw in a newline to try & keep the code
readable, I get the array pointer on one of the variables only...
printf ("%-18s %-5s %5d %5d\n",$disk,\
$Disks{$disk}[0],$Disks{$disk}[1],$Disks{$disk}[2]);
results in:
[[display snipped]]
/dev/dsk/c7t2d7 SCALAR(0x40060b2c) 4384 16
/dev/dsk/c8t3d0 SCALAR(0x40060b68) 4384 288
[[display snipped]]
So, I have two questions:
1. Why does it work on one line and not on two?
2. How do I dereference the array variable? I've been poking
around in various books but haven't got it yet.
Thanks for any help/hints.
Doug
--
--------------------
Douglas K. O'Leary
Senior System Admin
dkoleary@mayspeh.com
dkoleary@wwa.com
--------------------
------------------------------
Date: Fri, 20 Nov 1998 14:29:10 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: HELP: how to prompt for input from command line?
Message-Id: <F2q5Kn.2tK@world.std.com>
Marty Blase <mblase@ncsa.uiuc.edu> writes:
>The subject says it all, really. I need to step through an existing data
>file and prompt the user to enter a new value in the row of data,
One thing to point out that hasn't been in any of the replies so far.
If you want input from the processes controlling tty, no matter how
the standard input stream has been redirected, Open "/dev/tty" (on
Unix, "CON" on Win32) and read from there.
On the other hand, only use this for good reason. Someone may want to
later automate your script by feeding input to STDIN, and would be
annoyed at the hoops they have to jump through to make a pseudo tty to
communicate through your program.
Also, beware of the articles that suggested reading from the null
filehandle (Using the <> construct.) It will read from files on the
command line if present instead reading from STDIN. (I'd assume that
the data files you are altering are specified on the command line)
--
Andrew Langmead
------------------------------
Date: Fri, 20 Nov 1998 15:56:02 GMT
From: dturley@pobox.com
Subject: Re: Help:load unix ls>@array for use in cgi list box
Message-Id: <7343e8$p92$1@nnrp1.dejanews.com>
In article <365558F3.5352ED8B@bt.com>,
hamlinm@boat.bt.com, mark@dimitrinet.demon.co.uk wrote:
> I want to display a list of files from a directory in a html list box using a
> perl cgi. This must have been done a million times by now so has anyone got
> anything handy they could e-mail me to save
> me the time?
>
Here's a snippet that does that:
#!/usr/local/bin/perl
use CGI qw/:standard :netscape/;
use strict;
my $FILE_DIR = '\path\to\your\file';
chdir($FILE_DIR) || die "can't get file list: $!\n";
my @files = grep { !/^\./ }<*>; #avoid "." and ".." files
print start_form,
scrolling_list(-name=>'files',
-size=>5,
-values=>[@files]),
end_form;
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 20 Nov 1998 16:06:50 GMT
From: dave@mag-sol.com
To: mark.c.hamlin@bt.com
Subject: Re: Help:load unix ls>@array for use in cgi list box
Message-Id: <73442a$q22$1@nnrp1.dejanews.com>
In article <365558F3.5352ED8B@bt.com>,
hamlinm@boat.bt.com, mark@dimitrinet.demon.co.uk wrote:
> Hi all,
>
> firstly - I use comminicator for my news client, are my messages still not
> ideally formatted for NGs? Wordwrap - 80 (I can't seem to turn it off)with
> 8-bit text only.
Seems much better now. Thanks.
> I want to display a list of files from a directory in a html list box using a
> perl cgi. This must have been done a million times by now so has anyone got
> anything handy they could e-mail me to save
> me the time?
Hell, it's Friday afternoon and I'm feeling generous. Try something like this:
#!/usr/local/bin/perl -w
use strict;
use CGI;
my $pathname = '.';
my @files;
chomp(@files = qx/ls $pathname/);
my $page = CGI->new;
print $page->header, "\n";
print $page->start_html(-title=>'Directory List Sample');
print $page->h1("Files in directory: $pathname"), "\n";
print $page->p(join $page->br, map {$page->a({-href=>"$_"},$_)} @files), "\n";
print $page->end_html, "\n";
> You might remember I had a problem with the Shell command causing a
Segmentation
> Fault. I never resolved this, but got a workaround with the system function.
> I'm don't know how to use system or exec to pull data into an array, exec also
> seemed to prevent any further output in my cgi.
> I was advised about the my function but can't figure out the basics. ie what
is
> the correct version of the following.
>
> my @list = "ls $pathname"; #pull in listin of selected dir
> print @mylist; #complete ls
> print $mylist[1..5]; #first five files
As shown above it's
my @list = qx/ls $pathname/;
although
my @list = `ls $pathname`;
will also work (which may be what you were getting confused with).
hth,
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: Fri, 20 Nov 1998 16:33:11 GMT
From: dturley@pobox.com
Subject: Re: Help:load unix ls>@array for use in cgi list box
Message-Id: <7345k6$rdp$1@nnrp1.dejanews.com>
In article <7343e8$p92$1@nnrp1.dejanews.com>,
dturley@pobox.com wrote:
> my $FILE_DIR = '\path\to\your\file';
ACK! Been sitting at this windoze machine too long. :-(
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 20 Nov 1998 15:03:18 GMT
From: wmorgan@nswc.navy.mil (Bill Morgan)
Subject: How do you pass parameters to Perl script from HTML #exec statement?
Message-Id: <1998Nov20.150156.20573@relay.nswc.navy.mil>
I am running the Netscape Enterprise v3.5 web server on an NT 4.0 platform. I
am calling a Perl script from an HTML file using the #exec statement.
For example, <!--#exec cgi="/cgi-shell/my_script.pl" -->
I need to pass a parameter to the Perl script from the #exec line, but I
cannot figure out how to do it! I need to know the proper syntax for passing
parameters from #exec, as well as how to capture the parameter name and value
in the Perl script.
I would be very happy if someone could share the secret with me. Please email
any replies as well as posting to this group. Thanks very much!
---------------------------------------------------------------------------
William E. Morgan NAVAL SURFACE WARFARE CENTER
Code N84 email: wmorgan@nswc.navy.mil
17320 Dahlgren Rd. phone: (540)653-6088
Dahlgren, VA 22448 fax: (540)653-1810
------------------------------
Date: Fri, 20 Nov 1998 13:43:38 GMT
From: dturley@pobox.com
Subject: Re: HTTPS - I cannot find a module on CPAN for this.
Message-Id: <733rm6$i0a$1@nnrp1.dejanews.com>
In article <36547936.BB62D616@keane.com>,
Joseph DuBois <jdubois@keane.com> wrote:
> Well met,
>
> I am looking for a module to work with a HTTPS server. I looked
> on CPAN, but could not find either by catagory or module. Am I looking
> for the wrong thing, or is there another way to do this.
If I understand your question, you are looking at this incorrectly. HTTPS is
basically a protocol for encrypting transmissions between a client browser
and the web server. Calling a URL that starts with https simply uses secure
socket layer (SSL) to encrypt the transmissions. (If SSL is enable on the
server.) Your perl script is no different here than when it is called via
http (non-secure.) There may be some file permissions settings that need to
be different depending upon the certificate setup. For example, suppose you
have a file upload script, you may access it like:
http://www.mydomain.com/cgi-bin/upload.cgi
if you instead entered:
https://www.mydomain.com/cgi-bin/upload.cgi
the the browser and the server would agree on an encryption scheme and the
data stream would be encrypted.
hope this help, or at least is not totally of base,
cheers,
david
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 20 Nov 1998 13:25:50 GMT
From: richm@ucesucks.mulveyr.roc.servtech.com (Rich)
Subject: Re: I download ActiveState but don't understand how to install it on Win98
Message-Id: <slrn75arch.bi3.richm@ll.aa2ys.ampr.org>
On Thu, 19 Nov 1998 20:55:38 -0500, Sylvain Lavigne <proband@cam.org> wrote:
>Hi!
>I download ActiveState but don't understand how to install it on Win98.
>I supposed I have to play around with the registries but don't know
>exacly how to doit to make it work.
>I am using Netscape Communicator, do I need to configure other things
>there?
>So, what is the best procedure and fastest procedure to make it work.
>
Well, you could try the bold step of running the file you
downloaded...
- Rich
--
Rich Mulvey
My return address is my last name,
followed by my first initial, @mulveyr.roc.servtech.com
http://mulveyr.roc.servtech.com
Amateur Radio: aa2ys@wb2wxq.#wny.ny.usa
------------------------------
Date: Fri, 20 Nov 1998 16:52:46 GMT
From: henlif@elsfl.com (Henry Lifton)
Subject: NDBM Size
Message-Id: <7346lk$4qf$1@supernews.com>
The documentation for NDBM confuses me a little.
The docs in AnyDBM_File.pm say that the NDBM has a 4k size limit; but the NDBM
man page says 1k.
Does anyone know the answer?
Thanks
Henry Lifton
------------------------------
Date: 20 Nov 1998 16:57:20 +0100
From: haakon.alstadheim@sds.no
Subject: Re: Need equivalent to a sh's export command.
Message-Id: <u1zmymk67.fsf@sds.no>
[...]
> I was confusing export with bash's source command.
> Given a file like .profile, you can mod it and then do:
> . ~/.profile
> and all of the export commands get reflected into the
> calling process' environment.
[...]
Say you have ./profile.pl that does the same in perl as ./profile does
with shell commands. Then this is equivalent from a perl
script:
do "./profile.pl";
the changes to env-vars persist until the perl-script which did the
do :-) exits.
If you need to affect, say, a bash shell with env changes from a perl
script, have the perl script print shell commands to stdout and do:
$ profile.pl >./tmp.txt
$ . ./tmp.txt
i.e evaluate the output from the perl script.
You might be tempted to try:
$`profile.pl`
but this (I believe) will spawn a new shell
to evaluate the backticks, so it will not work.
I dont run bash (NT :-( ), so this is untested.
------------------------------
Date: Fri, 20 Nov 1998 12:40:15 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: PERL for windows 95/NT
Message-Id: <3655632F.4EB771DE@technologist.com>
Sreenivas wrote:
>
> Hi,
>
> I am new to PERL. I want to know where can I get PERL for windows 95/NT.
>
> Please help.
Try http://www.activestate.com/ActivePerl/
With Perl, please remember to ALWAYS start at http://www.perl.com in the
future. Perl.com has so much information - it will answer most of your
questions...
Good luck!
Brent
--
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Fri, 20 Nov 1998 08:18:04 -0500
From: "AmD" <Allan@due.net>
Subject: Re: PERL for windows 95/NT
Message-Id: <733ptc$h8f$1@camel29.mindspring.com>
Sreenivas wrote in message <3654FD6F.809F1997@sns.com.sg>...
>Hi,
>I am new to PERL. I want to know where can I get PERL for windows 95/NT.
>Please help.
>Thanks
>Sreenivas
>email:sreenivas@sns.com.sg
Get thee to:
http://www.activestate.com/ActivePerl/
The end of your quest is at hand.
AmD
------------------------------
Date: Fri, 20 Nov 1998 14:18:10 GMT
From: clay@zeddcomm.com (Clay Reimer)
Subject: PerLDAP Module Help!
Message-Id: <365579c9.5716111@news.nf.sympatico.ca>
Hi all
I recently installed the PerLDAP module on our NT server. When I try
(use Mozilla::LDAP::API ) I get two errors. The first says that NT
can't find NSLDAPSSL32V30.dll then when I get rid of that window I get
another error that says :
Can't load 'C:\PERL\site\lib/auto/Mozilla/LDAP/API/API.dll' for module
Mozilla::LDAP::API: load_file:One of the library files needed to run
this application can not be found at C:\PERL\lib/Dynaloader.pm line
168.
I am using the ActiveState Perl build and the PerLDAP module from
ActiveState and am running Netscape Enterprise Server 3.
I would appreciate any input on this problem.
Thanks
Clay Reimer (clay@zeddcomm.com)
------------------------------
Date: 20 Nov 1998 15:11:45 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: PerLDAP Module Help!
Message-Id: <slrn75b26f.hbl.randy@theory.uwinnipeg.ca>
On Fri, 20 Nov 1998 14:18:10 GMT, Clay Reimer <clay@zeddcomm.com> wrote:
>Hi all
>
>I recently installed the PerLDAP module on our NT server. When I try
>(use Mozilla::LDAP::API ) I get two errors. The first says that NT
>can't find NSLDAPSSL32V30.dll then when I get rid of that window I get
>another error that says :
>
>Can't load 'C:\PERL\site\lib/auto/Mozilla/LDAP/API/API.dll' for module
>Mozilla::LDAP::API: load_file:One of the library files needed to run
>this application can not be found at C:\PERL\lib/Dynaloader.pm line
>168.
Hi,
In other contexts I've seen similar messages. What worked then is
to put the dll file used by the module in a directory contained in the
PATH that the script uses. It may be that this PATH is more restrictive
than the one you're using in a command shell.
--
Best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: Fri, 20 Nov 1998 13:01:23 GMT
From: dave@mag-sol.com
Subject: Re: Please help on getting username
Message-Id: <733p6u$fvu$1@nnrp1.dejanews.com>
In article <yV652.348$ay.12866@news.connectnet.com>,
"Rusty Williamson" <rwilliamson@uno.gers.com> wrote:
> Hi,
>
> I know I saw something on getting the username, the effective and real user
> ID as well as group information but I just can't find it and the obvious
> stuff is not working. Can someone please point me in the right direction.
Real and effective user ids are in $< and $> respectively.
There are a number of get{something}uid functions that return other useful
user info given a uid.
hth,
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: Fri, 20 Nov 1998 10:16:48 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Posting FROM Perl
Message-Id: <fl_aggie-2011981016490001@aggie.coaps.fsu.edu>
In article <3654ED8D.801C799A@gol.com>, ariste@gol.com wrote:
+ any ideas?
Yes:
use LWP;
James - the LWP module on CPAN
------------------------------
Date: Fri, 20 Nov 1998 11:23:42 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: Put your options list in a file, trick for the novices
Message-Id: <F2pwzI.694@csc.liv.ac.uk>
In article <3654CF6D.4C29F47B@cam.org>,
Sylvain Lavigne <proband@cam.org> writes:
> Stop handwriting all your options. use this instead. When you need to
> add another option
> you just add it to the file. You don't need anymore to code it on your
> script.
Great idea, but you can go one beter than this and write it into a module
and use a Tie Hash or Tie Array. Makes life woderfully easy once tyou get
it right. Then you just add it to every prog where you need it like this.
use MyTieHash;
(my tie %mth = "MyTieHash", $path, $file_name) ||
die "Can't tie to $path/$file_name: $!";
Then you just use it like an ordinary hash, but the beuty is you can have
values associated with the tag names. eg.
New-York:New York
Virginia:Washington DC
etc...
And there is a great example in the perldoc amd blue camel.
Or if you want, email me and I will send you the working code with cacheing
to cut down on file access, developed from the camel example. I must admit I
use config files a lot, makes it easy to change values with out wading
through the code, and this is a God send.
>
> # sample cities.dat, make a flat file with the cities, this will be used
> as options list
>
> cities.dat
>
> New-York
> Washington
> New-Jersey
> Miami
>
>
>
[code snipped]
my code is too long really for including here, and if people want Sylvain's
code they can read the original post anyway.
> from: Sylvain Lavigne
>
>
--
--
Ian J. Garlick
<ijg@csc.liv.ac.uk>
<postmaster@merseymail.com>
Indifference will be the downfall of mankind, but who cares?
------------------------------
Date: Fri, 20 Nov 1998 14:41:12 GMT
From: jschueler@detroit.usweb.com
Subject: puzzler
Message-Id: <733v23$l9i$1@nnrp1.dejanews.com>
Is there a good trick for transposing a two dimensional array? That is,
combine a two dimensional array into a one dimensional array columnwise: 1st
element/1st row followed by 1st element/2nd row, etc. There must be some way
to streamline what I wrote.
The following code prints out:
fred
george
homer
barney
judy
lisa
elroy
bart
------------------ begin code --------------------
#! /usr/bin/perl5
my @LOL = (
[ "fred", "barney" ],
[ "george", "judy", "elroy" ],
[ "homer", "lisa", "bart" ],
) ;
my $IDX ;
my @RETVAL = () ;
while ( @LOL ) {
shift @LOL while ( @LOL && ! @{ $LOL[0] } ) ;
for ( $IDX = 0 ; @LOL && @{ $LOL[$IDX] } ; $IDX++ ) {
push( @RETVAL, shift @{ $LOL[$IDX] } ) ;
}
}
print join "\n", @RETVAL ;
print "\n" ;
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 20 Nov 1998 10:04:27 -0600
From: forrest reynolds <dropzone@mail.utexas.edu>
Subject: reset one variable?
Message-Id: <36559306.3F53B8A1@mail.utexas.edu>
Hello,
I'm looking in the Camel book at "reset".... it doesn't
mention resetting
just one variable. Is this possible without using:
$var = "" ;
Thanks ,Forrest
------------------------------
Date: Fri, 20 Nov 1998 11:29:00 -0500
From: "AmD" <Allan@due.net>
Subject: Re: Scope question for Perl
Message-Id: <7345cj$qfi$1@camel29.mindspring.com>
John Porter wrote in message <36549615.8E4131BE@min.net>...
[snip of uselss info]
>You're being sarcastic, but it worked for me!
John,
Just to be clear sarcasm was not my intent. The original statement just
struck me as humorous and I sort of went with it. Kind of jamming to the
riff as it were. Hey, my works for me too, and often keeps me happy :-).
In fact I think I will make it my new mantra. Off to chant.
Myyyyyyyy.... Myyyyyyyy...... Myyyyyyy...........
AmD
------------------------------
Date: Fri, 20 Nov 1998 10:27:17 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: scripts similar to hotmail
Message-Id: <F2puDI.40u@csc.liv.ac.uk>
In article <364DCB23.9E1F8D3E@usa.net>,
CTT <00000ctt@usa.net> writes:
> I'd like to creat a web based email system like hotmail in my server, i
> know how to do the pop3 mail stuff in perl, but i dont know how to do
> the add user stuff in unix.....what command should i use in order to
> creat a new user (with email account)?
>
Your going to have fun unless your root. Even then it's not a good idea as
you are giving people actual accounts on your server. What you need to do is
hack a POP3 server to handle mail only accounts, ie a special type of account
that just consists of a single file. You then need to come up with a script
to handle creating the account and adding the right entries to a password
file (not your system /etc/passwd file but a similar one) after that you need
a whole load of scripts to handle the admin, like delete an account, bar an
account, etc.... You really sure you want to continue?
I am doing something similar but someone else here wrote the admin scripts
and hacked the variuos POP and passwd config stuff, that's why I know what
to do but not how to. I will probably be qualified and able to do this in
about another 2 years, I would think. (Or sooner if someone holds a gun to
my head, afterall necessity is the mother of invention)
The real clincher for me though, why you propably don't want to try this,
unless you are a really clued up UNIX admin type, is the one fact I left out.
You have to hack sendamil as well, or at the very least configure it right.
System admins spend years grappling with this beast, and most will still
admit they don't know all of it's ideocyncracies (sp?).
That any help?
--
--
Ian J. Garlick
<ijg@csc.liv.ac.uk>
Indifference will be the downfall of mankind, but who cares?
------------------------------
Date: Fri, 20 Nov 1998 14:22:55 GMT
From: "john lampe" <j_lampe@bellsouth.net>
Subject: Re: Single word ouptu from aa array
Message-Id: <3Xe52.152$D24.433930@news1.atl>
Peter Moore wrote in message <732v3p$7rf$1@supernews.com>...
>
>MSmith wrote in message <0%Mx1.338$ML4.1093024@news4.mia.bellsouth.net>...
>>Im new to Perl. I'M trying to place a file, a txt file, into an
array..then
>>print out the first character of the first line..and then the second
>>character....etc..but IM having a bit of trouble. IM only able to print
>out
>>a line at a time:
>>
>>open (INFILE, "c:\\csv\\cpu_in\\test.txt");
>>@csvfiles = <INFILE>;
>>close (INFILE);
>>print @csvfiles[0];
I'm a newbie as well but you can also use
open (INFILE, "c:\\csv\\cpu_in\\test.txt");
while (<INFILE>) {
my (@temp) = split (//, $_);
push (@csvfiles, \@temp);
}
close (INFILE);
Now...@csvfiles[0][0] should point to just the first char of your text file.
I'm sure there's a much better way, and I'm sure someone will alert us to
this ;)
john
------------------------------
Date: Fri, 20 Nov 1998 12:51:02 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Strange Failure
Message-Id: <365565B6.22C7185@technologist.com>
ed_c@my-dejanews.com wrote:
>
> Hello all:
>
> open( FILENAME, "file.txt );
> @Records = <FILENAME>;
> $Num = @Records;
>
> For some reason, $Num always is 0, no matter how many lines are in the file.
> For what it's worth I'm on NT4 using IIS. Does anybody see anything strange
> with this?
>
> Any help would be appreciated.
Ok, I am hoping that the missing " after the .txt is a typo, as written
the program shouldn't get through the compile stage.
- You are not checking the result of your open command. If an error
occurs, which I'd bet my short has, Perl is not going to complain about
it because you didn't tell Perl to.
Change the open line to:
open( FILENAME, "file.txt" ) || die "An error occured opening the file!
Error: $!\n";
Note that the variable $! will contain the error that occured, that is
why it is in the line above.
On NT, the filename "file.txt" which you are _expecting_ to be read from
the same directory as the program is not. To fix it, add the whole path
and drive letter like so:
open( FILENAME, "c:/inetpub/scripts/file.txt" ) || die "An error occured
opening the file! Error: $!\n";
Finally, please remember to always, always, always, always, always,
always, always, always check the results of your file operations!
Good luck!
Brent
P.S. You guys did pretty well containing your anti-NT-isms :-)
--
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: 20 Nov 1998 09:46:16 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Strange Failure
Message-Id: <733vbo$ro2@panix.com>
In <731vog$6e$1@nnrp1.dejanews.com> ed_c@my-dejanews.com writes:
>I am relatively new to PERL but so far I love it. I've written a small
>guestbook application and am experiencing a strange problem I hope someone can
>help me with. When I add to the guestbook, I want to put the newest record at
>the front of the file. I try to find the number of records in the file by
>writing:
>open( FILENAME, "file.txt );
open FILENAME, "file.txt" or die "Can't open file.txt: $!\n";
>@Records = <FILENAME>;
# I hope file.txt isn't a very large file!
>$Num = @Records;
$Num = $#Records;
--
Clay Irving
clay@panix.com
------------------------------
Date: 20 Nov 1998 09:51:09 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Strange Failure
Message-Id: <733vkt$s2c@panix.com>
In <733vbo$ro2@panix.com> clay@panix.com (Clay Irving) writes:
>In <731vog$6e$1@nnrp1.dejanews.com> ed_c@my-dejanews.com writes:
>>I am relatively new to PERL but so far I love it. I've written a small
>>guestbook application and am experiencing a strange problem I hope someone can
>>help me with. When I add to the guestbook, I want to put the newest record at
>>the front of the file. I try to find the number of records in the file by
>>writing:
>>open( FILENAME, "file.txt );
> open FILENAME, "file.txt" or die "Can't open file.txt: $!\n";
>>@Records = <FILENAME>;
># I hope file.txt isn't a very large file!
>>$Num = @Records;
>$Num = $#Records;
Doh! This should be:
$Num = $#Records + 1;
--
Clay Irving
clay@panix.com
------------------------------
Date: Fri, 20 Nov 1998 08:00:42 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Strange Failure
Message-Id: <MPG.10bf3201cbec42e398991a@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <733vkt$s2c@panix.com> on 20 Nov 1998 09:51:09 -0500, Clay
Irving <clay@panix.com> says...
> In <733vbo$ro2@panix.com> clay@panix.com (Clay Irving) writes:
> >In <731vog$6e$1@nnrp1.dejanews.com> ed_c@my-dejanews.com writes:
...
> >>$Num = @Records;
>
> >$Num = $#Records;
>
> Doh! This should be:
>
> $Num = $#Records + 1;
Doh! Which is *identical* semantically to the correct statement that
you "corrected" (except if one has messed with $[ -- which is frowned
upon -- in which case the original statement still gives the correct
size for the array, while the one using the "highest index" doesn't).
So your "correction" is messier, marginally more prone to error, and
(presumably) slower. Good try...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 20 Nov 1998 16:06:49 GMT
From: c_b9209@my-dejanews.com
Subject: Sum by group
Message-Id: <73442a$q21$1@nnrp1.dejanews.com>
Hi
I want to sum by group in a data file were the first column has groups values
and other has regular values. The data file is really huge
here is a script for small file but it doesn't works for a big one,please can
anyone help me this problem make me crazy
\Claes
sub test{
open IN, "$utdata\\tabel.dat" or die "can't open in: $!";
while (<IN>){
($var,@DATS)=split(" ",$_);
$suml{$var} = [ @DATS ];
$sum0{$var}+= $DATS[0];
$sum1{$var}+= $DATS[1];
$sum2{$var}+= $DATS[2];
$sum3{$var}+= $DATS[3];
$sum4{$var}+= $DATS[4];
$ant{$var}+=1;
}
foreach $key (sort(keys %sum0)) {
print "$key = $ant{$key} $sum0{$key} $sum1{$key} $sum2{$key} $sum3{$key}
$sum4{$key}\n";
}
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 20 Nov 1998 07:39:27 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Bill McGonigle <bill@artoo.hitchcock.org>
Subject: Re: trouble storing array of objects
Message-Id: <3655710F.F18A12C6@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
Bill McGonigle wrote:
[snip]
> # Then I tack it on to the patient
>
> $patient->add_lab($new_lab);
>
> # which calls
>
> sub add_lab {
>
> my $self = shift;
> my $temp = shift;
>
> $self->{labs} = [$self->{labs},$temp];
^^^^^^^^^^^^^ <- this is a ref, _not_ the array
values
try:
push @{ $self->{labs} }, $temp;
> return $self->{labs};
> }
>
> # The happens n times. Later I want to print them out. Having:
>
> sub get_labs {
> my $self = shift;
> return $self->{labs};
> }
>
[snip]
from you Dumper output, you can tell that you are creating a new
anonymous array each time you call add_lab(), with the first array value
being the old $self->{lab} which a ref to yet another anonymous array,
hence the cascading Dumper output.
HTH.
-TK
------------------------------
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 4264
**************************************