[13224] in Perl-Users-Digest
Perl-Users Digest, Issue: 634 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 25 00:07:32 1999
Date: Tue, 24 Aug 1999 21:05:10 -0700 (PDT)
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 Aug 1999 Volume: 9 Number: 634
Today's topics:
RE: Adding a User ("Bill Jones")
Re: Archive::Tar <ltl@rgsun40.viasystems.com>
Re: Can't build perl with gcc (Martien Verbruggen)
domain name -> real host resolution? <jeep@rahul.net>
Re: Environment variables <mpersico@erols.com>
Re: Help! Need to check <makkulka@cisco.com>
Re: Help! Need to check (Larry Rosler)
Re: How to distinguish strings 'A|\\|B|' from 'A|\|B|' (Larry Rosler)
Re: How to do "or" in IF test? <arunas@an!m.org>
Re: Installing Perl and Perl/Tk on HP-UX 11 <bshow@my-deja.com>
Re: Installing Perl and Perl/Tk on HP-UX 11 <hal_mounce@amdahl.com>
Re: my() vs. local() (elephant)
mysql interview barrytownbb@yahoo.com
Re: mysql interview <makkulka@cisco.com>
Re: Need Help with "Check for same " (Larry Rosler)
Re: output format <malcolm.dewjones@moh.hnet.bc.ca>
Perl a Black Sheep? <joeyandsherry@mindspring.com>
Re: Perl Book <mpersico@erols.com>
Re: Perl don't stop (Martien Verbruggen)
Re: Problem processing form variables in CGI <makkulka@cisco.com>
Re: Problem processing form variables in CGI <cmd@maths.uq.edu.au>
Re: Problem processing form variables in CGI siafhir2@my-deja.com
Re: Referring to "my" variables <john@dlugosz.com>
Re: Resolving, Capturing, Storing a file on the network (Larry Rosler)
Running out of Virtual Memory (Red Hat Linux User)
Re: Send to ICQ with perl (Martien Verbruggen)
Re: tar? gzip? (Martien Verbruggen)
Re: The Perl debugger <mpersico@erols.com>
Re: Why use Perl when we've got Python?! (Kai Henningsen)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Aug 1999 21:48:17 -0400
From: bill@fccj.org ("Bill Jones")
Subject: RE: Adding a User
Message-Id: <199908250143.VAA26148@astro.fccj.cc.fl.us>
> Date: Tue, 24 Aug 1999 12:49:04 -0500
> From: Sarah <dontemailme@garbage.com>
> Subject: Adding a User
> Message-Id: <37C2DB10.29FC@garbage.com>
>
> Does anyone know of a script that would allow me to add a user to a Unix
> System via a form on a web page. It would be nice to have something to
> use, even just as a start to making something of my own.
>
> Thanks,
>
> Sarah
A big security hole, but possible.
Not the best of the best of the best, but not too terrible;
something I wrote years ago:
#!/usr/local/bin/perl -w
use strict;
require 5.003; # Will only work correctly under 5.00x :-)
# Must run as root!
($> == 0) or die("\n\n\nNot Authorized:
Can only be run by root user. Goodbye...\n\n");
my $count = 0; # Generic Counter...
my $cntr = 0; # Another generic counter :-)
my $hUID = 0; # Highest UID, if finished looking...
my $cUID = 0; # Highest UID Last Found...
my $account = 0; # The LOGIN Name we want to use...
my $acct = 0; # The LOGIN Name found, if any...
my $passwd = 0; # The Password we want to set...
my $pswd = 0; # The Password we found, if any...
my $uid = 0; # Use to determine the NEXT ID we will use...
my $gid = 0; # Not used...
my $quota = 0; # Not used...
my $comment = 0; # The Real Name data we want to set...
my $cmt = 0; # The Real name data we found, if any...
my $gcos = 0; # Not used...
my $home = 0; # Auto-Magical, if user successfully set...
my $shell = 0; # Auto-Magical, if user successfully set...
my $erc = 0; # Any returned error codes from the System Call...
my $x = @ARGV; # How many arguments did we get? We only want one...
my $y = 0; # Set ONLY if we find $account in /etc/passwd...
my $z = ''; # Used to 'build Add User' command string...
# First, we find the highest good UserID...
print "Looking for highest good UID in /etc/passwd;\n\nReading File ";
while (($account, $passwd, $uid, $gid, $quota, $comment, $gcos, $home,
$shell) = getpwent())
{
($uid < 30000 && $uid > $cUID) ? $cUID = $uid : print ".";
$account = ''; # The following are not used this time around...
$passwd = '';
$gid = '';
$quota = '';
$comment = '';
$gcos = '';
$home = '';
$shell = '';
# Increment the count...
$count++;
}
print " Done!\n\n";
# Now set the Highest UID correctly...
$hUID = $cUID + 1;
print "Completed reading $count User \'/etc/passwd\' Records; the next valid
ID is $hUID.\nContinuing...\n\n";
$count = 0; # Reset it...
# See if Input Data file was given, and validate that it is in correct
format...
if ($x) {
print "Setting default STAFF UNIX Environment...\n";
# Setup the default staff account environment...
$erc = system("useradd -D -g staff -b /drv2/home/staff") / 256;
if ($erc) {
print "\n\nSystem Call to \'useradd \-D \(set environment\)\'
generated an error of type $erc!\nExiting...\n\n";
exit $erc;
} else {
print "\n\nChecking input data file... Please wait...\n\n";
}
while(<>) {
$count++;
chomp; # Cut-off CR at eol...
( $account, $comment, $passwd ) = split(":");
$account = lc($account); # Make sure it is lowercase ...
print "$account, $comment, $passwd";
if (length($account) < 3 || $comment eq '' || length($passwd) < 3) {
if (length($account) < 3) { print "\nError Found: Login must be at least
3 characters..."; }
if ($comment eq '') { print "\nError Found: Account Name Comment
missing..."; }
if (length($passwd) < 3) { print "\nError Found: Password must be at
least 3 characters..."; }
print "\n\nErroneous input file data was found. See last record
displayed...\n\n";
exit 1;
}
setpwent();
while (($acct, $pswd, $uid, $gid, $quota, $cmt, $gcos, $home, $shell) =
getpwent())
{
next if $acct ne $account;
$y = 1;
last;
}
if ($y) {
print "\: LOGIN already exists...Skipping!\n";
$y = 0; # Reset for next time...
next;
} else {
#
# USERADD Command Format:
# To create users -
# usage: useradd [-u uid [-o] | -g group | -G group[[,group]...] | -d dir
| -s shell | -c comment | -m [-k skel_dir] | -f inactive | -e expire ] login
# - or, to set creation environment -
# useradd -D [-g group | -b base_dir | -f inactive | -e
expire ]
#
# Assemble the command string... Then execute it...
$z = "useradd -u " . ++$hUID . " -s /usr/bin/csh" . " -c "
. "\"" . $comment . "\"" . " -m " . $account;
$erc = system($z) / 256;
if ($erc) {
print "\n\nSystem Call to \'useradd\' generated an error
of type $erc!\nExiting...\n\n";
exit $erc;
} else {
print "\: Created. Setting Password .. ";
# Calls an Expect-script... Trust me, it's the only way...
$z = "passwd.expect $account $passwd";
$erc = system($z) / 256;
if ($erc) {
print "\n\nSystem Call to \'passwd.expect\' generated an error
of type $erc!\nExiting...\n\n";
exit $erc;
} else {
print " OK!\n";
}
}
}
$cntr++;
}
print "\nDone checking $count New Staff Input Data File Records...\nCreated
$cntr Staff Records...\n\n";
print "Restarting the WWW Server... Please wait...\n";
$erc = system("apache restart") / 256; # if you need too...
if ($erc) {
print "\n\nSystem Call to \'WWW Restart\' generated an error of
type $erc!\nExiting...\n\n";
exit $erc;
} else {
print "\n\nProgram done...\n\n\n";
}
} else {
print "\n\nError: No input data file given...\n";
print "Usage: \.\/NewAddStaff filename \[enter\]\n\
(NOTE: Do not use the \'\<\' I/O redirection symbol!\)\n\n";
exit 1;
}
#
# The input data file format is the same as that of student...
#
Making this a CGI is left as an exercise of the reader...
Also, you will need an Expect script to set the passwd;
call this passwd.expect and place in the same directory the above:
#!/usr/local/bin/expect
spawn passwd [lindex $argv 0]
set password [lindex $argv 1]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof
Enjoy!
-Sneex- :]
FCCJ Data Security Group
____________________________________________________________________
Bill Jones Data Security Specialist http://jacksonville.pm.org
"f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.", TC in c.l.p.misc
------------------------------
Date: 25 Aug 1999 01:28:44 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Archive::Tar
Message-Id: <7pvgsc$bah$1@rguxd.viasystems.com>
Teleport Admin--Jereme <admin3@teleport.com> wrote:
:>I am trying to use the Archive::Tar PM to backup the database on our
:>listserver. I am having problems getting Archive::Tar to work. here is
:>what I have:
:>use Archive::Tar;
[snip]
:> if(Archive::Tar->create_archive ("$backup_dir/$backup_filename",
:>9, "/opt/lyris")){
[snip]
I don't know about the error message you get, but my experience with
Archive::Tar is that unlike the Unix "tar" command, it does not
automatically do a recursive examination of a directory structure.
You must explicitly list every file that goes into the archive. You
can use File::Find to generate the list.
--
// Lee.Lindley /// Programmer shortage? What programmer shortage?
// @bigfoot.com /// Only *cheap* programmers are in short supply.
//////////////////// 50 cent beers are in short supply too.
------------------------------
Date: Wed, 25 Aug 1999 00:15:30 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Can't build perl with gcc
Message-Id: <CAGw3.2584$hf4.4677@nsw.nnrp.telstra.net>
In article <37C29A98.DE4C84B@dial.pipex.com>,
Technical Services - UK Link <fx77@dial.pipex.com> writes:
> I am trying to build perl (5.005_57) and mysql on a HP-UX 10.20 box.
That's a development release. Unless you are really planning on
developing perl, I wouldn't touch that. Go with the 5.005_03 release.
That is the current stable one you should be working with.
The fact that you need to answer this question more or less suggests
to me that you do not indeed want the development releases :)
Oh, and next time when you posts a report like this, you should
probably mention the version of gcc you're using.
Martien
--
Martien Verbruggen |
Interactive Media Division | You can't have everything, where would
Commercial Dynamics Pty. Ltd. | you put it?
NSW, Australia |
------------------------------
Date: 25 Aug 1999 02:52:22 GMT
From: California Man <jeep@rahul.net>
Subject: domain name -> real host resolution?
Message-Id: <7pvlp6$9ke$1@samba.rahul.net>
Im relatively new to perl and network software.
Im trying to take links in an HTML file such as:
www.somesite.com and find the real host to
use a socket connection on.
If the www.somesite.com is aliased to another
site (the host site) and I try to connect to
somesite.com, I get an error.
If there are packages/modules that do this for
me, Id appreciate a small example, if not,
how do you do this?
I thought gethostbyname would work, but seems
to return the same hostname.
Thanks in Advance
------------------------------
Date: Tue, 24 Aug 1999 20:39:22 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Environment variables
Message-Id: <37C33B3A.215BE940@erols.com>
One of the reasons I very occasionally miss VMS and it's system/group
symbol tables.
Sign.
No I do not belive that the child process will have any effect on the
parent environment.
If only the same be true of children...
:-)
Lee Mulleady wrote:
>
> Is there any way to set Environment variables (on Unix), so that they
> stay set after the script ends?
>
> Thanks for any help,
>
> -Lee
>
> lemull@unx.sas.com
--
Matthew O. Persico
You'll have to pry my Emacs from my cold dead oversized
control-pressing left pinky finger. -- Randal L. Schwartz
------------------------------
Date: Tue, 24 Aug 1999 17:37:12 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Help! Need to check
Message-Id: <37C33AB8.27C88CD5@cisco.com>
[ Tim wrote:
> I want to make a lotto kind of game. I want to choose 6 different
> numbers from 1-49. The random numbers part is ez, but how do I make it
> so no number repeats? (Every number is different)
You could use each value already chosen as a key in a hash and associate a
dummy
value to it. The next time you use the random function make sure that the
number returned is NOT a key in this hash ( use the function exists() to
do this).
You could also use an array to hold all previously chosen values. As you
are returning a max of 6 values searching this array will not be a time
consuming
operation either.
--Makarand
------------------------------
Date: Tue, 24 Aug 1999 20:26:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help! Need to check
Message-Id: <MPG.122d023ed837d3a6989e92@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37B852A4.44D5@connect.ab.ca> on Mon, 16 Aug 1999 12:04:20 -
0600, Tim <bie@connect.ab.ca> says...
> I want to make a lotto kind of game. I want to choose 6 different
> numbers from 1-49. The random numbers part is ez, but how do I make it
> so no number repeats? (Every number is different)
>
> I could do a lot of if statements, but there has to be a better way.
Oh, I see. You posted it again the next day, with a slightly different
(and even less useful) Subject. This is very poor netiquette.
As for the other answer you received in this thread, There's More Than
One Way To Do It, but some ways are better than others.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Aug 1999 20:08:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to distinguish strings 'A|\\|B|' from 'A|\|B|' ?
Message-Id: <MPG.122cfde5f2ce4267989e90@nntp.hpl.hp.com>
In article <37be9473.1608259@news.tiac.net> on Sat, 21 Aug 1999 13:21:02
GMT, holmberg@NoSpam.net <holmberg@NoSpam.net> says...
> On Sat, 21 Aug 1999 00:36:45 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
...
> From your response I take it that Perl cannot solve this simple parsing problem.
No. It can. You may have misinterpreted my response.
> You indicated the fragments 'A|B|\\|C' and 'A|B|\|C' as read from a file really
> cannot be distinguished because 'escape processing' cannot be suppressed in a
> local context, making them 'Really the same' strings. This means that Perl is
> inadequate for this parsing task.
No, they can be distinguished trivially. They are strings of different
lengths! What is muddying the situation is your writing them between
single-quotes as if they were string literals, in which case they would
represent the same string. When you write them as string literals, you
must use four backslashes to create the eight-character string A | B | \
\ | C. But the string A | B | \ | C has only seven characters.
> Obviously, outside of Perl these are NOT the same strings, but when read by Perl
> they become the same - and that can't be stopped. Input comes from files that I
> do not create, so this is not a matter of saying that this input should contain
> additional backslashes.
No, they do not become the same. Perl input doesn't change a string
from eight characters to seven characters because there are two
backslashes in a row. That is done by the mechanism that interprets a
string *literal*, but there is no string literal involved in reading a
string from a file.
> Guess I'll have to call out to another program to provide some input stream
> pre-processing support. I was hoping to avoid that.
No, you don't have to do that.
> Carl
Larry
> >> To illustrate the problem, the strings below are not distinguished, and
> >> I haven't been able to find a way to distinguish them because interpolation
> >> of '\\' hits before I can do anything. Is there any way to turn off
> >> interpolation in a local context?
> >
> >No, but there is no interpolation here. You mean 'escape processing'.
> >
> >> # Sample showing failure to distinguish strings - these produce
> >> # the same results:
> >> printf "length %d %s %s\n",length('A|\|C|'),'A|\|C|',quotemeta('A|\|C|');
> >> printf "length %d %s %s\n",length('A|\\|C|'),'A|\|C|',quotemeta('A|\\|C|');
> >
> >They produce the same results because they are the same strings. Really
> >the same. In single-quoted context, either \ (not followed by a single-
> >quote) or \\ produce a single backslash.
> >
> >To get two backslashes into a string (either single- or double-quoted),
> >you must use four (\\\\).
>
> This data comes from database dump files I don't create. And I don't think
> this helps anyways.
Once again, you are confusing string literals with string data derived
from reading a file. The same rules do not apply.
> According to the syntax of these files, '\\' pairwise left-right turns into
> literal '\' characters, and '\|' is treated as a literal vertical bar, but an
> unescape '|' is treated as a field separator. I need to distinguish
> real field-separators from literal vertical bars, which is complicated by
> the presence of some fields containing only a 'literal' backslash, in the
> escaped form of '\\'. Fields can contain whitespace and they may be null too.
The regex I posted and that you quoted below does exactly that. Did you
try it on data read from the file (or from a __DATA__ section at the end
of your Perl program)?
> >> What is desirable is when splitting (these are being read from a file) is to get
> >> the following splits:
> >> 'A|\|C|' splits into ('A','\|C') (2 components)
> >> 'A|\\|C|' splits into ('A','\\','C') (3 components)
<SNIP> of program using string literals
> This does not solve the problem I posed - you changed the problem by adding an
> extra backslash.. It does not distinguish input strings 'A|\|C|' from 'A|\\|C|'
> by parsing them differently.
Yes, it does. Try it this way to see:
#!/usr/local/bin/perl -w
use strict;
print join('+' =>
/( # start capture
(?: # a sequence of either
\\[\\|] # an escaped backslash or vertical bar
| # or
[^|] # any character except vertical bar
)+ # don't allow fields to be empty
) # end capture
/gx), "\n"
for <DATA>;
__END__
A|\|C
A|\\|C
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Aug 1999 21:36:25 -0600
From: "Arunas Salkauskas" <arunas@an!m.org>
Subject: Re: How to do "or" in IF test?
Message-Id: <37c364c7@news.cadvision.com>
Can you tell us the _Exact_ line you used?
if ($end <= 20 || $answer eq "y")
{
#do something
}
looks like it might work. Then again, you might tell us what happened, and
what you expect to happen. You could try printing out the values of $y and
$answer before the condition - just to make sure they are what you think
they are.
print "\$end = $end and \$answer = $answer\n";
--
--
- Arunas Salkauskas
High Point Designs
www.highpointdesigns.com
Jim wrote in message ...
>Please accept my apologies if this is not the appropriate
>place for this question.
>
>
>I am learning Perl using "Learning Perl" (great book). I am not
>able to find info on how to implement a logical OR in an if
>statement test, such as
>
>if (this or that) {
> -
> -
> -
>}
>
>
>I tried several permutations such as
>
>if ((this) || (that))
>
>if ( this || that )
>
>if (this) || (that)
>
>and nothing seemed to work.
>
>The actual tests are
>
>end <= 20
>
>answer eq "y"
>
>
>Thanks for any help.
>
>Jim
>
------------------------------
Date: Wed, 25 Aug 1999 02:58:50 GMT
From: Bob Showalter <bshow@my-deja.com>
Subject: Re: Installing Perl and Perl/Tk on HP-UX 11
Message-Id: <7pvm52$84$1@nnrp1.deja.com>
> - Did somebody compile Perl with the complete cc ? With specific
> parameters or options ?
FWIW, I have successfully built Perl 5.005_02 using cc. No special
options. DBI/DBD::Oracle required linking static, but otherwise work
great. Have not installed Perl/Tk.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 24 Aug 1999 20:48:32 -0700
From: Hal Mounce <hal_mounce@amdahl.com>
Subject: Re: Installing Perl and Perl/Tk on HP-UX 11
Message-Id: <37C36790.A63C3A80@amdahl.com>
Benjamin Cassan-de Gorostarzu wrote:
> - Did somebody compile Perl with aCC ?
I tried, never could beat it into submission. Wound up buying HP's ANSI
C.
> Did somebody known if copying a binary of Perl from 10.20 to 11 is
> working well ?
Should work. I've only got the one ANSI C license, so I compile on a
K420 and move things over to a V2200, both at 11.0.
I've also pulled the pre-compiled package from http://hpux.cs.utah.edu
back when it was at 5.004 and told swinstall to force it on my 11.0
machines even though it was built for 10.20 and this seemed to work
fine. I notice that they have 5.005 up now.
Regards,
Hal
------------------------------
Date: Wed, 25 Aug 1999 14:01:33 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: my() vs. local()
Message-Id: <MPG.122e15ac6d9352b6989c7e@news-server>
I'll not ask why you followed up to my post and not to the person who
actually asked the question .. just want to respond to the only part of
your post that was actually directed to me
Vincent Murphy writes ..
>>>>>> "jason" == jason <elephant@squirrelgroup.com> writes:
> jason> read the documentation .. start with the FAQ
>
> jason> perldoc -q "local.*my"
>
>Not in 5.004. Some people actually have to live in the past. :-(
yes .. that's very sad .. but you can't expect answers here in usenet to
be correct for every dinosaur version of Perl that there's ever been
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Wed, 25 Aug 1999 02:29:57 GMT
From: barrytownbb@yahoo.com
Subject: mysql interview
Message-Id: <7pvkeo$v15$1@nnrp1.deja.com>
I am going to soon be interviewed for a mysql database programmer
position. Any ideas on what kind of questions are generally asked? I
wanted to get a headstart on essential reading for being "tech-ed out"
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 24 Aug 1999 20:55:48 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: mysql interview
Message-Id: <37C36944.2BB77495@cisco.com>
[ barrytownbb@yahoo.com wrote:
> I wanted to get a headstart on essential reading for being "tech-ed out"
A new book is now out --
MySQL and mSQL (Nutshell Series)
by Randy Jay Yarger, George Reese, Tim King
There is some good docs you could read at www.Mysql.com
--
------------------------------
Date: Tue, 24 Aug 1999 20:20:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Need Help with "Check for same "
Message-Id: <MPG.122d00ddf5efddea989e91@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37B77147.7B3E@connect.ab.ca> on Sun, 15 Aug 1999 20:02:47 -
0600, Tim <bie@connect.ab.ca> says...
> I want to make a lotto kind of game. I want to choose 6 different
> numbers from 1-49. The random numbers part is ez, but how do I make it
> so no number repeats? (Every number is different)
>
> I could do a lot of if statements, but there has to be a better way.
This little problem seems not to have been answered and doesn't appear
at deja.com. Perhaps it was canceled.
At any rate, similar questions have been asked recently; perhaps a FAQ
on generating combinations from a list is desirable.
my @a = (1 .. 49);
my @winners = map splice(@a, rand @a, 1), 1 .. 6;
The splice removes from the input array each number that has been
selected.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 24 Aug 1999 16:21:08 -0700
From: Malcolm Dew-Jones <malcolm.dewjones@moh.hnet.bc.ca>
Subject: Re: output format
Message-Id: <37C328E4.EC7211C1@moh.hnet.bc.ca>
Dean Wilson wrote:
>
> Hi! I have a question that I don't even know where to start looking for
> answers for. I'd like to write a program that outputs information to
> STDOUT, but instead of scrolling the text upward, I'd like it to replace
> current text. (I'm not even sure if there is a common name for text that
> is outputted in this fashion...)
This doesn't happen automatically, but can be trivial if your needs are
simple, or more and more complex as the task gets harder and harder.
Simplest task is to print a single line and then overwrite it later with
no backing up.
# perl
print "Starting to do something"; # note no \n
sleep 10; # i.e. wait 10 seconds
print "\rNow we're done "; # note \r
For more complex screens you may want to learn about curses. There's a
perl module for that. It allows you to define forms on a text mode
terminal and place text in fields on the form, and etc.
You can also get brave and learn ANSI escape sequences. To do slightly
more complex tasks like keep writing in the same spot on the screen is
not hard. (though this may not work in DOS unless ANSI.SYS or similar
is loaded). Basically you add several controlling characters to the
beginning of any string you want to write, and then simply
"print $string" as normal. The controlling characters start with the
ESCAPE character which tells the terminal that the next few characters
are a controlling command instead of text to print.
If writing to a DOS text screen then there're other simple ways to
position the cursor though I don't know how to access that from perl.
------------------------------
Date: Tue, 24 Aug 1999 22:59:17 -0400
From: <joeyandsherry@mindspring.com>
Subject: Perl a Black Sheep?
Message-Id: <7pvma4$ab5$1@nntp3.atl.mindspring.net>
Greetings,
I am rather new to Perl, I began studying it to use in CGI applications,
which evolved from the necessity of maintaining a profitable web business.
My learning, has helped me cultivate a great deal of enthusiasm and passion
for programming. I work in the manufacturing industry and am only able to
study Perl in my spare time. I occasionally scan the local want ads in
search of Perl jobs, just to see what future may be available...
Today I had an interview with an admissions counselor of a facility that
offers training for the MCSE and the MCSD. I am hoping that this sort of
certification may aid in my desire to change careers...
I spoke to the admissions counselor and I questioned which training program
would best enhance my limited exposure to NT. The Counselor introduced me to
the Training Director, partly to answer my question and partly for
prequalification...He asked of my experience.
I told him of my learning of Perl and of how I used it, etc. As soon as I
mentioned Perl and the UNIX server I use, he snarled. It was if I was
speaking of a plague...He commented that Perl was not a "real" programming
language, it is a scripting language and offered his dissertation on
programming and Unix and other such things.
Why is Perl treated with such disdain? I've found many occasions where Perl
programmers say "Perl can do that...", which doesn't seem to reinforce what
I experienced today.
Thanks for your time and input.
--
Joey Cutchins
President
Trading Post.Com, L.L.C.
-The Race is to the Driven, Not the Swift.
http://InternetTradingPost.com
http://TPads.com
ceo@internettradingpost.com
------------------------------
Date: Tue, 24 Aug 1999 20:37:26 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Perl Book
Message-Id: <37C33AC6.CCC99FFE@erols.com>
Cookbook. Much of Camel is verbatim from perldoc.
James Liu wrote:
>
>
> Hash: SHA1
>
> I said before that i'm broke, but i've scraped up enough money for 1
> oreilly book. I already have llama, so i need to decide whether to
> get cookbook or camel.
>
>
> Version: PGPfreeware 6.5.1 for non-commercial use <http://www.pgp.com>
>
> iQA/AwUBN8KzbhlrzTx6g1omEQLAYACgiu0PJBc0V8uP9eoRCUMqWTNaPjcAnA9h
> uGZzZRS1XFYA9K6fTX888RvA
> =9QDM
> -----END PGP SIGNATURE-----
--
Matthew O. Persico
You'll have to pry my Emacs from my cold dead oversized
control-pressing left pinky finger. -- Randal L. Schwartz
------------------------------
Date: Wed, 25 Aug 1999 00:24:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl don't stop
Message-Id: <7JGw3.2589$hf4.4677@nsw.nnrp.telstra.net>
In article <7pu9ka$ff$1@nnrp1.deja.com>,
cls@quotient.net writes:
> Hello
>
> When I launch a cgi script with my browser and I stop it by closing the
> browser, perl.exe is always running and takes all the ressources
\begin{offtopic}
1) You cannot launch a CGI script with your browser
You request something from a web server, which then runs the CGI program.
2) You cannot stop a running CGI program by closing your browser. In
fact, in many cases, unless your script explicitly deals with it by
checking all of its writes to stdout, you can severely break things.
Especially on braindead OSes.
> I use Netscape Entreprise Server 3.5 on NT 4.0 SP3
Indeed.
The fact that your CGI script is written in Perl doesn't make this a
perl question. Go to a CGI group, and ask there what the general
problems are with what you see and what you are trying to do. Once
you understand what needs to be done, but you can't work out how to do
it in Perl, then you can come back.
\end{offtopic}
Martien
--
Martien Verbruggen |
Interactive Media Division | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: Tue, 24 Aug 1999 17:32:16 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Problem processing form variables in CGI
Message-Id: <37C33990.12499C74@cisco.com>
[ siafhir2@my-deja.com wrote:
> The trouble here is that the period followed by the space (substituted
> by "+")causes the CGI script to read it as a blank field. I don't have
> the problem if the value above read "S.E+Rink", "SE+Rink", or
> "S.E.Rink".
You have to encode your CGI param values..
http://wwwin-dev/CustAdv/SvMap/temp/test.pl?facility=S.E.%2BRink
You can copy the escape subroutine to do this from the CGI.pm source.
For example...
use CGI ;
$page= new CGI ;
$val = 'facility='. escape ('S.E.+Rink' ) ;
$url = 'http://wwwin-dev/CustAdv/SvMap/temp/test.pl?'. $val ;
print $page->header();
if ($page->param())
{
print $page->start_html ();
print "value of facility is " , $page->param('facility') , "\n" ;
print $page->end_html ();
}
else
{
print <<END;
<HTML>
<body>
<a href=\"$url\"> follow this..</a>
</body>
</HTML>
END
exit;
}
#from CGI.pm.
sub escape {
my $toencode = shift;
return undef unless defined($toencode);
$toencode=~s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg;
return $toencode;
}
~
--Results
value of facility is S.E.+Rink
--Hope this tip helps
------------------------------
Date: Wed, 25 Aug 1999 13:25:16 +1000
From: chris dawson <cmd@maths.uq.edu.au>
To: siafhir2@my-deja.com
Subject: Re: Problem processing form variables in CGI
Message-Id: <37C3621C.F6AF2546@maths.uq.edu.au>
siafhir2@my-deja.com wrote:
>
> I have a problem processing a form variable passed by the URL where the
> variable's value contains a period followed by a space, or a period at
> the end. I suspect any punctuation will cause the problem, but I hadn't
> tested that.
>
> Here's an example of code in the URL:
> http://www.website.com/script.cgi?facility=S.E.+Rink
I had a similar problem once, which I got around bu writing something
like
.cgi?facility=S.E.\s+Rink.
Hope it helps,
Chris.
------------------------------
Date: Wed, 25 Aug 1999 03:38:04 GMT
From: siafhir2@my-deja.com
Subject: Re: Problem processing form variables in CGI
Message-Id: <7pvoer$1rs$1@nnrp1.deja.com>
In article <MPG.122dd4a82554a644989c7a@news-server>,
elephant@squirrelgroup.com (elephant) wrote:
> siafhir2@my-deja.com writes ..
> >Does anyone know how to fix this problem?
>
> yeah .. we know exactly how to fix that problem .. of course - no one
> can know how you'll fix this problem until we can see what your code
> looks like
>
> --
> jason - elephant@squirrelgroup.com -
>
heh, oops.
here's the code that sends the value to another script:
#the value of "fields[$index]" in this case would be "S.E. Rink".
#tack a "+" so html sends all of the value (CGI will remove it).
@temp1 = split(/\s/, $fields[$index]);
$facfull = $temp1[0];
for ($lc=1;$lc<@temp1;$lc++) {$facfull = $facfull."+".$temp1[$lc];}
#I know, that's doing it the long way, another reply was posted to show
#me how to do it the right way. I'm weak at pattern matching right now.
#here's the code for the link that will send the value
#to another cgi script.
print qq~
<TD><A HREF =
"http://www.communityclubs.com/DB_Search/db_facilities.cgi?setup_file=fa
cilities.setup.cgi&facility_name=$facfull&ccowner=$form_data{'who_modifi
ed'}">$fields[$index]</A></TD>\n~;
#When the link is clicked, the following code in another CGI
#script processes the passed data.
$who_modified = $form_data{'ccowner'};
$facility = $form_data{'facility_name'};
The variable "$facility" should have a value of "S.E. Rink", but instead
has a value of "". If the original value didn't have punctuation before
the space (S.E Rink), I wouldn't have the problem.
Any ideas?
Thanks,
SiaFhir
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 24 Aug 1999 19:29:07 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: Re: Referring to "my" variables
Message-Id: <6ED49639ED57E0DB.7EBD6220C6499579.7897AFF8130DC679@lp.airnews.net>
Tom Briles <sariq@texas.net> wrote in message
news:37BD6185.FBC12F91@texas.net...
> Which made me wonder - "When *are* scalar refs warranted?"
>
> And I'm still wondering...
When you must have a ref.
Specifically, to implement an object or the back-end of a tie.
------------------------------
Date: Tue, 24 Aug 1999 20:33:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Resolving, Capturing, Storing a file on the network
Message-Id: <MPG.122d03e86f55178b989e93@nntp.hpl.hp.com>
In article <37C14592.2C28B97@compaq.com> on Mon, 23 Aug 1999 08:58:58 -
0400, JP <Jeff.T.Parker@compaq.com> says...
> Hmmmm, one of two scenarios took place here:
> 1. I stumped the entire newsgroup with that last question and was forced to
> find the answer myself -done successfully last week. -or
> 2. My question wasn't worthy for anyone (except a gallant e-mailed effort
> by A.B. using a "cookie" solution) and was forced to find the answer myself
> -done successfully last week.
You omitted the real scenario.
3. The question had nothing to do with the Perl language, which is what
this newsgroup is about. Bu no one bothered to tell you that.
> Anyway, the answer lied simply in a CGI script for downloading. Don't
> bother trying to say, "Oh, yea, of course I could have said that..."
> Post-coital flaming doesn't count.
And it would probably have worked the same way even if you wrote it in
Cobol.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 Aug 99 02:12:14 GMT
From: chuaswee@ccunx.ncs.com.sg (Red Hat Linux User)
Subject: Running out of Virtual Memory
Message-Id: <37c350fe.0@news.cyberway.com.sg>
HI,
When I am compiling my perl 5.005_03, it gives run out of virtual memory.
Has anyone faced the same problem before?
How was it resolved?
thanks,
Swee Gee.
------------------------------
Date: Wed, 25 Aug 1999 00:17:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Send to ICQ with perl
Message-Id: <hCGw3.2586$hf4.4677@nsw.nnrp.telstra.net>
In article <rs5cq56hdmc22@corp.supernews.com>,
"Jim Karsten" <jimk@gate-way.net> writes:
> Is there a method of sending a message to an ICQ number via a perl script? I
> know that I can send an email to 12345678@pager.mirabilis.com, for example,
> where 12345678 is the ICQ number, but the message is full of garbly-gook. I
> would like the message to be like that received if I had typed it manually
> using my ICQ. Any ideas?
Next time you have a question like this, please first go to CPAN:
http://www.perl.com/CPAN
You might also want to start using the CPAN module:
# perl -MCPAN -e shell
cpan> i /icq/
Distribution GOSSAMER/Net-ICQ-0.08.tar.gz
Module Net::ICQ (GOSSAMER/Net-ICQ-0.08.tar.gz)
cpan>
Martien
--
Martien Verbruggen |
Interactive Media Division | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: Wed, 25 Aug 1999 00:07:03 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: tar? gzip?
Message-Id: <HsGw3.2582$hf4.4677@nsw.nnrp.telstra.net>
In article <Pine.GSO.4.10.9908241229320.16864-100000@eng1.teleport.com>,
Teleport Admin--Jereme <admin3@teleport.com> writes:
> I would have like to have scoured the initial 22k messages for this
> answer, but.. Well.. You know.. Anyways, I know Programming Perl mentions
> something about a standard lib that can tar files. I can't remember where
> I saw it.. Can anyone clue me in? Also, is there one that gzips files as
> well?
Any time in the future you have questions like this, go to CPAN first:
http://www.perl.com/CPAN
And you might want to learn to use the CPAN module:
# perl -MCPAN -e shell
cpan> i Archive::Tar
[snip]
cpan> i Compress::Zlib
Martien
--
Martien Verbruggen |
Interactive Media Division | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Tue, 24 Aug 1999 20:32:57 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: The Perl debugger
Message-Id: <37C339B9.D0BA076E@erols.com>
Steve, I think that there is a good part of Programming Perl devoted to the
debugger. Also, try perldoc perl. One of teh sub-topics might be about the
debugger.
And, if you have the Tk GUI package installed, go lookup the Deve::ptkdb
package on CPAN.
steveeq1@earthlink.net wrote:
>
> Ok everyone.
>
> Forgive me for asking such a stoopid question, but I have three
> questions about the Perl debugger:
>
> 1) once I set the breakpoint. How do I tell Perl to "run through the
> rest of the lines without prompting until the breakpoint. Then stop and
> prompt."
>
> 2) Let's say I find a line that I want to change in Perl while the
> debugger is running. Can I open it in Emacs and change it there real
> time and have the debugger "know" I made the change?
>
> 3) Are there any good websites about the Perl debugger. I checked the
> major search engines and couldn't find much (although I did find a lot
> of great web sites that taught about Perl in general).
>
> Anwyay, any assistance would be appreciated. . .
>
> - Steve
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
--
Matthew O. Persico
You'll have to pry my Emacs from my cold dead oversized
control-pressing left pinky finger. -- Randal L. Schwartz
------------------------------
Date: 25 Aug 1999 01:51:00 +0200
From: kaih=7NZuYVx1w-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <7NZuYVx1w-B@khms.westfalen.de>
rra@stanford.edu (Russ Allbery) wrote on 12.08.99 in <ylwvv0y70r.fsf@windlord.stanford.edu>:
> Perl is not a language
> designed for the people who don't know it very well, whereas Python is
> much more welcoming.
Strange, I've had the opposite impression.
Maybe that's because I spent quite some time with parser theory and
practice, and this made me see significant amounts of whitespace as a
deadly sin, something impossible to forgive.
Or maybe it's because of extensive programming practice, which lead me to
the exact same conclusion.
I thought we had learned that lesson with FORTRAN. Or ISPF scripts
(however that language was called). But it seems not.
Perl has it's own parser sins, but none I consider as deadly as that.
But learning that one fact about Python was certainly enough to put an
abrupt end to my interest in that language.
Kai
--
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
- Russ Allbery (rra@stanford.edu)
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 634
*************************************