[11857] in Perl-Users-Digest
Perl-Users Digest, Issue: 5457 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 22 16:07:28 1999
Date: Thu, 22 Apr 99 13:00:22 -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 Thu, 22 Apr 1999 Volume: 8 Number: 5457
Today's topics:
AIX4.3, perl5.004, and "waitpid"? <dme7@cornell.edu>
Any free CGI hosting allow running similar to UNIX ? <austin95002887@yahoo.com>
cookie being shown in browser <rgl34@hotmail.com>
Database file locking... <Not@gonna.tell>
Re: Database file locking... <tchrist@mox.perl.com>
Re: DJGPP Port for DOS (Was Re: for (my $i;;) doesn't w (Bart Lateur)
Extracting fields to scalar variables? <mmione@tns-inc.com>
Re: FAQ 4.15: How do I find yesterday's date? <dgris@moiraine.dimensional.com>
Re: Help! Error message when using C-comment stripper f <aqumsieh@matrox.com>
Re: help! file upload from web <cassell@mail.cor.epa.gov>
Help: Problem capturing cntl-c signal in perl script <ecastle@nuance.com>
Re: how do you pass hashes to functions? <jglascoe@giss.nasa.gov>
How to read a NT mapped driver from CGI ? <qsun@kitco.ca>
Re: How to read the modification date of a file? (Abigail)
Re: http related module ? <cassell@mail.cor.epa.gov>
Re: Illegal seek (this makes no sense to me =) (Clinton Pierce)
Re: Is there a shorter way? (Larry Rosler)
Re: last item in associative array. (Andrew Allen)
Re: newbie with a "howto" question <cassell@mail.cor.epa.gov>
Re: newbie with a "howto" question <tbriles@austin.ibm.com>
passing 2 arrays into... hallian@hotmail.com
Re: Reading C binary data from disk <uri@sysarch.com>
Re: Reading C binary data from disk <tchrist@mox.perl.com>
Reading in password from <STDIN> <mgcook@ic.delcoelect.com>
Re: The Future of Tk? (Kaz Kylheku)
Re: The Future of Tk? <oakley@channelpoint.com>
Re: To trim right blanks from a field. (Larry Rosler)
Re: Verifying text in a string <jglascoe@giss.nasa.gov>
Re: Where can I get a CGI modul <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Apr 1999 15:40:38 -0400
From: Doug Elias <dme7@cornell.edu>
Subject: AIX4.3, perl5.004, and "waitpid"?
Message-Id: <86ogkgsatl.fsf@research.johnson.cornell.edu>
G'day ...
I have a piece of code that runs fine under Solaris6/perl5.005_02, but
when I run it under AIX4.3/perl5.004 it doesn't work properly, and the
problem statement involves a non-blocking "waitpid" which apparently
isn't receiving notification of the termination of the child process...
is this a known problem for that implementation-mix? I've asked that
the latest version of perl be obtained and installed, but I'm just
trying to verify the actual problem.
Thanks,
doug
--
Doug Elias, Ph.D.
__|_ Internet: doug@research.johnson.cornell.edu
dr _|_)oug USmail: Director of Technology
(_| Parker Center/Johnson Grad. School of Mgmt.
(_|__lias 302 Sage Hall/C.U./Ithaca/N.Y./14853-6201
| Phone: 607-255-3521 Fax: 607-254-4590
------------------------------
Date: 22 Apr 1999 19:17:05 GMT
From: "Austin Ming" <austin95002887@yahoo.com>
Subject: Any free CGI hosting allow running similar to UNIX ?
Message-Id: <7fnsjh$pum$18@newsread.f.de.uu.net>
Any free CGI hosting allow running similar to UNIX ?
I really don't want to run CGI using FTP uploading!
I want to run CGI and learn more it in UNIX environment.
------------------------------
Date: 22 Apr 1999 19:17:03 GMT
From: "Robert Long" <rgl34@hotmail.com>
Subject: cookie being shown in browser
Message-Id: <7fnsjf$pum$15@newsread.f.de.uu.net>
I have a rather complicated CGI that uses "plug-ins", that is it passes the
parsed information from a form on to a small script. I have a "plug-in" that
delivers a cookie, however, the cookie is displayed in the browser window.
I am using CGI.pm to do this, but I'm afraid I am not using it
correctly....below is the code that is delivering the cookie.
use CGI qw(:standard);
$debug=0;
print header if $debug;
print "Testing<br>" if $debug;
$query = new CGI;
%destination = qw(RAuth
http://www.rlong.com/legal/trademarp/pusage_logo/download_instr.html
rlongDALAN http://support.rlong.com/nav/license.htm
rlongDADMI http://support.rlong.com/nav/license.htm
rlongDAMBA ftp://ftp.rlong.com/pub/nic/bw98util.exe
rlongDAMPC
http://www.rlong.com/client/mcd/technology/damobile/software.html
);
foreach $cookie (keys %destination) {
print "\$cookie is $cookie\n" if $debug;
$dest = param('Dest');
if ($cookie eq $dest){
if ($cookie = $query->cookie($cookie)) {
print "\$cookie is now $cookie\n" if $debug;
$gotit = $destination{$cookie};
print "<H1>got it $gotit</H1><H1>destination $destination{$cookie}</H1>"
if $debug;
}
}
}
if ($gotit ne "") {
print "Location: $gotit\n\n";
exit;
} else {
print "Error";
}
------------------------------
Date: Thu, 22 Apr 1999 15:37:51 -0400
From: "Doug Crabtree" <Not@gonna.tell>
Subject: Database file locking...
Message-Id: <7fntse$lj2$1@nntp8.atl.mindspring.net>
I have a couple of functions written that will open a database file and
read/write data to it. I also have a function that will pack the data to
minimize the file after deletions and changes are made (run once in a blue
moon). My question is, using MLDBM, do I have to worry about two users on a
web site reading/writing from this file at the same time?
This is being done on a UNIX machine.
TIA,
Dug
------------------------------
Date: 22 Apr 1999 13:52:32 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Database file locking...
Message-Id: <371f7e00@cs.colorado.edu>
In comp.lang.perl.misc, "Doug Crabtree" <Not@gonna.tell> writes:
:My question is, using MLDBM, do I have to worry about two users on a
:web site reading/writing from this file at the same time?
Private reply sent via email to avoid clogging newsgroup. Enjoy.
--tom
--
I'm sure that that could be indented more readably, but I'm scared of
the awk parser. --Larry Wall in <6849@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 22 Apr 1999 19:17:06 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: DJGPP Port for DOS (Was Re: for (my $i;;) doesn't work like I think it should)
Message-Id: <7fnsji$pum$19@newsread.f.de.uu.net>
Jonathan Stowe wrote:
>Yes 5.005.02 is the version that is currently available from the djgpp
>archives.
How bizarre. I paid a visit to CPAN. The only binary distribution there
is still 5.004. It does say, however:
> Starting from Perl 5.005 the MS-DOS support has been integrated to the
> Perl standard source code distribution.
So everybody has to build their own binary now? Even if they end up with
the SAME binary, all over the world?
Then I went to ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/ and
there it is: perl552b.zip (2448 kb). Oh, and the source code is there
too, if you want it: perl552s.zip, 3775 kb.
I thought CPAN was supposed to be the main distribution?
Bart.
------------------------------
Date: Thu, 22 Apr 1999 18:50:38 GMT
From: mike <mmione@tns-inc.com>
Subject: Extracting fields to scalar variables?
Message-Id: <7fnr1t$v9c$1@nnrp1.dejanews.com>
All,
I am looking for a way, using Perl, to perform line by line pattern matching
of fields from two different hosts files called "hosts.new" and
"hosts.current" - the purpose is to update the /etc/hosts file
(hosts.current) with newly added hosts from (hosts.new).
Both files were preformatted in the following manner:
hosts.new
field 1 field 2 field 3
line 1-> xxx.xxx.xxx.xxx <TAB> hostname
hosts.current
field 4 field 5 field 6
line 1-> xxx.xxx.xxx.xxx <TAB> hostname
What I need to do is perform a series of comparisons (line by line) testing
equality from field 1 and field 4, field 3 and field 6. There is more to it
but basically what I am looking for is a way to cut field 1,4,3,6 to a
pattern space, possibly a scalar variable and do a series of comparisons.
In a shell environment I would normally use awk '{print $1 or $2} but I have
not found this equivalent in Perl.
Can anyone help?
Mike-
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Apr 1999 19:16:59 GMT
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: FAQ 4.15: How do I find yesterday's date?
Message-Id: <7fnsjb$pum$12@newsread.f.de.uu.net>
David Cassell <cassell@mail.cor.epa.gov> writes:
> Perhaps Larry Rosler would like to contribute his DST-safe version
> to the FAQ? I think he already sent a copy to Dan Grisinger's
> script archive...
I've got Russ Allbery's yesterday function.
http://moiraine.dimensional.com/~dgris/cgi-bin/pfr?func=yesterday&type=exact
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Thu, 22 Apr 1999 13:31:40 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Help! Error message when using C-comment stripper from perlfaq
Message-Id: <x3yiuaolfyb.fsf@tigre.matrox.com>
GoodfriB@jntf.osd.mil (James R. Goodfriend) writes:
> When I run this using -w I get the following error message:
>
> Use of uninitialized value at (program) line 19, <CFILE> chunk 1.
>
> ...this shows up about 20 times. Can anyone tell me what I can do to
> suppress this damn message? It's driving me slowly insane...
I have a wacky idea. Find out what variable(s) you're trying to access
on line 19 and is/are undefined, and fix your code.
Another idea would be to turn off the monitor.
------------------------------
Date: Thu, 22 Apr 1999 12:17:15 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: help! file upload from web
Message-Id: <371F75BB.87D49ED5@mail.cor.epa.gov>
[comp.lang.perl does not exist, and has been dead for years]
[newsgroup cross-post trimmed]
Chris Weiss wrote:
>
> hi all, i've been going at this all day and need help (code to follow). i'm
> sending a file up to the web, and the following is displayed (# denotes
> comments added here):
> [snip]
>
> what is happening is that when i write to the file which i am creating, i'm
> getting character added (\t, i suspect) that is fouling the file. the above
> example consists of a file with 9 lines, a single character on each (28
> bytes). when i save to my file, it becomes 37 bytes, with a blank line
> between each line. the temp file created by CGI does not have the extra
> values added, what i want. my two questions are these:
> [big snip]
Now let me see if I have this right. You're writing Perl code to
FTP a file from an NT box to another machine. Is that other
machine a unix box? And are you fixing the newlines?
In Win32, a newline is represented by a CR/LF combination, while in
unix it's a single character. So you have an 'extra' character at
the end of each line which is messing things up. And if your
file is now on a unix box, you can use 'od' to look at the file and
see what's going on. I think you'll find it's not a \t.
My suggestion is to use NET::FTP to do this, or else FTP it manually
making sure to transfer in ASCII mode rather than binary.
BTW, using the CGI.pm module gets you brownie points. But:
(1) use the -w flag on the shebang line.
(2) use strict; is A Good Thing.
(3) mkdir is looking for an octal mode [0777] instead of a decimal one.
(4) your way of checking the open() leads to extra indentation and
stuff. There are other approaches.
(5) the multiple print() statements can be done with a single here-doc.
(6) that's enough pestering for now... :-)
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: 22 Apr 1999 19:16:58 GMT
From: Eric Castle <ecastle@nuance.com>
Subject: Help: Problem capturing cntl-c signal in perl script
Message-Id: <7fnsja$pum$11@newsread.f.de.uu.net>
I'm trying to add a Control-C interrupt handler to my perl script. I've
looked at verious Perl books and web pages and have not found anything
that describes what I'm seeing.
My script runs a series of executables, some of which are servers and
need to run in the background and the rest are run in the foreground
using the open command.
So the script runs background processes by using the system command
like:
system("program >outfile 2>errfile &")
The script also runs foreground processes by using the open system call
like:
$write_to_child = new FileHandle;
if( open( $write_to_child, | "program >outfile 2>errfile") {
print $write_to_child +(join('\n', @input)) if @input;
close $write_to_child;
}
I send any stdin to the program being run if any input has been given.
So the script spends most of its time running the programs started by
using the open call like above.
I wanted to add a interrupt handler so that if the user presses Cntl-C
at the keyboard the script would then in the Cntl-C signal handler, stop
any background processes that have been started and then exit ( I keep
track of the background processes using ps and their pids and then issue
kill command and already have a subroutine that takes care of all that.
I want to call this subroutine from my signal handler.)
The problem seems to be that when the user hits Cntl-C, my signal
handler in the script doesn't see the Cntl-C, instead it appears the
program being run by the open call gets the signal instead. This causes
that program to exit, but then I don't end up in my signal handler at
all. So the script then goes and runs the next program. Each Cntl-C I
type just ends up killing the current program being run by the open
command. I've even seen the background process I had started earlier get
the Cntl-C's!!! I think in that case though, one of the client programs
is feeding the interrupt signal through to the server its connected to.
What I want to happen is for my script to catch the signal in the signal
handler FIRST, and then it would shut down any running servers and exit
(thereby hopefully ending the program being run by open). Is there some
way for my signal handler to get the Cntl-C signal first and not the
program being run by the open command? Why doesn't the signal go to my
signal handler first?
FYI my signal handler looks like:
sub handle_interrupt {
my $signame = shift;
print "\n received signal SIG$signame\n";
print "\n --- Control-C pressed, cleaning up before exit ------\n";
if( %bg_processes ) {
print "Shutting down background processes....\n";
&stop_all_servers;
}
exit;
}
And of course earlier in the script I have the line:
$SIG{INT} = \&handle_interrupt;
Thanks for any help.
Eric
------------------------------
Date: Thu, 22 Apr 1999 14:51:50 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Dunn One <obinani@popd.ix.netcom.com>
Subject: Re: how do you pass hashes to functions?
Message-Id: <371F6FC6.37DF47F4@giss.nasa.gov>
[posted and cc'd via email]
Dunn One wrote:
>
> I've been trying this and it just doesn't work. Can anyone please help?
> do you use type glob? When I tried to pass the typeglob argument to the keys
> function, I got an error. Please help. Thanks.
my %hash = (one => 1, uno => 1,
two => 2, dos => 2,
three => 3, tres => 3);
# pass our hash using the reference operator, "\"
my $inverted_ref = invert_hash(\%hash);
# dereference the returned hash reference
my %inverted = %$inverted_ref;
sub invert_hash {
my $hash_ref = shift;
# now turn the hash reference into a regular hash
my %hash = %$hash_ref;
my %return = ();
while (my ($k, $v) = each %hash) {
push @{ $return{$v} }, $k;
}
return \%return;
}
# huh? what does this do?
use Data::Dumper qw(DumperX);
print DumperX(\%hash), "\n";
print DumperX(\%inverted), "\n";
Jay Glascoe
--
"If you substitute other kinds of intellectual property
into the GNU manifesto, it quickly becomes absurd."
--Cal Keegan
------------------------------
Date: Thu, 22 Apr 1999 15:17:27 -0400
From: qinqiang sun <qsun@kitco.ca>
Subject: How to read a NT mapped driver from CGI ?
Message-Id: <371F75C7.2A1DB3B1@kitco.ca>
Hello, Everybody
I need to reading file from a mapped driver on our NT network in my
CGI (Perl/C++) script. The CGI script read files from a mapped drives
on windows95 machines successfully but failed to do the same thing from
any driver on any of my NT machines. The script did do the job from dos
window command. Does anybody know the reason ? Please help!
Thanks in advanced!
Jinbai
------------------------------
Date: 22 Apr 1999 19:44:23 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to read the modification date of a file?
Message-Id: <7fnu6n$bbq$1@client2.news.psi.net>
howitgolook (howitgolook@my-dejanews.com) wrote on MMLX September
MCMXCIII in <URL:news:7fnman$qgl$1@nnrp1.dejanews.com>:
-- How can I determine the modification date of a file on a remote server?
You NFS mount the disk and use the stat() command.
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: Thu, 22 Apr 1999 12:24:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: http related module ?
Message-Id: <371F7777.46D2F048@mail.cor.epa.gov>
Ching-Yu Lin wrote:
>
> hello,
> I want to write a WWW client application in perl.
> Are there any http module I can use ?
> Or any sample code to refer to ?
> thanks in advance ,
There are lots of modules, all available at CPAN. But I
can't tell what you are asking for.
Do you want to write Perl code to run on a webserver? If so, look
into CGI.pm
Do you want an HTTP daemon? Do you want HTTP content negotiation?
HTTP status code processing? All these things are available too,
under the HTTP:: hierarchy on CPAN.
HTML? still on CPAN
WWW API interface? ditto
Without more specifics, we can't help you more.
And your question may not really be relelvant to this newsgroup,
even though you want to program in Perl. It depends on the topic.
One of the comp.infosystems.www.* newsgroups might in fact be
more appropriate.
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Thu, 22 Apr 1999 19:27:39 GMT
From: cpierce1@ford.com (Clinton Pierce)
Subject: Re: Illegal seek (this makes no sense to me =)
Message-Id: <371f739e.1918563979@news.ford.com>
[poster cc'd in e-mail]
On 22 Apr 1999 17:10:00 GMT, phukit@enteract.com wrote:
>Clinton Pierce <cpierce1@ford.com> wrote:
>> Unless the open() fails, the contents of $! are indetermininate. Don't
>> use $! to test the success or failure of UNIX system calls.
>
>It doesn't outright fail, but when it closes <SENDMAIL> /usr/sbin/sendmail
>never gets run. That "Illegal Seek" error is the only indication I have
>that something happens between the open and close.
Welcome to UNIX. :-)
The exit status of the open only indicates that the fork() preceeding the
exec() of shell to run the pipeline is successful. Once the fork()
happens, the perl interpreter has no way of knowing what happened to the
pipeline...
...until you close the filehandle. At that time perl does a wait() on the
child that it forked off earlier. The wait will tell perl if the pipeline
did the right thing.
So oddly, to see if a pipeline worked, you need to check the exit status
of the open() AND the close(), examining $! and $? where appropriate.
For more information: see open() and close() in the Blue Camel, chapter 3;
the Perl Cookbook; or the manual pages for perlfunc and perlipc.
Remember though: $! gets set to all kinds of crazy things in perl which
aren't necessarily important except immediately after a system call
failure. To see this try:
perl -MTest -e 'print $!'
$! was set even though nothing went wrong. Don't rely on its value unless
you're using it immediately after a system-call _failure_-- like you're
supposed to.
--
Clinton A. Pierce "If you rush a Miracle Man, you get rotten
clintp@geeksalad.org Miracles." -- Miracle Max, The Princess Bride
http://www.geeksalad.org
------------------------------
Date: Thu, 22 Apr 1999 12:02:33 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Is there a shorter way?
Message-Id: <MPG.118912262f625ff5989915@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <x7aew0d0mh.fsf@home.sysarch.com> on 22 Apr 1999 13:29:58 -
0400, Uri Guttman <uri@sysarch.com> says...
...
> echo '' | perl -pe '$_=sprintf"%-6s",$ENV{USER};y/ /x/'
That's the second answer with 'y'. I love to see 'y' coming into its
own compared with 'tr' -- saving one character!
Just Another sed Hacker (to whom 'y' seems as natural as anything, and
more natural than 'tr' :-).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Apr 1999 19:17:05 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: last item in associative array.
Message-Id: <7fnsjh$pum$17@newsread.f.de.uu.net>
Larry Rosler (lr@hpl.hp.com) wrote:
: Whether or not that is the 'last' element is debatable, as you say. I
: interpreted it as the last value added to the hash.
While we're on the subject of "what the poster _didn't_ want", here's
one idea:
${[%myhash]}[-1];
It certainly is "the last item in [an] associative array [when interpreted
as a list]" ;)
<ducks for cover>
Andrew
------------------------------
Date: 22 Apr 1999 19:17:00 GMT
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: newbie with a "howto" question
Message-Id: <7fnsjc$pum$13@newsread.f.de.uu.net>
derose@my-dejanews.com wrote:
>
> Hello,
>
> I'm new at Perl, and don't really have the patience's to find the answers in
> my books, so I thought I would ask some experts.
And how is it that your time is more valuable than an entire newsgroup
of experts? This doesn't sound very polite. Patience is a virtue,
especially for a programmer. When you hear that LArry Wall described
the three great virtues of a programmer as Laziness, Impatience, and
Hubris, be aware that this is not what he had in mind.
Actually, your questions have basically been answered in the Perl
documentation that cmae with your install. If you don't have the
time to read all 1200 pages of docs, learn to use the really nice
toys that come with the docs. Try the following commands, and
see what niftiness awaits you:
perldoc perldoc
perldoc perl
perldoc -q uniq [or perldoc -q unique]
perldoc -f split
> I have two questions really
> 1. Is there a comparable command or module to unix's uniq? I want to sort and
> uniq a simple text file. I've figured out how to sort it in Perl, but not how
> to uniq it. If I were to do this in shell I would say something like:
> cat $file1 | sort | uniq > $outfile
By now you have tried `perldoc -q uniq' and read the FAQ and found
that it is easy to do in Perl using a hash.
> 2. Is there a module or function that will parse a line in a text file? I
> have a file with four individual columns, and I want to read each line on at
> a time and have each word placed in an individual variable. If I were to do
> this in shell, I would have used awk to parse the lines.
By now you have tried `perldoc -f split' and found that there is at
least one way to do this in Perl. But there are lots of ways.
Read the perlrun manpage and find out about the command line options.
So you could try something like
perl -wane 'print pop(@F), "\n";' filename
and see how Perl does autosplit.
Or you could use the a2p program and see what sort of code you get
if you convert an awk script to a Perl program.
TMTOWTDI.
> If any one could point me in the correct direction, I would appreciate it.
>
> Thank you.
You're welcome.
And remember that in general posters to this newsgroup are expected
to have done their homework first, or else one of the `experts'
may flame them instead of spoon-feeding them. :-)
HTH,
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Thu, 22 Apr 1999 14:30:03 -0500
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: newbie with a "howto" question
Message-Id: <371F78BB.3B2351B7@austin.ibm.com>
derose@my-dejanews.com wrote:
> Hello,
>
> I'm new at Perl, and don't really have the patience's to find the answers in
> my books, so I thought I would ask some experts.
<snipped questions>
> If any one could point me in the correct direction, I would appreciate it.
I would be *shocked* if one of the experts that read this group gives you a
straight answer.
This group is not here to regurgitate documentation that is readily available to
every Perl user.
Try:
perldoc perldoc
perldoc perltoc
and start reading.
- Tom
------------------------------
Date: Thu, 22 Apr 1999 19:21:25 GMT
From: hallian@hotmail.com
Subject: passing 2 arrays into...
Message-Id: <7fnsrf$15u$1@nnrp1.dejanews.com>
hi perlers......
I need to pass two array from one sub routine, into another subroutine. The
array values are dynamic and keep be called by different routines. But I need
to pass them as two array and then read into 2 new arrays. For example
sub routine_main {
statements....
statements....
statements....
&routine_two(@array1,@array2)
}
sub routine_two {
local(@newarray1,@newarray2)=(?,?)
statements....
statements....
statements....
}
How can I read @array1 into @newarray1 and @array2 into @newarray2;
thanks.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 22 Apr 1999 19:17:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Reading C binary data from disk
Message-Id: <7fnsjf$pum$16@newsread.f.de.uu.net>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> I wonder if there isn't a design flaw in the read() or sysread()
LR> functions implemented for the Evil Empire. Analogous to C's fread,
LR> shouldn't they automatically give back all the bytes as they exist on
LR> the external medium, instead of converting "\015\012" pairs to "\n"? An
LR> implicit binmode(), in effect, to help eliminate these recurrent bugs.
LR> The line-at-a-time input operators <> and readline() wouldn't be
LR> affected by this change.
i am no expert on the evil os (thank god!), but i believe perl's binmode
calls a winblows system call to affect its conversion of cr/lf to
\n. this is needed for c programs too as c uses the \n convention. so
having perl's read and sysread do an implicit bin mode makes little
sense. they don't know what the programmer is doing (and if the
programmer is using winblows, he doesn't know what he is doing either
:-), so they can't always turn on binmode.
just trying to help out those poor POB's,
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 22 Apr 1999 19:17:07 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Reading C binary data from disk
Message-Id: <7fnsjj$pum$20@newsread.f.de.uu.net>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
lr@hpl.hp.com (Larry Rosler) writes:
:I wonder if there isn't a design flaw in the read() or sysread()
:functions implemented for the Evil Empire. Analogous to C's fread,
:shouldn't they automatically give back all the bytes as they exist on
:the external medium, instead of converting "\015\012" pairs to "\n"?
Yes, it's a bug, but it's a bug from the Evil One in their C code, and
one apparently we're not allowed to fix it. It's nestled deep down
in the bowels of their hideous run-time system.
I, too, long believed as you believed, so when the light of truth
finally shone upon their profound iniquity, a non-trivail clean-up
job was required to rescue the random documentation (like peropentut),
as well as the ensuing mess on my hardwood floors.
That is not dead which can fternal lie,
and in strange fons, even CP/M may die.
--Abdulw Al-Lhazard
--tom
--
When the dinosaurs are mating, climb a tree. --Steve Johnson
------------------------------
Date: Thu, 22 Apr 1999 14:22:41 -0700
From: "Micah G. Cook" <mgcook@ic.delcoelect.com>
Subject: Reading in password from <STDIN>
Message-Id: <371F9321.672C@ic.delcoelect.com>
I have looked through several man pages and dont see
anything in my only "Learning Perl" book.
I want to read in a users password from <STDIN> but
want to display ****'s while they type it in.
Right now it displays what they type. <-Bad
Apologies if this has been posted before, where do the
post go after they runoff? Is there an archive of post
somewhere? -Micah
I need some more books.
------------------------------
Date: 22 Apr 1999 19:17:02 GMT
From: kaz@ashi.FootPrints.net (Kaz Kylheku)
Subject: Re: The Future of Tk?
Message-Id: <7fnsje$pum$14@newsread.f.de.uu.net>
On Thu, 22 Apr 1999 18:01:27 GMT, Barry Margolin <barmar@bbnplanet.com> wrote:
>In article <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk>,
>Robin Becker <robin@jessikat.demon.co.uk> wrote:
>>I take this completely differently; least astonishment for me is if
>>program X looks and behaves the same way no matter what keyboard, mouse
>>and screen I'm using. As a 'user' of the program X it shouldn't matter
>>what OS/WM is executing the code. I certainly don't want vi or emacs to
>>be different on the mac why should I treat word or excel differently?
>
>I would be very surprised if Netscape on the Macintosh presented a
>Windows-like user interface, rather than adopting the standard Macintosh
I'd be very surprised if even 10% of, say, comp.lang.c gave a damn. The pitiful
dumbfuck who started this thread made a severe mistake in constructing the
Newsgroups: header line, the moment he put in the first comma.
I am setting Followup-to: to comp.lang.tcl.
------------------------------
Date: Thu, 22 Apr 1999 12:38:06 -0600
From: Bryan Oakley <oakley@channelpoint.com>
Subject: Re: The Future of Tk?
Message-Id: <371F6C8E.6631E8F1@channelpoint.com>
Barry Margolin wrote:
>
> In article <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk>,
> Robin Becker <robin@jessikat.demon.co.uk> wrote:
> >I take this completely differently; least astonishment for me is if
> >program X looks and behaves the same way no matter what keyboard, mouse
> >and screen I'm using. As a 'user' of the program X it shouldn't matter
> >what OS/WM is executing the code. I certainly don't want vi or emacs to
> >be different on the mac why should I treat word or excel differently?
>
> I would be very surprised if Netscape on the Macintosh presented a
> Windows-like user interface, rather than adopting the standard Macintosh
> user interface. Most end users don't switch between platforms much, so
> it's more important that all the programs on their system conform to their
> expectations, than that a particular program work the same across different
> platforms.
I would have to agree with that statement. While there are those who
think retaining the same look and feel across platforms is necessary, I
would wager they are in the distinct minority. That's not to invalidate
their position, but merely to put it in context. _Most_ users of
software want a package to look and feel like the other packages on a
given system. I hate, for example, the artsy (-fartsy) graphic programs
that have some weird UI instead of a more traditional UI.
On the other hand, to some degree this is application-dependent rather
than user-dependent. For example, if I were to have a requirement to
write a air traffic control program that had to run on BeOS, MacOS, NT
and *nix, I would think there would be significant advantages to keeping
it 100% identical across all platforms. So, to some degree it depends on
the application, or the targeted user base.
My point being, there's a need in the world for both models. Only, the
model where applications should adhere to native conventions is (I'm
guessing) far and away the most commonly expected model by most users.
Which is why I think using native windows on Tk is a win -- it meets the
needs of the majority (though definitely not all) of the users in the
world.
--
Bryan Oakley mailto:oakley@channelpoint.com
ChannelPoint, Inc. http://purl.oclc.org/net/oakley
------------------------------
Date: Thu, 22 Apr 1999 12:15:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: To trim right blanks from a field.
Message-Id: <MPG.1189152af4b1bbd0989916@nntp.hpl.hp.com>
In article <371F6508.267D9F79@mail.cor.epa.gov> on Thu, 22 Apr 1999
11:06:00 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
> kalash4334@my-dejanews.com wrote:
> > I am looking for a function to trim the right spaces from a field of one line.
...
> > Can someone suggest a solution.
>
> Yes. tr/// will do this for you very nicely. This could also be
> done using a regex, but that will likely be a lot slower than the
> tr solution. tr works like the unix tr(1), only better.
Well, finally. You have resolved the debate about whether 'tr' stands
for 'translate' or 'transliterate'. None of the above. It stands for
'trim'.
:-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 22 Apr 1999 14:59:50 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Verifying text in a string
Message-Id: <371F71A6.EBCF156A@giss.nasa.gov>
[posted and cc'd]
Larry Rosler wrote:
>
> my $Count0a = sub { my $x = () = $rand =~ /[^A-Za-z0-9]/g };
you might find this one interesting:
my $Count0b = sub { my $x = map /[^A-Za-z0-9]/g, $rand };
I'm not sure why, but supplying a list context via map
seems to be more efficient than the "() =" trick.
> I am really surprised that for the 'look at every character but don't do
> anything' cases (the ones with the '1' in their names), the regex is
> noticeably faster than the tr(): about 0.5 sec compared to 0.8 sec.
on my box, I get:
Bool0: 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)
(warning: too few iterations for a reliable count)
Bool1: 1 wallclock secs ( 0.84 usr + 0.00 sys = 0.84 CPU)
Count0: 42 wallclock secs (41.10 usr + 0.00 sys = 41.10 CPU)
Count0a: 87 wallclock secs (83.47 usr + 0.01 sys = 83.48 CPU)
Count0b: 68 wallclock secs (65.71 usr + 0.01 sys = 65.72 CPU)
Count1: 1 wallclock secs ( 0.84 usr + 0.00 sys = 0.84 CPU)
Count1a: 2 wallclock secs ( 0.82 usr + 0.00 sys = 0.82 CPU)
Count1b: 1 wallclock secs ( 0.83 usr + 0.00 sys = 0.83 CPU)
Del0: 19 wallclock secs (17.61 usr + 0.01 sys = 17.62 CPU)
Del1: 1 wallclock secs ( 0.85 usr + 0.00 sys = 0.85 CPU)
Tr0: 1 wallclock secs ( 0.78 usr + 0.00 sys = 0.78 CPU)
Tr0_d: 1 wallclock secs ( 0.70 usr + 0.00 sys = 0.70 CPU)
Tr1: 0 wallclock secs ( 0.64 usr + 0.00 sys = 0.64 CPU)
Tr1_d: 1 wallclock secs ( 0.66 usr + 0.00 sys = 0.66 CPU)
thus showing that the speed of tr// is system dependent, ;^)
Jay Glascoe
------------------------------
Date: Thu, 22 Apr 1999 12:30:30 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Where can I get a CGI modul
Message-Id: <371F78D6.A30EECEB@mail.cor.epa.gov>
serguei wrote:
>
> Hi, everybody.
>
> Can somebody tell me where can I get a modul CGI.pm .
Go to CPAN. Always go to CPAN.
Did you read the FAQ first?
http://www.perl.com/CPAN/
And if you have a recent ActiveState install, you probably already
have it.
> What a directory will I have to use to install it?
Just follow the directions on the back of the box.
Follow the directions that come with it.
And if you want to install it into one of your private directories
instead, read the FAQ for directions on what to do.
> Thanks in advance
>
> Serguei
HTH,
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
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 5457
**************************************