[9517] in Perl-Users-Digest
Perl-Users Digest, Issue: 3113 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 10 05:07:22 1998
Date: Thu, 9 Jul 98 22:00:27 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 9 Jul 1998 Volume: 8 Number: 3113
Today's topics:
"CGI" What? How? Why? rups_is_@hotmail.com
Re: "CGI" What? How? Why? (brian d foy)
Re: -w on production code (was Re: better way of gettin <rra@stanford.edu>
Re: -w on production code (was Re: better way of gettin <tchrist@mox.perl.com>
Re: Abigail - Another Question for you. (Ronald J Kimball)
Announcing scripts on c.l.p.a [was: Re: new charter and (William R. Ward)
Bug? shift( split(' ',$_)); won't compile. <"postmaster"@[127.0.0.1]>
Re: Bug? shift( split(' ',$_)); won't compile. (Ronald J Kimball)
Re: Bug? shift( split(' ',$_)); won't compile. (Andre L.)
Re: Creating files problems. (CGI-Unix) (brian d foy)
Re: delete key from array <mpersico@erols.com>
Re: Directory Names with Perl for NT (Tye McQueen)
Re: environment-vars (brian d foy)
Re: environment-vars <*@qz.to>
Re: environment-vars (Martien Verbruggen)
Re: Get IP Address for Server Name <"postmaster"@[127.0.0.1]>
How can you encrypt a CGI script on a server so it will <jpl@lanl.gov>
Re: How to use 'system ("...")' on WIN32. (Tye McQueen)
need to code a delete function (Doug Perry a.k.a drperry)
Re: new charter and moderator for comp.lang.perl.announ (William R. Ward)
Re: new charter and moderator for comp.lang.perl.announ (Martien Verbruggen)
Re: Pattern matching problems <rick.delaney@shaw.wave.ca>
Re: pattern matching results into an array (brian d foy)
Re: pattern matching results into an array <*@qz.to>
Perl OO for dummies [Was: Oh man, DO I love Perl ! (Ref <mpersico@erols.com>
Re: Question I can't find an answer for. (brian d foy)
Re: Recognizing BACK and FORWARD button-visits <rra@stanford.edu>
Re: Silly things to do in Perl (or: is that Laptop wate (Ronald J Kimball)
Single vs Double Quotes [was: Re: Abigail - Another Que (William R. Ward)
Re: Single vs Double Quotes [was: Re: Abigail - Another <zenin@bawdycaste.org>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 10 Jul 1998 02:53:12 GMT
From: rups_is_@hotmail.com
Subject: "CGI" What? How? Why?
Message-Id: <6o3vmo$b92$1@nnrp1.dejanews.com>
Hello, I am completely new to CGI. All I know about CGI is that its some
kinda program that takes information "data" from internet and e-mails the
data to you or stores it somewhere. I am trying to make my own guest-book. I
know I can get free guest-books from many different sites. But I do wanna
make my own. I know HTML and I can design the guest-book with FORMS within
HTML. But I don't know how to get the data that the user inputs and get it to
e-mail it to me or to store on my web-space. In short, I don't know what to
say for the "ACTION" command. Can anybody tell me where can I start from? And
how can I start?
Please reply at "rups_is_@hotmail.com"
Thanks,
Rups
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 09 Jul 1998 23:32:48 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: "CGI" What? How? Why?
Message-Id: <comdog-ya02408000R0907982332480001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6o3vmo$b92$1@nnrp1.dejanews.com>, rups_is_@hotmail.com posted:
>Hello, I am completely new to CGI. All I know about CGI is that its some
>kinda program that takes information "data" from internet and e-mails the
>data to you or stores it somewhere. I am trying to make my own guest-book. I
>know I can get free guest-books from many different sites. But I do wanna
>make my own. I know HTML and I can design the guest-book with FORMS within
>HTML. But I don't know how to get the data that the user inputs and get it to
>e-mail it to me or to store on my web-space. In short, I don't know what to
>say for the "ACTION" command. Can anybody tell me where can I start from? And
>how can I start?
see the sig :)
--
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 Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
Date: 09 Jul 1998 20:41:10 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <m3r9zunzjd.fsf@windlord.Stanford.EDU>
Craig Berry <cberry@cinenet.net> writes:
> Just possibly, some questions would not get asked, as people would be
> forced to see the warnings explaining why their programs aren't behaving
> as they expect.
But. Please do not make Perl do things that annoy those of us who know
how to use it in the name of making it easier for those who do not know
how to use it. Down that path lies strong typing, mandatory warnings,
bondage and discipline languages, and C++.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 10 Jul 1998 04:44:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o467q$4v9$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Lloyd Zusman <ljz@asfast.com> writes:
:I, for one, think that it's a postively wonderful idea!
That would be horrible. Scripts would lose portability
if the run-time environment were so unpredictable.
--tom
--
"It's ironic that you would use a language as large as English to express
so small a thought."
--Larry Wall
------------------------------
Date: Thu, 9 Jul 1998 23:55:06 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Abigail - Another Question for you.
Message-Id: <1dbx9ju.sgth885q89n8N@bay2-51.quincy.ziplink.net>
Abigail <abigail@fnx.com> wrote:
> Indeed. Please tell your newsadmin to honour cancels, as the article was
> cancelled.
Is that why it didn't show up? Unfortunately, you didn't cancel Tad's
reply. ;-)
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 09 Jul 1998 20:05:01 -0700
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Announcing scripts on c.l.p.a [was: Re: new charter and moderator for comp.lang.perl.announce]
Message-Id: <waa90m24d9e.fsf_-_@ese.UCSC.EDU>
First a few words up top which I would like everyone in this debate to
think about:
I think the most important factor that this boils down to is: what is
the target audience of c.l.p.a? I think it is Perl programmers, and
so announcements of interest to Perl programmers should be the only
thing accepted. A script that happens to be written in Perl is not of
direct interest to Perl programmers. If you expand the target
audience to include all people who use Perl software, then yes you
would want to include all scripts. Maybe if we can achieve some
consensus on the target audience, we can ascertain what the charter
should say to best help that audience.
Now on to my comments about Nathan's post:
Nathan Torkington <gnat@frii.com> writes:
> mgjv@comdyn.com.au (Martien Verbruggen) writes:
> > Please. Not that. We'll be inundated with announcements of every CGI
> > program that is written in Perl.
>
> Yes, quite possibly. Of course, they would be marked [CGI] on the
> subject line, so you could automatically kill them by subject. Then
> again, the Perl newsgroups have such an enshrined "no damn CGI" ethos
> that it wouldn't be out of place to say "no damn CGI for
> comp.lang.perl.announce". After all, there are already other
> newsgroups for That Sort of Thing.
Programs written in Perl belong on comp.lang.perl.announce in the same
way that programs written in C would belong on comp.lang.c.announce
(if such a group existed, anyway). I believe it should only be
accepted for c.l.p.a if it is of benefit to perl *programmers* - a new
CGI.pm would be OK, but a new shopping cart utility wouldn't (unless
it was a shopping cart library that could be used by other Perl
programs).
> I just don't want to refuse announcements of scripts. Don't forget
> that the scripts section of CPAN will soon be reborn. I want to see
> uploads announced on c.l.p.a. This doesn't mean that we can restrict
> announcements to only CPAN scripts, though. That would rule out
> commercial software like Tom Boutell's PerlMud, for instance.
It might be a good idea to have some kind of automated "what's new in
CPAN" report that gets posted to c.l.p.a, perhaps weekly or
semimonthly? It could contain a short description (up to one or two
paragraphs) of each new upload along with the author and perhaps a URL
where more information could be obtained.
> > Imagine comp.lang.c.moderated getting advertisements
> > for every program that uses C or interfaces with C in some way.
>
> I think this argument is bogus. First, .moderated is not .announce.
> They have different raisons d'etre. Second, even comparing .moderated
> to .moderated, the charter for comp.lang.perl.moderated doesn't seem
> to forbid such advertisements. Third, Perl is not C--Perl is not used
> as widely as C, and shooting down Perl software announcements because
> of the number of C programs seems to be faulty argumentation.
Hmm, I didn't even notice this argument until I had already made it
myself above. If there were a comp.lang.c.announce newsgroup, woudl
you want to see every C program listed there??
> I think that ruling out script announcements entirely would be a loss
> to the community, in the end. Currently, c.l.p.a does permit scripts.
> Merlyn's improvised behaviour is to reject scripts unless they're
> CPANned. If the author refuses to CPAN it, Merlyn then gives in and
> allows the announcement anyway. For instance, txt2pdf was announced
> in c.l.p.a, despite costing $10 for a license and not being on CPAN.
>
> In summary, I don't mind saying "no CGI". I do mind saying "no
> scripts".
I would like to see scripts *only* if they're CPANned, and even then
as a digest - but Perl libraries and modules should always be
welcomed.
--Bill.
--
William R Ward Bay View Consulting http://www.bayview.com/~hermit/
hermit@bayview.com 1803 Mission St. #339 voicemail +1 408/479-4072
hermit@cats.ucsc.edu Santa Cruz CA 95060 USA pager +1 408/458-8862
PGP Key 0x2BD331E5; Public key at http://www.bayview.com/~hermit/pubkey.txt
-----------------------------------------------------------------------------
"Language is a virus from outer space." --William S. Burroughs
------------------------------
Date: Thu, 09 Jul 1998 22:26:09 -0500
From: postmaster <"postmaster"@[127.0.0.1]>
Subject: Bug? shift( split(' ',$_)); won't compile.
Message-Id: <6o41mn$aud$1@farstar.frb.gov>
(Note: I spent 20 minutes at CPAN and perl.com trying to finds a list of
bugs before I posted this - couldn't find it. Any help on this would be
appreciated. If responding via email, please use "bobn at interaccess
dot com".)
Program is:
#!/usr/local/bin/perl -w
use diagnostics;
@junk = (
"str00 str01 str02",
"str10 str11 str12",
"str20 str21 str22",
);
foreach (@junk) {
@junk2 = split(' ',$_);
$junk = shift @junk2;
print "$junk\n";
}
exit;
__END__
foreach (@junk) {
$junk = shift( split(' ',$_));
print "junk\n";
print "@junk2\n";
}
Running this as is produces:
"
str00
str10
str20
"
If I comment the __END__, running this produces:
"
Type of arg 1 to shift must be array (not split) at perl.shift.prob line
23, near "))"
Execution of perl.shift.prob aborted due to compilation errors (#1)
(F) The final summary message when a Perl compilation fails.
Uncaught exception from user code:
Execution of perl.shift.prob aborted due to compilation errors.
"
Is this actually a bug or am I missing something?
(Oh, yeah, running
"
/usr/local/bin/perl -v
"
produces
"
This is perl, version 5.004_03
Copyright 1987-1997, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.
"
)
------------------------------
Date: Fri, 10 Jul 1998 00:05:56 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Bug? shift( split(' ',$_)); won't compile.
Message-Id: <1dbxc0i.g8t71r1wv6053N@bay2-51.quincy.ziplink.net>
postmaster <"postmaster"@[127.0.0.1]> wrote:
> (Note: I spent 20 minutes at CPAN and perl.com trying to finds a list of
> bugs before I posted this - couldn't find it. Any help on this would be
> appreciated.
Try the perldiag documentation.
> "
> Type of arg 1 to shift must be array (not split) at perl.shift.prob line
> 23, near "))"
Perl is telling you exactly why it doesn't compile. What does that say?
shift modifies its argument, so it needs a named array, not an anonymous
one.
> Is this actually a bug or am I missing something?
It's the latter.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 10 Jul 1998 00:44:10 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Bug? shift( split(' ',$_)); won't compile.
Message-Id: <alecler-1007980044100001@dialup-737.hip.cam.org>
In article <6o41mn$aud$1@farstar.frb.gov>, "abuse"@[127.0.0.1] wrote:
> (Note: I spent 20 minutes at CPAN and perl.com trying to finds a list of
> bugs before I posted this - couldn't find it. Any help on this would be
> appreciated. If responding via email, please use "bobn at interaccess
> dot com".)
>
> Program is:
> #!/usr/local/bin/perl -w
>
> use diagnostics;
>
>
> @junk = (
> "str00 str01 str02",
> "str10 str11 str12",
> "str20 str21 str22",
> );
>
>
> foreach (@junk) {
> @junk2 = split(' ',$_);
> $junk = shift @junk2;
> print "$junk\n";
> }
>
> exit;
>
> __END__
> foreach (@junk) {
> $junk = shift( split(' ',$_));
> print "junk\n";
> print "@junk2\n";
> }
>
>
> Running this as is produces:
> "
> str00
> str10
> str20
> "
>
>
> If I comment the __END__, running this produces:
> "
> Type of arg 1 to shift must be array (not split) at perl.shift.prob line
> 23, near "))"
> Execution of perl.shift.prob aborted due to compilation errors (#1)
>
> (F) The final summary message when a Perl compilation fails.
>
> Uncaught exception from user code:
> Execution of perl.shift.prob aborted due to compilation errors.
> "
>
>
> Is this actually a bug or am I missing something?
shift(split()) is not licit syntax, is all.
Use correct syntax and you won't get the error.
foreach (@junk) {
print shift(@{[split ' ']}),"\n";
}
But, if you think about it, there's no practical reason to use shift() on
an anonymous array, so:
foreach (@junk) {
print +(split ' ')[0],"\n";
}
A.L.
------------------------------
Date: Thu, 09 Jul 1998 23:10:11 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Creating files problems. (CGI-Unix)
Message-Id: <comdog-ya02408000R0907982310110001@news.panix.com>
Keywords: from just another new york perl hacker
In article <35a4ed99.0@news.arrakis.es>, "Guillermo Garcis" <ggarces@arrakis.es> posted:
>I have been trying to create files with this command: open(NEW,">$file") or
>open(NEW,"+>$PAGE"), but it doesn4t work. I don4t know if i have to give
>some permissions to can to create files.
let perl tell you what is wrong!
open NEW, "+>$PAGE" or die "Error opening $PAGE\n$!";
good luck :)
--
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 Travel Deals! <URL:http://www.pm.org/travel.html>
somewhere Tom P. just had either itching palms, chest pains
------------------------------
Date: Thu, 09 Jul 1998 23:02:27 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: dwiesel@my-dejanews.com
Subject: Re: delete key from array
Message-Id: <35A58443.9CF45A0B@erols.com>
1) You really want to delete $array[0]
2) You can't delete a "key" from an array because there are none. You
mean you want to delete an "element". A "key" implies some master/slave
pairing. If you want that, you use a hash.
dwiesel@my-dejanews.com wrote:
>
> Hi.
>
> I don't seem to find the (probably) simple answer...
>
> I have an array and want to delete a key from it
>
> @array = ("hallo", "hallo2");
>
> how do I delete $array[1] so that the arrays new look is ("hallo2") ???
>
> // Daniel
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 9 Jul 1998 22:58:12 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: Directory Names with Perl for NT
Message-Id: <6o43gk$q0p@fumnix.metronet.com>
Jeff Lockard <jLockard@rwd.com> writes:
[...]
) DOS copy, xcopy, and move commands.
)
) The problem that I keep running into is that the folders and files may
) have spaces in the names which tend to mess up the DOS commands
Although there is no guarantee that this will always work
because Microsoft has not bothered to provide a standard
method for parsing command-line arguments, the trend seems
to be to support something close to this:
system( "xcopy /hekq ", join(" ",quote_files($source,$dest)) );
sub quote_files {
my( @files )= @_;
my $file;
foreach $file ( @files ) {
# If file name contains things that require quoting
# and isn't already enclosed in quotes:
if( $file =~ /["\s<>&]/ && $file !~ /^".*"$/ ) {
# Turn <This is "my" file name>
# into <"This is ""my"" file name">:
$file =~ s/"/""/g;
$file= '"'.$file.'"';
}
}
return @files;
}
If this ever becomes really pervasive then it might be worth
having this:
sub system {
if( 1 < @_ && $^O eq "MSWin32" ) {
return CORE::system( quote_files( @_ ) );
}
return CORE::system( @_ );
}
Note that on a decent operating system:
system( "xcopy", $source, $dest );
causes the values of $source and $dest to be sent to the "xcopy"
program with no intervening interpretation (except that they can't
contain '\0' characters). Under DOS and Windows, the only method
for passing arguments is to build a "command line" which each
program must decide how to interpret, no two quite exactly the
same way.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Thu, 09 Jul 1998 23:08:20 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: environment-vars
Message-Id: <comdog-ya02408000R0907982308200001@news.panix.com>
Keywords: from just another new york perl hacker
In article <35A491EE.30F5F6CE@erlm.siemens.de>, Antje Rau <Antje.Rau@erlm.siemens.de> posted:
>how can i get the following result:
>
>shell#: echo $TEST
>TEST: Undefined variable
>shell#: <perl-script>.pl
>shell#: echo $TEST
>testvar
fortunately, a process cannot affect the shell in that fashion.
--
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 Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
Date: 10 Jul 1998 03:21:22 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: environment-vars
Message-Id: <eli$9807092317@qz.little-neck.ny.us>
Keywords: from just another new york perl hacker
In comp.lang.perl.misc, brian d foy <comdog@computerdog.com> wrote:
> Antje Rau <Antje.Rau@erlm.siemens.de> posted:
> >how can i get the following result:
> >
> >shell#: echo $TEST
> >TEST: Undefined variable
> >shell#: <perl-script>.pl
> >shell#: echo $TEST
> >testvar
>
> fortunately, a process cannot affect the shell in that fashion.
How hard have you played with attaching debuggers to the parent process?
Elijah
------
#!/usr/local/bin/perl5 -- # -*- my ny.pm sig -*-
$_=$^ ;s;s;sss;;s^.^ju^&&s&P+&\n&&&(s(_..)(ers)||s|^|^^|)&&s(T)(q(st%eg))eg;
s<.(o).><$& new 1$$>i+s+\dst.+$a--||reverse(q(rep k))+ge;s*%.+u* so+*i;s=\++
="me"=mex&&s%ege%l$"hke%;$a||s/^\S+ /\/\//;s;\d+;yor;;s[KE]<ac$&>i;print $_;
------------------------------
Date: 10 Jul 1998 03:26:16 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: environment-vars
Message-Id: <6o41ko$a33$1@comdyn.comdyn.com.au>
In article <35A491EE.30F5F6CE@erlm.siemens.de>,
Antje Rau <Antje.Rau@erlm.siemens.de> writes:
> hi,
>
> how can i get the following result:
This is a frequently asked question, and therefore is answered in the
FAQ:
# perldoc perlfaq8
I {changed directory, modified my environment} in a perl
script. How come the change disappeared when I exited the
script? How do I get my changes to be visible?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd. | network - Mitchell Kapor
NSW, Australia |
------------------------------
Date: Thu, 09 Jul 1998 22:33:38 -0500
From: postmaster <"postmaster"@[127.0.0.1]>
Subject: Re: Get IP Address for Server Name
Message-Id: <6o424m$aud$2@farstar.frb.gov>
Ooops, a literal "`nslookup" sneaks into the output. I meant to say:
#!/usr/local/bin/perl -w
use diagnostics;
$ip_addr = `nslookup $ARGV[0]`;
print "$ip_addr\n";
postmaster wrote:
> #!/usr/local/bin/perl -w
>
> use diagnostics;
>
> $ip_addr = `nslookup $ARGV[0]`;
> print "`nslookup $ip_addr\n";
>
> # works on Solaris 2.5.1, perl 5.00403; s/b OK on NT too.
>
> (if replying via email, use "bobn at interaccess dot com")
>
------------------------------
Date: Thu, 09 Jul 1998 21:36:42 -0600
From: John Layne <jpl@lanl.gov>
Subject: How can you encrypt a CGI script on a server so it will not get "stolen"?
Message-Id: <35A58C49.23BEE40F@lanl.gov>
Hi there,
I have spent many, many hours writing a CGI script that creates a
client's web site from a text file on the server. I am worried because
there is nothing to prevent this client from copying the plain-text
script, firing me as their web developer, and getting someone else to
use the script. I have made it clear that the scripts belong to me and
they pay to use them. But...
What would be the best way to protect my assets? I guess I could encrypt
the script on the server and have another password-protected script that
would decode it and then run it. Any ideas would be gratefully accepted.
I would imagine that this is an issue others have faced.
Thanks!
John Layne
jpl@t-f.com
------------------------------
Date: 9 Jul 1998 23:33:03 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: How to use 'system ("...")' on WIN32.
Message-Id: <6o45hv$84a@fumnix.metronet.com>
Michael Pham <mpham@cts.com> writes:
) I have a script that calls another script using 'system()' function.
) It works fine on Unix. I tried to port it to WIN32 and find that it
) does not work as expected. Any WIN32 gurus?
Why, are you thinking of hiring one?
If not, be polite and do a little home work before you post.
Simplify the script as much as possible without making the
specific problem go away (if you can't get it under two
dozen lines, then you may need to hire someone). Describe
the problem ("does not work as expected" is _not_ a problem
description).
Than you'll probably get a helpful response.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Fri, 10 Jul 1998 04:27:49 GMT
From: drperry@greennet.net (Doug Perry a.k.a drperry)
Subject: need to code a delete function
Message-Id: <35a595d9.9397133@news.greennet.net>
This is driving me nutz! I have a nice content mangement tool that I
out together to teach myself CGI/perl. So far I have a script to parse
and write a datafile and one to display the data in a Web page. The
funny thing is that I still haven't figured out a way to delete all
the entries at once. Dumb me, I tried the brute force way:
unlink("FILENAME"). It worked but it caused one big 500 http error.
What would be nice is some guidance towards a way to delete all the
entries in a datafile at once without the 500 errors.
------------------------------
Date: 09 Jul 1998 20:12:49 -0700
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: new charter and moderator for comp.lang.perl.announce
Message-Id: <waa7m1m4cwe.fsf@ese.UCSC.EDU>
groenvel@cse.psu.edu (John D Groenveld) writes:
> I like the current charter and Randal has done a fine job moderating
> the group. Let the commercial interests advertise in the Perl Journal
> or some other median.
>
> Commercial products and services like the ActiveState IDE and the Perl
> Conference have been adequately promoted elsewhere.
They most certainly have not. I never heard of the Perl Journal or
the Perl Conference until long after I would like to have, because
they were not listed in c.l.p.a. I would have wanted to go to the
conference last year, but didn't know about it until afterwards. (I
can't afford it this year.) I only heard of TPJ because a coworker
got a subscription and showed it to me.
I think it's safe to say that most of us who program Perl do (at least
some of) it with an eye towards making money. Even though Perl itself
is not a commercial product it is related to commercial activities in
our daily lives, and commercial posts relating to Perl are certainly
relevant. I think any commercial product, service, conference,
publication, or book deserves mention in c.l.p.a if it is of direct
benefit to Perl programmers, though I have no problem with tagging it
as commercial in the subject line.
Another possibility might be to have a periodical (pardon the pun)
digest of new Perl books, instead of a separate posting for each one,
or something like that which would reduce the number of postings about
books in c.l.p.a.
--Bill.
--
William R Ward Bay View Consulting http://www.bayview.com/~hermit/
hermit@bayview.com 1803 Mission St. #339 voicemail +1 408/479-4072
hermit@cats.ucsc.edu Santa Cruz CA 95060 USA pager +1 408/458-8862
PGP Key 0x2BD331E5; Public key at http://www.bayview.com/~hermit/pubkey.txt
-----------------------------------------------------------------------------
"Language is a virus from outer space." --William S. Burroughs
------------------------------
Date: 10 Jul 1998 03:06:44 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: new charter and moderator for comp.lang.perl.announce
Message-Id: <6o40g4$9u1$1@comdyn.comdyn.com.au>
In article <6o3b93$c7l$1@tholian.cse.psu.edu>,
groenvel@cse.psu.edu (John D Groenveld) writes:
> Let the commercial interests advertise in the Perl Journal
> or some other median.
Now, this is an idea I like.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm desperately trying to figure out
Commercial Dynamics Pty. Ltd. | why kamikaze pilots wore helmets -
NSW, Australia | Dave Edison
------------------------------
Date: Fri, 10 Jul 1998 03:08:31 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Pattern matching problems
Message-Id: <35A586CD.56477071@shaw.wave.ca>
brian d foy wrote:
>
> does this count? :)
>
Certainly.
> #!/usr/bin/perl
>
> %h = qw( a e i o u a e i o u );
>
> $_ = 'facetious';
>
> print "$_\n";
>
> s/([aeiou])/$old.=substr($`,length $old,length $`-length $old).$h{$1};
> print "$old$'\n";
> $h{$1}
> /ge;
>
Or just:
s/(.*?)([aeiou])/$old.="$1$h{$2}";
print "$old$'\n";
"$1$h{$2}"/ge;
(which I would never have come up with without your solution).
Thanks!
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Thu, 09 Jul 1998 23:13:03 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: pattern matching results into an array
Message-Id: <comdog-ya02408000R0907982313030001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6o3p2p$4ti$1@nnrp1.dejanews.com>, Juli@my-dejanews.com posted:
>What I am trying to do is read a file, line by line.
>If either pattern is matched anywhere on that line,
>I want to keep that line.
>I would like to put the line in an array, but I'm not sure if this
>is possible and/or the best solution.
you want something like
while( defined( $this_line = <FILE>) )
{
push @saved_lines, $this_line if $this_line =~ m/PATTERN/;
}
once you have the saved lines in the array, you can process them
however you like.
good luck :)
--
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 Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
Date: 10 Jul 1998 03:16:45 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: pattern matching results into an array
Message-Id: <eli$9807092309@qz.little-neck.ny.us>
In comp.lang.perl.misc, <Juli@my-dejanews.com> wrote:
> unless (open (BOOK, "book.pl")){
> die ("can't open the file $!");
> }
Good.
> $this = bob;
> $that = jane;
$this = 'bob';
$that = 'jane';
You want quotes there, if you want those at all.
> while ($line = <BOOK>) {
A line like "0\n" would confuse this, use:
while (defined($line = <BOOK>)) {
Newer versions of perl will warn about this with -w.
> if ( ($line =~ $that) ||
> ($line =~ $this) )
Won't work. You meant:
if ( ($line =~ /$that/o) ||
($line =~ /$this/o) )
Better would be:
if ($line =~ /jane|bob/)
> {
> ## $line = @theory; ##
push @theory, $line;
> }
> }
Grep around perlfunc for other ways to put things into arrays.
Elijah
------
was expecting an m//g problem
------------------------------
Date: Fri, 10 Jul 1998 00:04:16 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Perl OO for dummies [Was: Oh man, DO I love Perl ! (References to things that go out of scope)]
Message-Id: <35A592C0.373B2D64@erols.com>
<Manual>
1: Learn everything you can about modules and packages in their own
right. (That saves a lot of typing on ,my part :-) )
2: Especially understand that if you do not do an EXPORT or EXPORT_OK of
your functions in package MYPACK, you can access them anyway with an
explicit MYPACK::theFuncIWant().
3: An object is simply a variable that that has been "blessed" into a
package. What does that mean? Simply put, once you do
bless $myVar, MYPACK
you can substitute $myVar for MYPACK.
4: By convention (and that's all it seems to be to me), the variable
that is used 99.9999.... percent of the time is of type hash reference.
Why? Because you can then store variable values in the hash that act as
public data (not private) for the class instance. There are ways to make
it private.
5: Again, by convention to, most likely, appease the C++ gods, the
creation of a new object instance is peformed by putting a function
'new' in the package:
package MYPACK;
sub new {
my $self = {
'foo' => 'default',
'bar' => 'default'
};
bless $self, MYPACK;
return $self;
}
and the user does
my $obj = new MYPACK;
my $obj2 = MYPACK::new();
take your pick.
</Manual>
Well now, how's that for a start?
And once you understand this and have written a few object defs by hand,
then go get ModuleMaker and use it instead of rolling your own!
------------------------------
Date: Fri, 10 Jul 1998 00:50:57 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Question I can't find an answer for.
Message-Id: <comdog-ya02408000R1007980050570001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6o3ng0$3t9$1@nnrp1.dejanews.com>, jevon@my-dejanews.com posted:
>I have just begun to script in perl. I am trying to make a CGI application
>(This is a perl question) that will replace all instances of $name with $value
>{$name} in a template HTML file.
>
>I beleive this should be able to be done in two foreach loops
>
>I have read the template file into the @lines variable
>eg.
>
>foreach $lines (@lines) {
> foreach $name (@name) {
> ($line) = $lines =~ s/$name/$value{$name}/ig;
> }
>}
that's pretty close. let's try adding a few features though. :)
1) instead of storing the entire file in a variable when you
are going to process it line by line, just read it line by line:
open FILE, $file or die "$!"; #just an example, rootbeer :)
while( <FILE> )
{
... #do stuff here
}
you might also want to process the file in one shot. in that case,
you can store the file data in a scalar variable:
$/ = undef; #set the input record separator to undef
$file = <FILE>;
... #process stuff.
beware! this could be really bad for large files!
2a) now, for processing. you can make the substitutions. there are a
few tricks here, and i won't go into all of them - just enough to give
you the flavor of the problem. when you are using variables in a
pattern, watch out for regex meta-characters in the value - they
will be treated as meta-characters unless you explicity say so. my
favorite way around this is to use \Q to turn off the "specialness" of
characters (until the pattern gets to the end or until a \E):
s/\Q$name\E/$form{$name}/g;
you might also see special quoting mechanisms like quotemeta().
2b) another tricky thing is that you probably want to match on word
boundariesm, whitespace, or some other delimiter. imagine $name
holding the value "cat", so you expect to change each occurance
of "cat" in the file. what should happen if you run into the
word "concatenate"? you can to specify the boundaries
in the regex:
s/\b\Q$name\E\b/$form{$name}/g;
the rub is that the boundary conditions (\b, \s, and so on) may not be
to your liking. templating systems sometimes supply the boundary.
i like using %%, so my templates look like
the quick brown %%cat%% jumped over the lazy dog.
i can recognize and replace that with something like
s/%%\Q$name\E%%/$form{$name}/g;
this has the added benefit of solving another problem. imagine
replacing "cat" with "fox". further along in the process you
decide to change all occurances of "fox" to "weasel". do you
want to change occurances of things already changed? in the
example above, the delimiter has been removed in the first pass
so things only are changed only once. think about this as you design
your system.
2c) if you want to process the data line by line, you might
want to consider compiling the regex pattern only when it needs
to change. use the /o option for this. you might also take
advantage of the null pattern behaviour which uses the last
successfully executed regex for the pattern (see perlre, for
instance). this may or may not be something you want, but i
think its kinda cool :)
2d) if you are creating a templating system, you might take a
look at other such things on CPAN, such as Text::MetaText and
so on - either to take a peek at the code or to use to complete
your task.
3) once you've made the substitutions, you need to do something
with the result. you can save the lines in an array:
push @lines, $new_line;
or append the data to a string:
$data .= $new_line;
these might be useful for small bits of data or if you need to
do further processing.
for lots of data, you might want to immediately send the output
somewhere rather than store it in memory. just print or write to
whereever it needs to go. this might be good for data that
you don't need to process further and is ready to present.
well, i didn't mean to say that much. if i'd made more mistakes
doing the same thing, this post might have been longer :)
--
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 Travel Deals! <URL:http://www.pm.org/travel.html>
------------------------------
Date: 09 Jul 1998 21:16:11 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Recognizing BACK and FORWARD button-visits
Message-Id: <m3oguynxx0.fsf@windlord.Stanford.EDU>
staaldui <staaldui@my-dejanews.com> writes:
> I'm trying to find a way to see the 'site-walking' behaviour of a
> visitor. By this I mean I am looking for a way so I can see a visitor is
> pressing the BACK and FORWARD-buttons to go through previously cached
> pages. (e.g. a visitor comes in on page A, clicks on a link to page B,
> clicks on a link to page C and clicks BACK to go back to page B
> again. When the visitor comes back on page B this is recognized as a
> repeated visit to page B.)
> Theoratically this can be achieved by disabeling caching (through
> HTTP-headers) and use cookies to tell the different visitors apart and
> to tell which visitor is a first-time visitor and which is not, however,
> I don't want to rely on cookies for that, since cookies can be blocked
> by the client.
Um...
(a) That's an *incredibly* obnoxious thing to do. I can't think of very
many cases where someone has a legitimate reason to do that, and if I
ever visited a site and found that they were doing that, I'd never
visit that site again.
(b) This isn't even remotely a Perl question, so I'm not sure why you're
posting it to this group. At best it's a CGI question, but if you're
talking about invalidating the cache, it's really a HTTP protocol
question.
(c) Without relying on some saved state, whether it be a form submission
or cookies (and form submission won't catch forward and back buttons)
you can't tell clients apart. This is sort of a first principles
kind of thing. You can at best look for connections from unique IP
addresses. If that's good enough, then disable caching by claiming
that all your pages immediately expire, and that *might* work for
*some* browsers.
I'd recommend asking any followup questions on a different group, read by
people who know more about the issues involved.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Thu, 9 Jul 1998 23:55:08 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Silly things to do in Perl (or: is that Laptop waterproof?)
Message-Id: <1dbxbhp.3l96t4zd9i4gN@bay2-51.quincy.ziplink.net>
Dave Bushong <spamfree@yahoo.com> wrote:
> Here is a brute force conversion program...
Thanks! Got a few more characters I didn't know the Morse encoding for.
> s/\./\.-\.-\.- /g;
Ick! There's no need to backslash periods in the replacement string,
and it just makes the program harder to read.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 09 Jul 1998 20:41:02 -0700
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Single vs Double Quotes [was: Re: Abigail - Another Question for you.]
Message-Id: <waa67h64bld.fsf_-_@ese.UCSC.EDU>
tadmc@flash.net (Tad McClellan) writes:
> [ I believe that it is misleading to use double quotes when there
> is no interpolation. Single quotes are more appropriate in
> that case.
Isn't it also faster to use single quotes, as the interpreter can then
know it doesn't have to scan for metacharacters such as $ or \ to
interpolate?
--Bill.
--
William R Ward Bay View Consulting http://www.bayview.com/~hermit/
hermit@bayview.com 1803 Mission St. #339 voicemail +1 408/479-4072
hermit@cats.ucsc.edu Santa Cruz CA 95060 USA pager +1 408/458-8862
PGP Key 0x2BD331E5; Public key at http://www.bayview.com/~hermit/pubkey.txt
-----------------------------------------------------------------------------
"Language is a virus from outer space." --William S. Burroughs
------------------------------
Date: 10 Jul 1998 04:19:12 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Single vs Double Quotes [was: Re: Abigail - Another Question for you.]
Message-Id: <900044889.268725@thrush.omix.com>
William R. Ward <hermit@cats.ucsc.edu> wrote:
: Isn't it also faster to use single quotes, as the interpreter can then
: know it doesn't have to scan for metacharacters such as $ or \ to
: interpolate?
It still has examine each char (think about ending "'", '\'', etc):
$ perl foo.pl 100000
Benchmark: timing 100000 iterations of LongDouble, LongSingle, ShortDouble,
ShortSingle...
LongDouble: 61 wallclock secs (55.43 usr + 0.07 sys = 55.50 CPU)
LongSingle: 53 wallclock secs (51.17 usr + 0.09 sys = 51.27 CPU)
ShortDouble: 41 wallclock secs (37.42 usr + 0.95 sys = 38.38 CPU)
ShortSingle: 46 wallclock secs (42.98 usr + 0.04 sys = 43.02 CPU)
Results go from single to double and back, depending on the
exact phase of the moon.
use Benchmark;
timethese shift || 100, {
ShortSingle => sub {
eval q(
my $string = 'AAAAAAA';
);
},
ShortDouble => sub {
eval q(
my $string = "AAAAAAA';
);
},
LongSingle => sub {
eval q(
my $string =
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
);
},
LongDouble => sub {
eval q(
my $string =
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
);
},
};
--
-Zenin
zenin@archive.rhps.org
------------------------------
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 3113
**************************************