[9421] in Perl-Users-Digest
Perl-Users Digest, Issue: 3009 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 30 13:59:37 1998
Date: Tue, 30 Jun 98 10:41:55 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 30 Jun 1998 Volume: 8 Number: 3009
Today's topics:
COMPARING FILES AND CREATE A NEW FILE <lem@ocean.com.au>
Re: COMPARING FILES AND CREATE A NEW FILE <quednauf@nortel.co.uk>
Re: cookie and redirect (Sami Kvykkd)
Re: creating unique session id w/ perl (Mark-Jason Dominus)
Re: creating unique session id w/ perl <rootbeer@teleport.com>
Re: Date calculation formula needed <romeyde@mc0115.mcclellan.af.mil>
Re: Date Calculation Problems. <jc_cann@ix.netcom.com>
Re: Date Calculation Problems. <rootbeer@teleport.com>
Re: DBM problem - can't get a list of all keys (using " <Darrell@Nash.org>
decimal to hex, or binary to hex?? <spence79@pilot.msu.edu>
Re: decimal to hex, or binary to hex?? <rootbeer@teleport.com>
DHCP <robertcr@us.ibm.com>
Re: DHCP <rootbeer@teleport.com>
Die quit working - 5.004_004 <julie@foss.com>
Re: Die quit working - 5.004_004 <rootbeer@teleport.com>
Difference between USE and REQUIRE ? (Phil Taylor)
Re: Difference between USE and REQUIRE ? (brian d foy)
Re: Difference between USE and REQUIRE ? <tchrist@mox.perl.com>
Re: Difference between USE and REQUIRE ? lusol@turkey.cc.Lehigh.EDU
Re: Doublequoting philosophy <mgregory@asc.sps.mot.com>
Re: Download file to browser via application/x-compress <postmaster@castleamber.com>
Re: E-Mail Validation (easy question) (Charlie Stross)
Re: E-Mail Validation (easy question) (Charlie Stross)
Re: E-Mail Validation (easy question) (Larry Rosler)
Re: E-Mail Validation (easy question) (Mike Stok)
Re: Erasing password (Josh Kortbein)
Re: eval (Data::Dumper->dump($cool, ...'limit?')); <hck@formalsys.ca>
executing perl scripts in browser without HTTP server abhidon@hotmail.com
Re: executing perl scripts in browser without HTTP serv <quednauf@nortel.co.uk>
Re: executing perl scripts in browser without HTTP serv <perlguy@inlink.com>
Re: Exit status from system() not what I expected (and <mgregory@asc.sps.mot.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Jun 1998 13:45:04 GMT
From: "Minh Le" <lem@ocean.com.au>
Subject: COMPARING FILES AND CREATE A NEW FILE
Message-Id: <01bda29b$25312410$51eb0ccb@gfg00056>
Hi,
I'm new to perl. I'd like to write a perl script to compare two files
which normally have 5 to 10 text lines in each file. IF they are
different, create a new file which only keeps the difference. Please help.
Regards
lem@ocean.com.au
------------------------------
Date: Sun, 28 Jun 1998 15:19:22 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: COMPARING FILES AND CREATE A NEW FILE
Message-Id: <359650EA.BCF5D641@nortel.co.uk>
Minh Le wrote:
>
> Hi,
> I'm new to perl. I'd like to write a perl script to compare two files
> which normally have 5 to 10 text lines in each file. IF they are
> different, create a new file which only keeps the difference. Please help.
A good way to do that is to read the files into arrays. From there on you can go
to the Perlfaq:
perlfaq4
|-> data manipulation
|-> Data: Arrays
| -> How do I compute the difference of two arrays?
How do I compute the intersection of two arrays?
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 29 Jun 1998 06:41:16 GMT
From: samik@uta.fi (Sami Kvykkd)
Subject: Re: cookie and redirect
Message-Id: <6n7cuc$fek$1@baker.cc.tut.fi>
According to Jonathan Feinberg :
>due@murray.fordham.edu (Allan M. Due) writes:
>
>> The question asked to generate a cookie and then redirect the person
>> to a new site, all in one script.
>
>> getprint('http://www.amazon.com');
>
>That's not exactly "redirecting"...
(...)
> print header( -COOKIE => $c,
> -REFRESH => '0; URL=http://www.perl.com',
> );
The above method could cause problems with browser's back function. I
have used this method succesfully:
$cookie=$query->cookie(-name=>'myname'
-value=>'myvalue',
-expires=>'+1M',
-path=>'/',
);
print $query->redirect(-location=>$new_location_url,
-cookie=>$cookie);
--
Sami Kvykkd http://www.iki.fi/~samik/
"Blink your eyelids periodically to lubricate your eyes."
- HP "Environmental, Health & Safety Handbook for Employees.", page 16.
------------------------------
Date: 28 Jun 1998 07:09:15 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: creating unique session id w/ perl
Message-Id: <6n588r$5pd$1@monet.op.net>
Keywords: Aides avid Calgary probity
In article <Pine.GSO.3.96.980627151906.19372C-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
>> $cart_id = int(rand(10000000));
>
>That won't necessarily be able to produce 10_000_000 possible integers on
>many (most?) systems. It should probably be something more like this.
>
> $cart_id = sprintf "%04d%03d", rand(10_000), rand(1000);
What are you thinking of? If the random number generator has only 16
bits of state, then running it twice isn't going to generate a larger
output set than running it once; just the opposite, in fact. Or is
there some other problem that I'm missing that you were trying to work
around here?
------------------------------
Date: Sun, 28 Jun 1998 20:01:00 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: creating unique session id w/ perl
Message-Id: <Pine.GSO.3.96.980628125301.7277D-100000@user2.teleport.com>
On 28 Jun 1998, Mark-Jason Dominus wrote:
> In article <Pine.GSO.3.96.980627151906.19372C-100000@user2.teleport.com>,
> Tom Phoenix <rootbeer@teleport.com> wrote:
> >> $cart_id = int(rand(10000000));
> >
> >That won't necessarily be able to produce 10_000_000 possible integers on
> >many (most?) systems. It should probably be something more like this.
> >
> > $cart_id = sprintf "%04d%03d", rand(10_000), rand(1000);
>
> What are you thinking of? If the random number generator has only 16
> bits of state, then running it twice isn't going to generate a larger
> output set than running it once; just the opposite, in fact. Or is
> there some other problem that I'm missing that you were trying to work
> around here?
Good point. I was (possibly incorrectly) assuming that a generator may
have more bits of state than output bits. For example, the generator on
SunOS has period 2**32 but only returns 15 random bits each time it's
called. So my method shouldn't be significantly _worse_ than the original,
but you're right that it may well be no better, either.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 29 Jun 1998 19:17:14 +0000
From: Derek Romeyn <romeyde@mc0115.mcclellan.af.mil>
Subject: Re: Date calculation formula needed
Message-Id: <3597E83A.E7348231@mc0115.mcclellan.af.mil>
Thanks for the suggestions. One question on this one though. I am
probably reading this wrong.
What would happen then with 8013 and 0132? Wouldn't that end up
comparing 1998 to 1990 instead of 2000?
> use Date::Calc qw(:all);
>
> my $annoying = 8013;
>
> my ($year,$day) = $annoying =~ /^(\d+)(\d{3})$/;
>
> $year += 1990;
>
> $min = Date_to_Days(1998,6,20);
> $max = Date_to_Days(1999,1,1); # or whatever you need...
>
> $test = Date_to_Days($year,1,1) + $day - 1;
>
--
Derek W Romeyn romeyde@calweb.com
I wish I could say everything there was to say in one word. I hate
all the things that can happen between the beginning of a sentence
and the end. -- Leonard Cohen, The Favourite Game
------------------------------
Date: Sun, 28 Jun 1998 23:03:13 -0600
From: Jeffery Cann <jc_cann@ix.netcom.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Date Calculation Problems.
Message-Id: <35972011.8D6FB6A0@ix.netcom.com>
Tom Phoenix wrote:
>
> On Tue, 23 Jun 1998, Col wrote:
>
> > I've looked through the faq's, used dejanews and searched on lots of
> > perl pages the answer seems to be to use date::Manip.
>
> > The problem is that my host can't (they are in some partnership thing
> > with 7thgate???) install the mod, I tried and obviously I don't have the
> > correct permissions setup to install it.
>
> If your sysadmin can't install software, get a new one. But section eight
> of the FAQ has information on keeping your own directory for modules. Good
> luck!
>
>From Perl FAQ8:
How do I keep my own module/library directory?
When you build modules, use the PREFIX option when generating Makefiles:
perl Makefile.PL PREFIX=/u/mydir/perl
then either set the PERL5LIB environment variable before you run scripts that use the
modules/libraries
(see the perlrun manpage) or say
use lib '/u/mydir/perl';
See Perl's the lib manpage for more information.
Question:
--------
If I only have ftp access to a remote web server is it still possible to make my own
module?
Thanks
+--------------------------+-------------------------+
| Jeffery Cann | This message sent from |
| JCDS Managing Developer | a Linux Workstation |
+--------------------------+-------------------------+
http://www.netcom.com/~jcds
------------------------------
Date: Mon, 29 Jun 1998 05:58:48 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Date Calculation Problems.
Message-Id: <Pine.GSO.3.96.980628225021.21917J-100000@user2.teleport.com>
On Sun, 28 Jun 1998, Jeffery Cann wrote:
> If I only have ftp access to a remote web server is it still possible to
> make my own module?
If you can merely add and remove files, you're not going to be able to use
_any_ software; you have to have the ability to run software, after all.
But if you can install and run software, what's stopping you? Can't you
install something which lets you log in remotely? :-)
I'll fall back on my original advice. If your system administrator can't
install software, get a new one. After all, what good is a sysadmin who
can't install software?
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 29 Jun 1998 19:57:55 -0600
From: "Darrell Nash" <Darrell@Nash.org>
Subject: Re: DBM problem - can't get a list of all keys (using "keys" nor "each")
Message-Id: <35984629.0@news.cadvision.com>
Just so you know, I found a way around the problem... since DBM ".pag" files
still store the data in its original form (along with binary stuff around
the records), it was possible to parse out the data I needed. Not a nice
solution, but I was desparate.
Darrell Nash wrote in message <3593d211.0@news.cadvision.com>...
>Hello folks,
>
>I've written a relatively simple client database using Perl's DBM features,
>which was working great for a week or so. I have over 45,000 clients in
the
>database, which shouldn't be a huge problem from what I understand with
DBM.
>Here's the problem:
>
>When I attempt to traverse the entire database, one record at a time (with
a
>while(($key, $value) = each %CLIENTS)), it gets caught in an endless loop.
>With further investigation, it is actually only getting about 5000 clients
>into the database when the "each" function iterates back to some point
prior
>and starts again (not the beginning - probably between client# 500 and 1000
>in the list). A related problem occurs when I use the "keys" or "values"
>function - a memory overflow occurs (even on a Solaris machine with 300+
>megs of ram). It would seem it too is caught in the loop.
>
>The retrieval, addition, modification, and deletion of single records works
>fine. It's only when I try to traverse the whole database that I encounter
>this problem. It definately sounds like a DBM problem more than Perl, but
I
>figured I'd try all possibilities. I make sure that nothing else is
>accessing the file when I try to traverse it, but that doesn't seem to make
>a difference. I fear it is corrupted somehow, but I really need to extract
>as much data as I can, or I'll have 45,000 very unhappy people.
>
>Any help would be greatly appreciated.
>
>Darrell Nash
>nash@freerealtime.com
------------------------------
Date: Tue, 30 Jun 1998 01:24:00 -0400
From: "AJS" <spence79@pilot.msu.edu>
Subject: decimal to hex, or binary to hex??
Message-Id: <6n9sf6$isv$1@msunews.cl.msu.edu>
Is there an easy way to go from a decimal representation to a hex, or
decimal to binary to hex? I just can;t seem to get it. Any help would be
great.
AJS
------------------------------
Date: Tue, 30 Jun 1998 05:53:14 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: decimal to hex, or binary to hex??
Message-Id: <Pine.GSO.3.96.980629225145.17225R-100000@user2.teleport.com>
On Tue, 30 Jun 1998, AJS wrote:
> Is there an easy way to go from a decimal representation to a hex, or
> decimal to binary to hex?
That last doesn't make much sense. Why would you want to convert from
decimal to binary if you really want to convert that to hex? But you
proably want the pack/unpack functions, or maybe (s)printf. Check the
perlfunc manpage. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 29 Jun 1998 12:55:10 +0100
From: "Robert C. Rekas" <robertcr@us.ibm.com>
Subject: DHCP
Message-Id: <3597809E.B993524A@us.ibm.com>
Is there DHCP perl package?
thanks
------------------------------
Date: Mon, 29 Jun 1998 20:47:56 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: DHCP
Message-Id: <Pine.GSO.3.96.980629134648.28620E-100000@user2.teleport.com>
On Mon, 29 Jun 1998, Robert C. Rekas wrote:
> Is there DHCP perl package?
I think you mean 'module'.
$DHCP::foo = "There's a DHCP package now!"; # :-)
If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-) Hope this helps!
http://www.perl.org/CPAN/
http://www.perl.com/CPAN/
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 29 Jun 1998 18:40:30 GMT
From: "Julie Schneider" <julie@foss.com>
Subject: Die quit working - 5.004_004
Message-Id: <ycRl1.995$r73.998692@news.teleport.com>
For some reason, the die statement quit working in any program I run, even
those I have downloaded from elsewhere. It was working fine last week. Has
anyone come across this, what died???
Any help appreciated. Thanks.
------------------------------
Date: Mon, 29 Jun 1998 21:31:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Die quit working - 5.004_004
Message-Id: <Pine.GSO.3.96.980629142853.28620K-100000@user2.teleport.com>
On Mon, 29 Jun 1998, Julie Schneider wrote:
> For some reason, the die statement quit working in any program I run,
> even those I have downloaded from elsewhere. It was working fine last
> week. Has anyone come across this, what died???
die died? :-)
If this doesn't do what it should, you should re-install perl.
perl -e 'die "Well, this died"'
If that works, could you show an example of what you mean? Please strive
to keep your example small (say, under half a dozen lines). Thanks!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 29 Jun 1998 18:23:02 GMT
From: phil@ackltd.demon.co.uk (Phil Taylor)
Subject: Difference between USE and REQUIRE ?
Message-Id: <3597db70.725311@news.demon.co.uk>
Can anyone explain the difference between USE and REQUIRE?
I want to define a library of common procedures which will be
contained within a single file, which of the two statements above
should I use?
Thanks
Phil
------------------------------
Date: Mon, 29 Jun 1998 14:36:14 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Difference between USE and REQUIRE ?
Message-Id: <comdog-ya02408000R2906981436140001@news.panix.com>
Keywords: from just another new york perl hacker
In article <3597db70.725311@news.demon.co.uk>, phil@ackltd.demon.co.uk (Phil Taylor) posted:
>Can anyone explain the difference between USE and REQUIRE?
sri[6] perldoc -f use
=item use Module LIST
=item use Module
=item use Module VERSION LIST
=item use VERSION
Imports some semantics into the current package from the named module,
generally by aliasing certain subroutine or variable names into your
package. It is exactly equivalent to
BEGIN { require Module; import Module LIST; }
except that Module I<must> be a bareword.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>
------------------------------
Date: 29 Jun 1998 18:58:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Difference between USE and REQUIRE ?
Message-Id: <6n8o4d$cqf$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
phil@ackltd.demon.co.uk (Phil Taylor) writes:
:Can anyone explain the difference between USE and REQUIRE?
Is there some part of the standard definitions in perlfunc
that you find unclear?
:I want to define a library of common procedures which will be
:contained within a single file, which of the two statements above
:should I use?
I don't know. It depends on what you're doing. Probably use.
Have you consulted perlmod?
Here are the deltas between the various inclusion constructs:
1) do $file is like eval `cat $file`, except the former:
1.1: searches @INC.
1.2: bequeaths an *unrelated* lexical scope on the eval'ed code.
2) require $file is like do $file, except the former:
2.1: checks for redundant loading, slipping already loaded files.
2.2: raises an exception on failure to find, compile, or execute $file.
3) require Module is like require "Module.pm", except the former:
3.1: translates each "::" into your system's directory separator.
3.2: primes the parser to disambiguate class Module as an indirect object.
4) use Module is like require Module, except the former:
4.1: loads the module at compile time, not run-time.
4.2: imports symbols and semantics from that package to the current one.
--tom
--
Besides, REAL computers have a rename() system call. :-)
--Larry Wall in <7937@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 29 Jun 1998 20:48:31 GMT
From: lusol@turkey.cc.Lehigh.EDU
Subject: Re: Difference between USE and REQUIRE ?
Message-Id: <6n8uiv$136m@fidoii.cc.Lehigh.EDU>
Tom Christiansen <tchrist@mox.perl.com> wrote in article <6n8o4d$cqf$2@csnews.cs.colorado.edu> :
>
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc,
> phil@ackltd.demon.co.uk (Phil Taylor) writes:
>:Can anyone explain the difference between USE and REQUIRE?
>
>Is there some part of the standard definitions in perlfunc
>that you find unclear?
>
>:I want to define a library of common procedures which will be
>:contained within a single file, which of the two statements above
>:should I use?
>
>I don't know. It depends on what you're doing. Probably use.
>Have you consulted perlmod?
>
>Here are the deltas between the various inclusion constructs:
Tom/I came up with this once upon a time:
http://www.perl.com/CPAN-local/doc/FMTEYEWTK/use_vs_require
------------------------------
Date: 29 Jun 1998 10:33:00 +0930
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Re: Doublequoting philosophy
Message-Id: <r83ecpggu3.fsf@asc.sps.mot.com>
lr@hpl.hp.com (Larry Rosler) writes:
> In article <3594d7c9.13453427@news.appman.com>, Robert Friberg
> <robban@insult.com> says...
> >
> > Many perl hackers use double quotes when they don't have to.
> >
> > The documentation is full of stuff like:
> >
> > print "Password: ";
> > "ab" =~ /a(.*)b/;
> > die "/etc/games is no good";
> > die "/etc/games is no good, stopped";
> > require "ioctl.ph";
> >
> > Isn't there a penalty of at least one scan on those strings?
> > Please don't tell me the penalty is so insignificant that it
> > doesn't matter because that's not the point.
>
> You're right. That's not the point.
>
> A good point is that using '...' consistently when there is no
> interpolation immediately draws attention to "..." when there *is*
> (should be) interpolation (or interpretation of escape sequences other
> than \\ or \').
>
> I've switched my null strings from '' to "" though, because it's too easy
> to eyeball '' as ".
The only sad thing is that perl-mode (or my version/setup of it)
doesn't fontify '' strings :-(
Martin.
------------------------------
Date: 29 Jun 1998 20:01:15 GMT
From: "John Bokma" <postmaster@castleamber.com>
Subject: Re: Download file to browser via application/x-compress
Message-Id: <01bda398$f9073ec0$02521e0a@tschai>
RHooD <chat-world@gmx.net> wrote in article
<3596f585.10350993@news.infopool.com>...
> Hi !
>
> I have a big problem !!!
>
> I have written a script who download a file from a remote server,
> but when i click in a browser on the href, in the savebox ,
> the name of the perlscript are standing !!!!
>
> how can i tell the browser that the filename is xxx.zip ?????
Try: http://www.yoursite/cgi-bin/yourscript/xxx.zip
See: http://computerdog.com/CGI_MetaFAQ.html
And go to the CGI FAQ, this is explained in
22.How can I control the default filename when downloading a file via CGI?
(BTW I hope this helps more than some of the other "smartass" replies)
John
--
------------------------------------------------------------------
C A S T L E A M B E R Software Development (Java/Perl/C/CGI)
http://www.castleamber.com/ john@castleamber.com
NEW: http://www.binaries.org/ Guide to Program Binaries & Pictures
------------------------------
Date: Tue, 30 Jun 1998 12:46:06 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: E-Mail Validation (easy question)
Message-Id: <slrn6phnh4.23c.charlie@cs.ed.datacash.com>
In the name of Kibo the Compassionate, the Merciful,
on Mon, 22 Jun 1998 22:38:40 +1000,David Hamilton
the supplicant <ozslot@alphalink.com.au> implored:
> I am very stupid at PERL and I have the following code to do
>something if an E-Mail address exists and is in valid format:
>
>if ($INPUT{'email'}) {
> if ($INPUT{'email'} =~ /(.*)@(.*)/) {
^^^^^^^^^^^^^^
The above-indicated regular expression is broken. A dot means "one of
any character"; an asterisk means "zero or more occurences of the preceeding
atom". So in a degenerate case, you may get a positive result when
$INPUT{email} contains a single ampersand.
(I think what you're looking for is /.+@.+/, but even this is dubious --
I suspect I'm about to be drowned out by Tom Christiansen chanting "there
is no way to verify an email address!" with a chorus of SMTP hackers
chanting RFCs in the background.)
> }
>}
>
>My easy question is: how do I reverse this check (without simply adding
>an ELSE type thing) so that it will do something if $INPUT{'email'}
>doesn't exist or doesn't conform to: =~ /(.*)@(.*)/)
Yup:
if (foo) {
statement1;
} else {
statement2;
}
You really, _really_, ought to purchase and read one of the numerous perl
books out there.
-- Charlie
"One World. One Web. One Program."
-Microsoft promotional advertisement
"Ein Volk, ein Reich, ein Fuhrer!"
-Adolf Hitler
------------------------------
Date: Tue, 30 Jun 1998 12:59:03 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: E-Mail Validation (easy question)
Message-Id: <slrn6pho9d.23c.charlie@cs.ed.datacash.com>
>>My easy question is: how do I reverse this check (without simply adding
>>an ELSE type thing) so that it will do something if $INPUT{'email'}
>>doesn't exist or doesn't conform to: =~ /(.*)@(.*)/)
>
>Yup:
>
>if (foo) {
> statement1;
>} else {
> statement2;
>}
Whoops, my mistake. 0 out of 10 for reading comprehension!
The ! (NOT) operator negates an expression. So ...
if (foo) { ... } else { statement }
is equivalent to:
if (!foo) {statement} else { ... }
(only less efficient).
See the perlop man page.
-- Charlie
------------------------------
Date: Tue, 30 Jun 1998 07:08:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: E-Mail Validation (easy question)
Message-Id: <MPG.1002914361a86173989703@nntp.hpl.hp.com>
In article <slrn6pho9d.23c.charlie@cs.ed.datacash.com> on Tue, 30 Jun
1998 12:59:03 GMT, Charlie Stross <charlie@antipope.org> says...
> >>My easy question is: how do I reverse this check (without simply adding
> >>an ELSE type thing) so that it will do something if $INPUT{'email'}
> >>doesn't exist or doesn't conform to: =~ /(.*)@(.*)/)
...
> if (foo) { ... } else { statement }
>
> is equivalent to:
>
> if (!foo) {statement} else { ... }
>
> (only less efficient).
Not at all, after a microsecond or two in the compilation phase to parse
one extra token!
One might also point out the !~ binding operator as the negation of =~.
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 30 Jun 1998 14:42:59 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: E-Mail Validation (easy question)
Message-Id: <6nathj$jaq@news-central.tiac.net>
In article <slrn6pho9d.23c.charlie@cs.ed.datacash.com>,
Charlie Stross <charlie @ nospam . antipope . org> wrote:
>Whoops, my mistake. 0 out of 10 for reading comprehension!
>
>The ! (NOT) operator negates an expression. So ...
>
>if (foo) { ... } else { statement }
>
>is equivalent to:
>
>if (!foo) {statement} else { ... }
>
>(only less efficient).
Of course, perl has unless so you can say
unless (foo) {
statement
}
which I find easier to read than if and not combinations (especially if
the condition is complicated.)
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 30 Jun 1998 15:09:09 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Erasing password
Message-Id: <6nav2l$kp7$1@news.iastate.edu>
womlake@zip.com.au wrote:
: Here is what I want to do: (I've seen it done at several sites)
: Step 1 ... Enter a password, submit it and proceed to next web page
: Step 2 ... Press the back button on browser to return to password page
: BUT with the password having been erased.
: Can this be accomplished with Perl ?
: Also is it possible using Perl to prevent someone from using the BACK
: button to retrace steps in cgi scripted pages, thus preventing other
: users from altering form settings ?
: Thanks,
: Warren
Disabling the back button is sometimes easily accomplished with a stupid
Javascript hack. Surely it's in all those nifty stupid-JS-tricks web
pages.
Josh
--
_________________________________________________________
I do not trust your bitch.
- Frederich Nietzche, in _Also Sprach Zarathustra_
------------------------------
Date: Tue, 30 Jun 1998 11:08:59 -0300
From: Colin Kilburn <hck@formalsys.ca>
Subject: Re: eval (Data::Dumper->dump($cool, ...'limit?'));
Message-Id: <3598F17B.FA18F643@formalsys.ca>
Colin Kilburn wrote:
>>>
>>> Tom Phoenix wrote:
>>
>>> On Sat, 27 Jun 1998, Colin Kilburn wrote:
>>>
>>>> What is the size of the largest piece of code that can
>>>> be evaled?
>>>
>>> You're talking about eval of a string, right? Like most things in
>>> Perl,there's no hard limit built into eval.
>>> If you can fit it into a string and have enough memory left
>>> to process it, you should be able to eval it.
>>>
>>> Of course, that's not likely to be the best way to solve whatever
>>> problem you might be having... :-)
>>>
>>
>> Why would you say that ?
> eval of a string, especially a very large string, is hardly ever needed
> (or desirable) in modern Perl programming. (Most languages don't have
> this sort of feature, and nobody > > misses it... :-) In this case,
> perhaps it would be better to save the data to a file as a library and
> require it?
> Or, instead of having one large text form of a data structure,
> perhaps you could use a number of smaller chunks representing its elements.
> Having said that, one big eval _may_ be the right way to solve your
> particular problem. But I'd encourage you to think about it some more.
> Hope this helps!
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
The Data::Dumper section in the Panther book only mentioned 'eval'
restoration but now I see that a 'require' does an eval, cool, thanks!
Is this what you mean?
Is there any thing else I am missing in this persistence thing?
Thanks,
C.
Test example
##### Part 1 - the driver #####
##### reqD.perl #####
#!/usr/local/bin/perl5 -w -- # -*-Perl-*-
use strict;
my $cust = require "data.pl"; # evaluate data from Data::Dumper
# prove the require worked and restored the cust object with data.
print "The cust->{DBFDTnextKey} is $cust->{DBFDTnextKey}\n";
print "DONE\n";
__END__
##### Part 2 - Data::Dumper generated data file
##### data.pl #####
$cust = bless( {
DBFDTnextKey => 1,
DBFDT => {
'0' => [
'FDT',
'FILE_003_DB_199',
'/FDT/FILE_X',
199,
3,
4
]
},
}, 'Customer::Customer' );
>>
>>> --
>>> Tom Phoenix Perl Training and Hacking Esperanto
>>> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
--
=================================================================
= Colin Kilburn - FSI Software Developer - hck@formalsys.ca =
= Fredericton NB - phone 506 433 0300 - fax 506 433 0300 =
=================================================================
------------------------------
Date: Tue, 30 Jun 1998 11:52:55 GMT
From: abhidon@hotmail.com
Subject: executing perl scripts in browser without HTTP server
Message-Id: <6najin$hbe$1@nnrp1.dejanews.com>
hi, Is there any way I can run perl files, in a browser from anywhere? I
want my browser to execute the perl files, without the HTTP server being
present. Can perl files run the way java binaries r run?
TIA
abhi
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 30 Jun 1998 13:24:51 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: executing perl scripts in browser without HTTP server
Message-Id: <3598D913.509556F1@nortel.co.uk>
abhidon@hotmail.com wrote:
>
> hi, Is there any way I can run perl files, in a browser from anywhere (me - without http server)?
Not of my knowledge. You can use the command line.
But, I still hope that one day someone grabs the Netscape source code and embeds
the Perl interpreter!
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Tue, 30 Jun 1998 13:12:22 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: executing perl scripts in browser without HTTP server
Message-Id: <3598E436.C2B8EEA@inlink.com>
Unfortunately for you, Perl runs on the server side, and not the browser
side like Java. So, your browser (at least in this generation), will
not be able to "execute Perl".
I say "for you" above because I like keeping Perl on the server side.
You have a few choices though.
1) Install a web server on your system and use it.
B) Try out Perl Builder from Solutionsoft (http://www.solutionsoft.com
Hope this helps!
Brent
(Don't you hate it when people mix numbers/letters in ordered lists?)
------------------------------
Date: 29 Jun 1998 10:22:42 +0930
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Re: Exit status from system() not what I expected (and other doc probs)
Message-Id: <r867hlghb9.fsf@asc.sps.mot.com>
allbery@kf8nh.apk.net (Brandon S. Allbery KF8NH) writes:
> Also sprach ced@bcstec.ca.boeing.com (Charles DeRykus) (<Ev14w2.9r0@news.boeing.com>):
> +-----
> | system launchs another shell apparently. I'm not sure
> | why this happens in the case of yes though.
> +--->8
>
> He included a redirection, therefore /bin/sh was used to run it.
Right. This is something that it not at all clear in the current
documentation, but Tom has added into the upcoming version, and it
helps alot to know it!
Martin.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 3009
**************************************