[17645] in Perl-Users-Digest
Perl-Users Digest, Issue: 5065 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 8 14:10:34 2000
Date: Fri, 8 Dec 2000 11:10:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976302615-v9-i5065@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 8 Dec 2000 Volume: 9 Number: 5065
Today's topics:
Re: Execute perl code enterred at run time? (Tom Christiansen)
Re: FTP question <abaxaba@my-deja.com>
Re: GD.pm constructor hangs <jgoldst@my-deja.com>
Re: help on regexp (Tad McClellan)
Re: Help with metacharacters and search and replace (Tad McClellan)
Re: List Values and Arrays (Chris Fedde)
Re: List Values and Arrays (Tad McClellan)
Re: Multiple line regular expressions (Tad McClellan)
Re: number vs string (Chris Fedde)
Re: number vs string (Tad McClellan)
Re: number vs string (Richard Zilavec)
Re: number vs string tigra@sky.deep.ru
Perl and DOS windows <graham@purplemtn.com>
Please Help, rookie question <m026636@nadn.navy.mil>
Re: Please Help, rookie question <contact@davew.com>
Re: Precedence, or other ??? <mds-resource@mediaone.net>
Re: splitting a string into an array and preserving the (Abigail)
Re: Statistics for comp.lang.perl.misc (Abigail)
Re: String Manipulation (Abigail)
Re: Use PERL or Java? Which is faster? <hbarta@enteract.com>
Re: Use PERL or Java? Which is faster? (Abigail)
Re: Use PERL or Java? Which is faster? (Abigail)
Re: Use PERL or Java? Which is faster? <smatta@acm.org>
Re: User quota check via web (Abigail)
Re: Using 'require' and performance gains (Abigail)
Re: Willing to review a 90 line Perl program? (Peter Scott)
Win32::Setupsup - nt.ph needed <neil@alaweb.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Dec 2000 12:00:03 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Execute perl code enterred at run time?
Message-Id: <3a312fb3@cs.colorado.edu>
In article <slrn931r5t.vp.tadmc@magna.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
>[ Please put your comments *following* the quoted text that
> you are commenting on.
> Please do not quote entire articles.
> Please do not quote .signatures.
Time to reinstate aggressive autofaqqing.
>>Look for 'eval' in the docs.
>And tremble in fear!
Or in anticipation of great power!
>Users have a nasty habit of exploiting wide-open security flaws.
>Be veeerrrry careful whose code you will run unseen.
>What do you want to do if they enter something like the below?
>
> unlink <* .*>;
> system 'rm -rf /';
> system "rm $0";
Here's the flipside of that argument:
What does the shell do if the user types "rm *"?
What does the shell do if the user types "remuser $user"?
What does the shell do if the user types "clri / 2"?
For example, consider the rename script below.
Now, if you run on multiuser systems where everyone always executes
everything they ever run as the superuser, then fine, I suppose for
those miserable folks, your warning is more appropriate.
But one line of retort to such inanity is that those people get
what they deserve, that stupidity is the only crime that carries
its own built-in, automatically executed penalty, and that the
faster they take themselves out of the gene pool, the better the
environment we'll all enjoy. That's rather harsh, but there's
also something to it. When you blow your own head off because
you pointed the gun the wrong way, well, you can't blame the
manufacturer.
--tom
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# pathedit
# rename (linked to pathedit)
# relink (linked to pathedit)
#
echo x - pathedit
sed 's/^X//' >pathedit << 'END-of-pathedit'
X#!/usr/bin/perl
X# pathedit/rename/relink -- rename or relink files
X# original rename and relink were by Larry Wall
X# this version by Tom Christiansen
X
Xuse 5.006;
Xuse strict;
Xuse warnings;
X
Xour(
X $errcnt, # how many didn't work
X $verbose, # trace actions
X $nonono, # but don't do them (implies verbose)
X $careful, # ask if target *appears* to exist
X $inspect, # ask about everything
X $quiet, # don't carp if target skipped
X $force, # overwrite existing target without prompting
X $nullpaths, # stdin paths are null terminated, not \n
X @flist, # list of magic filenames containing paths to edit
X $renaming, # rename paths (disimplies reslinker)
X $reslinking,# reslink paths (disimplies renamer)
X);
X
X$errcnt = 0;
X
Xopter();
Xcompiler();
Xfixer();
Xexit($errcnt != 0);
X
Xsub usage {
X warn "@_\n" if @_;
X die <<EOF;
Xusage: $0 [-ifqI0vnml] [-F file] perlexpr [files]
X -i ask about clobbering existent files
X -f force clobbers without inquiring
X -q quietly skip clobbers without inquiring
X -I ask about all changes
X -0 read null-terminate filenames
X -v verbosely says what its doing
X -n don't really do it
X -m to always rename
X -l to always symlink
X -F path read filelist to change from magic path(s)
XEOF
X}
X
Xsub accesstty {
X return 1 if defined fileno(TTYIN) &&
X defined fileno(TTYOUT);
X
X unless (open(TTYIN, "</dev/tty") && open(TTYOUT,">/dev/tty")) {
X return 0;
X }
X
X select((select(TTYOUT),$|=1)[0]);
X return 1;
X}
X
Xsub compiler {
X my $op = shift @ARGV || usage();
X *pathedit = eval qq{
X sub () {
X use warnings qw/FATAL all/; # XXX: does not work
X local \$SIG{__WARN__} = sub {
X local \$_ = "\@_";
X s/at \\(eval.*//;
X die "FATAL WARNING: \$_";
X };
X $op;
X }
X } || do {
X local $_ = $@;
X s/at \(eval.*//s;
X die "$0: can't compile perlexpr $op: $_\n";
X }
X}
X
Xsub get_targets {
X if (@ARGV) {
X usage "-F list exclusive of command line paths" if @flist;
X return @ARGV;
X }
X @ARGV = @flist ? @flist : '-';
X local $/ = "\0" if $nullpaths;
X my @paths = <>;
X chomp @paths;
X return @paths;
X}
X
Xsub fixer {
X
X my $oldslink;
X
XPATHNAME:
X for my $oldname (get_targets()) {
X
X if ($oldname =~ /\0/) {
X warn "$0: null found in $oldname; did you forget -0?\n";
X $errcnt++;
X next PATHNAME;
X }
X if ($renaming && !-e $oldname) {
X warn "$0: $oldname doesn't exist\n";
X $errcnt++;
X next PATHNAME;
X }
X
X if ($reslinking) {
X unless (-l $oldname) {
X warn "$0: $oldname ", (-e _)
X ? "not a symbolic link\n"
X : "doesn't exist\n"
X unless $quiet;
X $errcnt++;
X next PATHNAME;
X }
X $oldname = readlink($oldslink = $oldname);
X }
X my $newname = do {
X local $_ = $oldname;
X pathedit();
X $_;
X };
X next if $newname eq $oldname;
X
X local *confirm = sub () {
X next PATHNAME unless accesstty();
X print TTYOUT $renaming
X ? "rename $oldname to $newname? "
X : "symlink $oldslink to point to $newname? ";
X my $answer = <TTYIN>;
X no warnings 'exiting'; # hush, you: it's in my lexical scope
X last PATHNAME unless defined $answer; # exit?
X chomp $answer;
X last PATHNAME if "QUIT" =~ /^\Q$answer/i;
X next PATHNAME unless "YES" =~ /^\Q$answer/i;
X };
X
X confirm() if $inspect;
X
X # "I'd like to teach
X # The world to race
X # In perfect hackery!"
X my $was_there = do {
X no warnings 'newline';
X -e $newname;
X };
X
X if ($renaming) {
X
X if ($was_there && !$inspect && $careful) {
X confirm() unless $force || $quiet;
X next PATHNAME if $quiet;
X }
X
X unless (vrename($oldname, $newname)) {
X warn "$0: can't rename $oldname to $newname: $!\n";
X $errcnt++;
X next PATHNAME;
X }
X
X }
X elsif ($reslinking) {
X unless ($was_there) {
X warn "$0: symlinking $oldslink to nonexistent $newname\n"
X unless $quiet;
X }
X unless (vunlink($oldslink)) {
X warn "$0: can't unlink $oldslink: $!\n";
X $errcnt++;
X next PATHNAME;
X }
X if (!vsymlink($newname, $oldslink)) {
X warn "$0: can't symlink $newname to $oldslink: $!\n";
X $errcnt++;
X next PATHNAME;
X }
X }
X else {
X die "Not reached";
X }
X
X }
X
X}
X
Xsub vunlink {
X my $goner = shift;
X if ($verbose) {
X print "unlink $goner\n";
X return 1 if $nonono;
X }
X unlink $goner;
X}
X
Xsub vrename {
X my ($old,$new) = @_;
X if ($verbose) {
X print "rename $old $new\n";
X return 1 if $nonono;
X }
X rename($old,$new);
X}
X
Xsub vsymlink {
X my ($new,$old) = @_;
X if ($verbose) {
X print "symlink $old -> $new\n";
X return 1 if $nonono;
X }
X symlink($new,$old);
X}
X
Xsub opter {
X
XARG: while (@ARGV && $ARGV[0] =~ s/^-(?=.)//) {
XOPT: for (shift @ARGV) {
X
X m/^$/ && do { next ARG; };
X m/^-$/ && do { last ARG; };
X
X s/^0// && do { $nullpaths++; redo OPT; };
X s/^f// && do { $force++; redo OPT; };
X s/^l// && do { $reslinking++; redo OPT; };
X s/^I// && do { $inspect++; redo OPT; };
X s/^i// && do { $careful++; redo OPT; };
X s/^v// && do { $verbose++; redo OPT; };
X s/^m// && do { $renaming++; redo OPT; };
X s/^n// && do { $nonono++; redo OPT; };
X s/^q// && do { $quiet++; redo OPT; };
X
X s/^F(.*)//s && do { push @flist, $1 || shift @ARGV; redo OPT; };
X
X usage("Unknown option: $_");
X }
X }
X unless ($renaming || $reslinking) {
X $renaming = $0 =~ /name/;
X $reslinking = $0 =~ /link/;
X }
X if ($renaming && $reslinking) {
X usage "Can't both rename (-r) and relink (-h)";
X }
X unless ($renaming || $reslinking) {
X warn "$0: assuming renaming behavior requested\n";
X $renaming++;
X }
X $verbose++ if $nonono;
X
X if ($inspect) {
X accesstty() || usage "can't inspect without /dev/tty: $!";
X }
X
X}
END-of-pathedit
echo chmod +x pathedit
chmod +x pathedit
echo ln pathedit rename
ln pathedit rename
echo ln pathedit relink
ln pathedit relink
exit
------------------------------
Date: Fri, 08 Dec 2000 16:28:57 GMT
From: abaxaba <abaxaba@my-deja.com>
Subject: Re: FTP question
Message-Id: <90r27t$n4t$1@nnrp1.deja.com>
if you're on Unix, this will extract the the last N lines...
#!/u/l/b/p
my $file = "path/dir/file";
my $N = someNumber #number of lines to read;
open (LOG, "tail -$Nl $file|") || die "errStr";
my @lines=<LOG>;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 08 Dec 2000 16:15:17 GMT
From: JL Goldstein <jgoldst@my-deja.com>
Subject: Re: GD.pm constructor hangs
Message-Id: <90r1ed$mfc$1@nnrp1.deja.com>
In article <3A30649F.50723A93@rochester.rr.com>,
Bob Walton <bwalton@rochester.rr.com> wrote:
> Hmmmm...I ran your program verbatim, and it ran fine. Windoze 98 SE,
> Website 1.1, Perl 5.6, ActiveState build 618.
Well, that's probably cuz (a) it's the example that came with the GD.pm
distribution, and (b) obviously you got GD set up just fine on your
system...... <sigh> But I do thank you for taking the time to try to
help me out.
<banging head against wall>
--
Anyone for Perl bowling?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 8 Dec 2000 09:41:20 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help on regexp
Message-Id: <slrn931sog.14d.tadmc@magna.metronet.com>
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>On 8 Dec 2000 11:15:32 GMT, Bill <suweiyi@supanet.com> wrote:
>>
>>If I have strings like:
>>
>>My ISP's URL:<http://www.myisp.com>
>>My ISP's URL:(http://www.myisp.com)
>>How can I use Perl regexp to separate http://www.myisp.com from the above
>>strings?
>
>print $1 if $input_string =~ /(?:<|\(|")(.*?)(?:>|\)|")/;
While that does match the 3 lines given, it does not enforce
that the correct delimiters are present.
It matches: My ISP's URL:<http://www.myisp.com)
^ ^
And is should be written with char classes instead of
single-char alternations anyway:
/[<("](.*?)[>)"]/
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 8 Dec 2000 09:58:25 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with metacharacters and search and replace
Message-Id: <slrn931toh.14d.tadmc@magna.metronet.com>
jrogers42@hotmail.com <jrogers42@hotmail.com> wrote:
>The thing is that I won't always know what the format will be, cause
>I'm pulling the delimiter
They are "separators", not "delimiters", BTW.
>in from a file. So if I pull in \t from a
>file and store it in a scalar.
Like: $sep = "\t"; ?
>How do I set up s/// so that it sees the
>stored \t has a tab and not a \t?
The replacement string part (and the pattern part too) of s///
is double-quotish (it acts like a double quoted string).
So you can interpolate variables into the replacement string:
s/,/$sep/g;
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 08 Dec 2000 16:09:31 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: List Values and Arrays
Message-Id: <%I7Y5.59$B9.170157056@news.frii.net>
>
>Perl is more of a natural language than a programming language, in that it
>has rules of context that many other languages don't. When I say "dog",
>you don't know if I mean the noun, the verb, or the adjective. You need
>context around it. "I hate dogs." "I am dog-tired." "The dog catcher
>dogged a dog during the dog days of summer and got dog-tired."
>
I'd rather say that Perl has some natural language like features
than most programming languages. I agree that one of the main
things to 'get' in Perl is the idea of context. It can enable some
consise constructs. Some times perhaps too consise. :-)
chris
--
This space intentionally left blank
------------------------------
Date: Fri, 8 Dec 2000 10:09:08 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: List Values and Arrays
Message-Id: <slrn931uck.14d.tadmc@magna.metronet.com>
erictwx@my-deja.com <erictwx@my-deja.com> wrote:
>In article <qcr13t08gdmoonds0sk5p0mddvtpue7pjl@4ax.com>,
> Lou Moran <lmoran@wtsg.com> wrote:
>> @stuff = ("one", "two", "three");
>> $stuff = @stuff;
>> print $stuff
>>
>This return 3
It "outputs" 3. "return" means something altogether different.
"print $stuff" returns true if the print succeeded, else false.
>because when evaluated in scalar context, a list returns
>the number of elements in the list.
No it doesn't.
First, there is nothing that even looks like "list in scalar context".
The _only_ list above is in the first line, which is in list context.
@stuff is not a list, it is an array.
Second there is *no such thing* as a list in a scalar context:
$stuff = ("one", "two", "three");
There is no list there (despite looking like there is).
There is just the comma operator in some parens.
Third an *array* (not a list) returns the number of elements
in the array when used in scalar context.
Please do not try and reanswer FAQs. Your followup has made
things worse, not better. Just provide a pointer to the FAQ answer.
Perl FAQ, part 4:
"What is the difference between a list and an array?"
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 8 Dec 2000 09:49:16 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Multiple line regular expressions
Message-Id: <slrn931t7c.14d.tadmc@magna.metronet.com>
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>On Fri, 08 Dec 2000 11:24:02 GMT, qades <qades@my-deja.com> wrote:
>>I have to delete <script></script> tags from a bunch of html-files. What
>>I tried is read the file into a variable and do a
>>
>> s/<script.*<\/script>//ig;
>>
>>you can imaging that this didn't work for multiple line scripts. I
>>thought [.\n]* would work but now i know better :) So anybody knows
>>the/one right syntax?
>
>perl -i.bak -ne 'print unless /<script>/i .. /<\/script>/i' <input_file>
What will that do if input_file contains:
<p>before</p>
<p>Hi there</p><script>
Iamcode
</script><p>So long</p>
<p>after</p>
??
A: it will discard some babies with the bathwater.
Use a module that understands HTML for processing HTML.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 08 Dec 2000 16:14:32 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: number vs string
Message-Id: <IN7Y5.60$B9.170157056@news.frii.net>
In article <Pine.LNX.4.20.0012081016490.29457-100000@ethyl.addictmud.org>,
Daniel W. Burke <dwb1@home.com> wrote:
>
>
>Hello,
>
>
>What is the best, most warning-free method of testing if a scalar
>is a number or a string?
>
>I have a situation where I'm pulling data from a database, and
>based on some conditions, the field I need to compair could be
>a number or a string. I don't appear to have a way of knowing
>ahead of time what kind of value it is, so compairsons I do
>like this give warnings on character fields:
>
>if (length($var) == 0 || ($var < 1)
>
>Is there a way ahead of time to check that... like,
>
>if ( (ischar($var) && (length($var) == 0)) ||
> (isnum($var) && ($var < 1)
> )
>
the FAQ says...
How do I determine whether a scalar is a number/whole/integer/float?
Assuming that you don't care about IEEE notations like "NaN" or
"Infinity", you probably just want to use a regular expression.
if (/\D/) { print "has nondigits\n" }
if (/^\d+$/) { print "is a whole number\n" }
if (/^-?\d+$/) { print "is an integer\n" }
if (/^[+-]?\d+$/) { print "is a +/- integer\n" }
if (/^-?\d+\.?\d*$/) { print "is a real number\n" }
if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print "is a decimal number" }
if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/)
{ print "a C float" }
If you're on a POSIX system, Perl's supports the `POSIX::strtod'
function. Its semantics are somewhat cumbersome, so here's a `getnum'
wrapper function for more convenient access. This function takes a
string and returns the number it found, or `undef' for input that isn't
a C float. The `is_numeric' function is a front end to `getnum' if you
just want to say, ``Is this a float?''
sub getnum {
use POSIX qw(strtod);
my $str = shift;
$str =~ s/^\s+//;
$str =~ s/\s+$//;
$! = 0;
my($num, $unparsed) = strtod($str);
if (($str eq '') || ($unparsed != 0) || $!) {
return undef;
} else {
return $num;
}
}
sub is_numeric { defined getnum($_[0]) }
Or you could check out the String::Scanf module on CPAN instead. The
POSIX module (part of the standard Perl distribution) provides the
`strtol' and `strtod' for converting strings to double and longs,
respectively.
--
This space intentionally left blank
------------------------------
Date: Fri, 8 Dec 2000 10:54:18 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: number vs string
Message-Id: <slrn93211a.19m.tadmc@magna.metronet.com>
Richard Zilavec <rzilavec@tcn.net> wrote:
>
>if($var /^$/ || ($var =~ /^\d+$/ && $var < 1)) {
^^^ ^^^
>
>Hmmmmm, maybe :)
Hmmm, think about that for a minute.
The only possible "number" (by your implied definition of "number")
that could meet the condition is zero.
So you might just as well replace the whole second clause with
$var == 0
I doubt that your definition of "number" is applicable there.
0.5 should probably be a "number" in the OP's case...
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 08 Dec 2000 17:30:01 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: number vs string
Message-Id: <3a381a54.354824879@news.tcn.net>
On Fri, 08 Dec 2000 15:33:58 GMT, rzilavec@tcn.net (Richard Zilavec)
wrote:
>
>if($var /^$/ || ($var =~ /^\d+$/ && $var < 1)) {
>
if(
# var is not empty and does not contain letters
($var =~ /^$/ || ($var =~ /.+/ && $var =~ /[^\w]) ||
# or var is less then one
$var < 1)
) {
hmmm...
Richard Zilavec
rzilavec@tcn.net
------------------------------
Date: Fri, 08 Dec 2000 18:41:21 GMT
From: tigra@sky.deep.ru
Subject: Re: number vs string
Message-Id: <90ra0g$u0m$1@nnrp1.deja.com>
In article
<Pine.LNX.4.20.0012081016490.29457-100000@ethyl.addictmud.org>,
"Daniel W. Burke" <dwb1@home.com> wrote:
>
>
> Hello,
>
> What is the best, most warning-free method of testing if a scalar
> is a number or a string?
>
> I have a situation where I'm pulling data from a database, and
> based on some conditions, the field I need to compair could be
> a number or a string. I don't appear to have a way of knowing
> ahead of time what kind of value it is, so compairsons I do
> like this give warnings on character fields:
>
> if (length($var) == 0 || ($var < 1)
>
> Is there a way ahead of time to check that... like,
>
> if ( (ischar($var) && (length($var) == 0)) ||
> (isnum($var) && ($var < 1)
> )
>
> Or am I dooooooooooomed?
>
> Dan.
>
>
Try this:
#!/usr/bin/perl -w
use strict;
{
print '$a: ';
my $a = <STDIN>; chomp $a;
print isnum($a) ? "Number\n" : "String\n";
redo;
}
sub isnum {
my $a = shift;
no warnings; # They will be enabled automatically when the '}' is met
return $a eq $a+0 ? 1:0;
}
This works for perl 5.6. In case your perl is older, this sample of
isnum should work
sub isnum {
my $a = shift;
$^W = 0; # disable warnings
my $isnum = $a eq $a+0 ? 1:0;
$^W = 1;
return $isnum;
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 08 Dec 2000 09:38:49 -0700
From: Graham Knight <graham@purplemtn.com>
Subject: Perl and DOS windows
Message-Id: <3A310E99.C283C749@purplemtn.com>
I have a perl program running occasionally out of the scheduler on windows 98.
Does anyone know of a way to run the program so that it does not pop
up a DOS window every time it runs? If it popped up the window in a
minimized state that would be great too, basically I don't want
windows popping up all over the scren every time the program runs.
Any help or tips to make this happen very much appreciated.
Thx,
Graham
------------------------------
Date: Fri, 8 Dec 2000 11:39:38 -0500
From: "Joey Tanner" <m026636@nadn.navy.mil>
Subject: Please Help, rookie question
Message-Id: <90r2om$36g$1@news.usna.navy.mil>
I am just learning Perl, with exp in C++, java... Does anyone know where I
can find a sample script that would very simply take info from forms (name,
address etc..) and then write this info to a .txt file? I really appreciate
the help in starting my "journey through Perl.
J Tanner
------------------------------
Date: Fri, 08 Dec 2000 17:39:45 GMT
From: "DaveW" <contact@davew.com>
Subject: Re: Please Help, rookie question
Message-Id: <B19Y5.85023$751.2025274@typhoon.ne.mediaone.net>
You can go here... http://cgi.resourceindex.com/Programs_and_Scripts/Perl/
Look at some of the "Forms Processing" scripts or take one of the
"Guestbooks" scripts and learn how it's done.
DaveW
"Joey Tanner" <m026636@nadn.navy.mil> wrote in message
news:90r2om$36g$1@news.usna.navy.mil...
> I am just learning Perl, with exp in C++, java... Does anyone know where I
> can find a sample script that would very simply take info from forms
(name,
> address etc..) and then write this info to a .txt file? I really
appreciate
> the help in starting my "journey through Perl.
>
> J Tanner
>
>
------------------------------
Date: Fri, 08 Dec 2000 12:42:13 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Precedence, or other ???
Message-Id: <3A312B85.D14791A6@mediaone.net>
"Michael D. Schleif" wrote:
>
> my $i = 1;
> my $j;
> $j = ++$i*$i--;
> print "j is now $j\n";
>
> What is happening here?
>
> Why is $j == 2 ???
>
> How can I trace $i every step of the way?
$j = ++$i/$i--;
Just when I thought I understood the first one -- now, why is $j == 0.5
???
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: 8 Dec 2000 17:55:51 GMT
From: abigail@foad.org (Abigail)
Subject: Re: splitting a string into an array and preserving the "\n"
Message-Id: <slrn932857.nl1.abigail@tsathoggua.rlyeh.net>
On Sat, 02 Dec 2000 14:01:47 -0500, Bernie Cosell (bernie@fantasyfarm.com) wrote in comp.lang.perl.misc <URL: news:<528i2tsf13ekrqbqft44u6t1knhlmn153u@news.supernews.net>>:
++ kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz> wrote:
++
++ }
++ } So your saying that because people use America Online, we have to start
++ } dumming down our vocabulary to greet them?
++
++ No, *EVERYONE* (except tom and perhaps you) uses "online" (in an
++ unrestricted sense) to mean somehow relating to the Internet these days. I
++ don't want to belabor this silly side issue any more, but when most of the
++ 'online' users did so through shell accounts [or the equivalent on other
++ operating systems] saying things like "man THIS" [for unix fans] wasn't a
++ bad start for 'online'. But these days, even without AOL you have
++ Earthlink, and Mindspring and ATT Worldwide and millions and millions of
++ users for whom online means primarily "connected to the Internet" or
++ "accessible via the Internet"
Funny that you mention AOL. You do know that the "online" in AOL has
nothing to do with the Internet, don't you?
Abigail
------------------------------
Date: 8 Dec 2000 18:00:10 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <slrn9328da.nl1.abigail@tsathoggua.rlyeh.net>
On Tue, 05 Dec 2000 20:21:49 GMT, Philip 'Yes, that's my address' Newton (nospam.newton@gmx.li) wrote in comp.lang.perl.misc <URL: news:<3a2d3171.250709579@news.tiscalinet.de>>:
++
++ > Bottom 10 Posters by OCR (minimum of five posts)
++ > =================================================
++ >
++ > (kb) (kb)
++ > OCR orig / body Posts Address
++ > ----- -------------- ----- -------
++ >
++ > 0.431 ( 5.2 / 12.1) 8 OTR Comm <otrcomm***NO-SPAM***@wildapache**NO-SPAM***.net>
++ > 0.429 ( 1.5 / 3.5) 6 "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
++ > 0.412 ( 6.9 / 16.7) 9 "Ed Grosvenor" <secursrver@hotmail.com>
++ > 0.410 ( 5.2 / 12.6) 13 abigail@foad.org
++
++ Now that Abigail seems to use nearly only ++ as a quote prefix, she's
++ dropped quite a bit in the OCR scale (number 7) -- though I note that
++ being number 9 is not so hot, either. (On the other hand, I'm probably
++ not doing much to improve my score with this post.)
OCR is a stupid rating. It strongly suggest that asking questions,
even if they are off-topic or FAQs is a good thing, while answering
questions in a concise way is bad.
The OCR should be removed from the statistics.
Abigail
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler OCR filler
--
;-)
------------------------------
Date: 8 Dec 2000 18:01:57 GMT
From: abigail@foad.org (Abigail)
Subject: Re: String Manipulation
Message-Id: <slrn9328gl.nl1.abigail@tsathoggua.rlyeh.net>
On Sat, 2 Dec 2000 19:08:04 -0000, James Boulter (jbou@bunker79.fsnet.co.uk) wrote in comp.lang.perl.misc <URL: news:<90bhb9$uch$1@newsg2.svr.pol.co.uk>>:
++ Dear all,
++
++ I have the string "James <email address>"
++
++ How can I get the information into two separate variables without the
++ brackets.
my ($first, $second) = $string =~ /([^<>]+)/g;
Abigail
------------------------------
Date: 8 Dec 2000 16:32:29 GMT
From: Henry_Barta <hbarta@enteract.com>
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <90r2et$m6k$1@bob.news.rcn.net>
In comp.lang.java.help Kenny Pearce <kenny@kennypearce.net> wrote:
[...]
> 5. Perl is my "native" language (the first one I learned to program with) and
> I am therefore biased toward it.
Programmer productivity is always important. (To me, anyway.)
As a C/C++ programmer who has been using Perl almost exclusively
for over a year, I find Perl *incredibly* productive. I'm
converting a Perl app from Perl/Tk to Java/AWT. The app also
uses a database, which I'm converting from mSQL to MySQL. While
the interface to Tk seems to be about the same 'level' as the
interface to Tk, the language features in Perl (loose typing,
ready access to hashes, easy string manipulation) make Tk easier
to use. I find JDBC vs. DBD::DBI to be similar. Both are a
*real* pleasure to use compared to ctlib, but again Perl wins
out in ease of use because of the language.
I'd have to say that the main advantage that Java has is that
it should be more portable to Windows, given that it would not
require installation of Perl and modules for Tk, DBI, DBD:MySQL
and so on.
I might also give Java an advantage for providing a GUI builder
if I could get Forte to run on a machine with *only* 128 MB of
RAM ;).
Of course, consider that the main reason I'm porting this to Java is
to gain some Java experience. I'm much further along on the curve
WRT Perl and C/C++ than Java.
> Note that none of these factors are specific to servlets, as I have never
> used them. Also, I have never interacted with a database application
> programmatically. I have found it easier to use plain text files, and no one
> has ever given me any feature of database applications which appeals to me. I
> therefore know nothing about database connectivity in Java or Perl.
> All these things said, I personally would choose Perl over Java for any
> application which did not require a GUI.
And for me, perhaps some with a GUI too...
--
Hank Barta White Oak Software Inc.
hbarta@enteract.com Predictable Systems by Design.(tm)
Beautiful Sunny Winfield, Illinois
------------------------------
Date: 8 Dec 2000 18:16:26 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <slrn9329bq.nl1.abigail@tsathoggua.rlyeh.net>
On 7 Dec 2000 02:48:22 GMT, Peter Schuller (peter.schuller@infidyne.com) wrote in comp.lang.perl.misc <URL: news:<90mtpm$3pq$3@hecate.umd.edu>>:
++
++ Proof please? First of all, all indications to me are that Java is on par
++ with C++ (except of course if you use OO more extensively than in your
++ equivalent C++ code). And since when is *perl* or all things
++ blindingly fast?
My experience is that a typical C or C++ program is already finished
when the Java equivalent is still busy allocating the memory so it
can actually start running.
Abigail
------------------------------
Date: 8 Dec 2000 18:25:52 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <slrn9329tg.nl1.abigail@tsathoggua.rlyeh.net>
On Fri, 08 Dec 2000 12:29:45 GMT, Bart Lateur (bart.lateur@skynet.be) wrote in comp.lang.perl.misc <URL: news:<l0l13t860tan0as3fahn8us7hb0ivi07bv@4ax.com>>:
++ Ray Pendergraph wrote:
++
++ >I was parsing and this is
++ >what PERL does best. That is what it was designed for. But don't
++ >underestimate its speed because it's a scripting language.
++
++ Perl is pretty darn fast, because Perl gets compiled (into "bytecode")
++ when the script starts up. The script itself runs at high speed.
Perl is pretty fast if it can spend most of its time executing primitives.
Compared to C, it's quite slow if it needs to execute many different
primitives. Perl typically also uses quite a lot more memory to store
data, which means it swaps earlier, and hence becomes slower.
Abigail
------------------------------
Date: Fri, 08 Dec 2000 18:53:15 GMT
From: Sunil Matta <smatta@acm.org>
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <90ramo$uif$1@nnrp1.deja.com>
In article <90mtpm$3pq$3@hecate.umd.edu>,
peter.schuller@infidyne.com (Peter Schuller) wrote:
> >> No comparison. Perl is blindingly fast. Java is slow.
>
> Huh?
>
> *sigh*
>
> Proof please? First of all, all indications to me are that Java is on
par
> ...
Now, I am not arguing for one language OVER another as I think each
has its strong points. So no flames please. I prefer to choose the
best tool for the task at hand, and not to do everything in c++ etc..
I have worked exclusively with c++ and perl until six months ago, when
I delved into java. While I like the ease and speed of development of
servers and threads with java, I would definitely not rank the SPEED
OF EXECUTION of a java program with that of a c++ program. If you say
that you have studies that show this to be true, could you please let
me know where to get this info !
( do as you say yourself, proof please ! )
for now, I like java and the features the language gives me,
especailly interfaces, and not to mention the hundreds of packages
that come with it, but it is slow and a hog.
> with C++ (except of course if you use OO more extensively than in your
> equivalent C++ code). And since when is *perl* or all things
> blindingly fast?
Perl of all things IS extremely fast. It is interpreted, but I would
rank the language ( again, my own observations so dont ask for
studies ) as one of the fastest scripting languages that I have ever
seen for processing of streams.
Also, I wouldnt exactly build a multithreaded server in perl either !
> Regexp/stringprocessing yes, that's what perl is made for. I highly
doubt
> however that your typical application would be faster in perl than in
Java.
Like I said earlier, for streams and db access.
enough of this, like someone said, this can be in a different
newsgroup...
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 8 Dec 2000 18:29:13 GMT
From: abigail@foad.org (Abigail)
Subject: Re: User quota check via web
Message-Id: <slrn932a3p.nl1.abigail@tsathoggua.rlyeh.net>
On Mon, 04 Dec 2000 00:12:30 GMT, Brcin (info@sz-brkini.si) wrote in comp.lang.perl.misc <URL: news:<OjBW5.41610$GU1.5286@news.siol.net>>:
++ I'm writing a script for my users to see their disk quota via a web
++ browser. I use the Quota module for Perl. But when a user tries to see his
++ quota, he gets "Not privileged".
Of course. Cause the program isn't run as the user, but as the uid of
the webserver.
There are several ways to solve this, each with their own security
problem. None of this has to do with perl, so I won't state them here.
Abigail
------------------------------
Date: 8 Dec 2000 18:30:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Using 'require' and performance gains
Message-Id: <slrn932a60.nl1.abigail@tsathoggua.rlyeh.net>
On Wed, 06 Dec 2000 15:01:21 +0100, Craig Manley (c.manley@chello.nl) wrote in comp.lang.perl.misc <URL: news:<3A2E46B1.4EADBBAE@chello.nl>>:
++
++ I've got a CGI script that uses a class that contains 6 different and
++ huge action handling functions. Only one action is executed per web
++ request. So my thought is: how much performance gain (or maybe loss) can
++ I expect if I place these 6 action handling functions each into seperate
++ files so that the class will load the correct file at runtime using
++ 'require'?
Well, none of course. After all, with your performance problem, you've
cached the compilation of the Perl program, haven't you?
Abigail
------------------------------
Date: Fri, 08 Dec 2000 18:20:27 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Willing to review a 90 line Perl program?
Message-Id: <LD9Y5.35672$3j.3936995@news1.gvcl1.bc.home.com>
In article <3A2E4AB7.886CC0DA@home.com>,
Michael Carman <mjcarman@home.com> writes:
>Philip Garrett wrote:
>> > while( $line = <IN> )
>>
>> You may want something more like this:
>>
>> while( defined($line = <IN>) ) {
>
>FUD. Perl will put a defined() there for you if you didn't do it
>yourself. Either way is fine; explicitly adding the defined() just makes
>things clearer for Perl novices.
But it's worth pointing out that the implicit defined() is only inserted
in perl 5.005 or later. There's still a lot of 5.004s out there.
--
Peter Scott
------------------------------
Date: Fri, 8 Dec 2000 10:11:33 -0600
From: "Neil Trenholm" <neil@alaweb.com>
Subject: Win32::Setupsup - nt.ph needed
Message-Id: <t3221sbil3k03b@corp.supernews.com>
I am using Win32::Setupsup to interact with several Win32 programs - and it
works great - however when I installed it on an older perl setup, it told me
I needed to have nt.ph ...
I looked over that system for it (or nt.h - to use h2ph.bat on) ... with no
luck ... so I looked over severa other setups ... and in the source perl
files ... and CPAN ... and a general search.....
Any help would be appreciated !
Thanks In Advance !
Neil
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 5065
**************************************