[9295] in Perl-Users-Digest
Perl-Users Digest, Issue: 2890 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 17 10:17:23 1998
Date: Wed, 17 Jun 98 07:01:19 -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 Wed, 17 Jun 1998 Volume: 8 Number: 2890
Today's topics:
Re: Calling perl from NT <guillaume@deepend.co.uk>
Re: Calling perl from NT <quednauf@nortel.co.uk>
Re: Calling perl from NT scott@softbase.com
Re: fixed width files into an array ? <baliga@synopsys.com>
Re: getting first letter of a string (Mike Stok)
Re: getting first letter of a string (Michael J Gebis)
Getting TEXTWIDTH from Perl (Tim)
Re: Getting TEXTWIDTH from Perl <quednauf@nortel.co.uk>
Re: Having STDERR go to STDOUT in a system call <r.goeggel@atos-group.de>
Re: Having STDERR go to STDOUT in a system call <tchrist@mox.perl.com>
Re: Help with using Time in PERL <baliga@synopsys.com>
Re: HELP: Perl Scripts for a unix host using Apache <0x74_0x6F_0x64_0x64@0x40.0x7A.0x65.0x72.0x6F.0x6B.0x61.0x72.0x6D.0x61.0x2E.0x64.0x79.0x6E.0x2E.0x6D.0x6C.0x2E.0x6F.0x72.0x67>
Re: HELP: Perl Scripts for a unix host using Apache (Mike Whitaker)
Re: How to delete a character from a string? (Kevin Reid)
Re: leading zeros <baliga@synopsys.com>
Re: obfuscated perl (Tom Grydeland)
Re: perl 5 on NT4 problems <perlguy@inlink.com>
Re: Pod::Text -- Unix only? <tchrist@mox.perl.com>
Problems with newlines in perl regexp <dalsboji@sjo.statkart.no>
Re: REVIEW: Perl CGI Programming - No Experience Requir (Chris Nandor)
Re: REVIEW: Perl CGI Programming - No Experience Requir (Chris Nandor)
Re: REVIEW: Perl CGI Programming - No Experience Requir <tchrist@mox.perl.com>
Re: REVIEW: Perl CGI Programming - No Experience Requir <tchrist@mox.perl.com>
Re: REVIEW: Perl CGI Programming - No Experience Requir <tchrist@mox.perl.com>
Re: simple expression matching problem <baliga@synopsys.com>
Re: Undefined subroutine CGI::pram <hannum@oak.cat.ohiou.edu>
Re: Win NT- CGI script help please <perlguy@inlink.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 17 Jun 1998 11:18:36 +0100
From: Guillaume Buat-Menard <guillaume@deepend.co.uk>
To: Caleb Newville <webmaster@briefcasegolf.com>
Subject: Re: Calling perl from NT
Message-Id: <358797FC.D34F35CD@deepend.co.uk>
Caleb Newville wrote:
> Does anyone know how to call a perl or CGI from a HTML file on an NT
> server. The following command works on Unix, but not on NT. Have a
> solution?
>
> <#!-- exec cgi="/cgi-bin/perl_script.pl">
It's the same as an html link (works on UNIX too):
<A HREF="/cgi-bin/script.pl">link to the script</A>
Cheers,
Guillaume.
------------------------------
Date: Wed, 17 Jun 1998 11:38:34 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Calling perl from NT
Message-Id: <35879CAA.5857E9B2@nortel.co.uk>
Guillaume Buat-Menard wrote:
>
> Caleb Newville wrote:
>
> > Does anyone know how to call a perl or CGI from a HTML file on an NT
> > server. The following command works on Unix, but not on NT. Have a
> > solution?
> >
> > <#!-- exec cgi="/cgi-bin/perl_script.pl">
>
> It's the same as an html link (works on UNIX too):
> <A HREF="/cgi-bin/script.pl">link to the script</A>
Not quite true. The exec line can be used eg to execute a script that returns
some text, eg a counter number , which is then directly inserted into the
position of the exec line. So either way, this is more of a webserver issue than
Perl issue.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 17 Jun 1998 12:26:33 GMT
From: scott@softbase.com
Subject: Re: Calling perl from NT
Message-Id: <6m8clp$34p$5@mainsrv.main.nc.us>
> Does anyone know how to call a perl or CGI from a HTML file on an NT
> server. The following command works on Unix, but not on NT. Have a
> solution?
> <#!-- exec cgi="/cgi-bin/perl_script.pl">
If you mean when you say "NT server" that you're running Internet
Information Server, it does not support server-side includes (SSI).
To use them, you'll have to find another web server like Apache
that does.
Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more.
------------------------------
Date: Tue, 16 Jun 1998 12:26:13 -0700
From: "Yogish Baliga B." <baliga@synopsys.com>
Subject: Re: fixed width files into an array ?
Message-Id: <3586C6D5.7DAD@synopsys.com>
Hi,
Suppose the opened file handle is FILEFP,
U can use,
@array = <FILEFP>;
Good Luck,
Baliga
Chris Beatson wrote:
>
> Could someone please advise me as to the best way to read a fixed width
> text file line into an array ?
>
> TIA
> Chris
------------------------------
Date: 17 Jun 1998 12:12:33 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: getting first letter of a string
Message-Id: <6m8brh$q1@news-central.tiac.net>
In article <tZih1.3127$pr4.1564214@proxye1.san.rr.com>,
Ritche Macalaguim <ritche@san.rr.com> wrote:
>How can I get the first letter of a string in Perl?
What do you mean by letter?
Do you care about accented characters or locale setting? If you do then
($letter) = $string =~ /([^\W\d_])/;
might be a way to do it.
Hope this helps,
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: 17 Jun 1998 06:16:02 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: getting first letter of a string
Message-Id: <6m7mv2$moq@mozo.cc.purdue.edu>
rjk@coos.dartmouth.edu (Ronald J Kimball) writes:
}Ritche Macalaguim <ritche@san.rr.com> wrote:
}> How can I get the first letter of a string in Perl?
}($first) = $string =~ /([a-z])/i;
};-)
You fascist american umlaut-ignoring, accent-hating, not-to-mention
that-funny-german-B-and-that-french-c-with-a-tail-bigoted pig!
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Wed, 17 Jun 1998 10:49:35 GMT
From: tim@paco.net (Tim)
Subject: Getting TEXTWIDTH from Perl
Message-Id: <35879d44.9448369@news.paco.net>
Hi!
Sorry for my english.
You now that default 'Times' font used by browsers has different width
of characters and string of ten 'I' much shorter than string of ten
'W'. The question is how to determine width of string to correctly fit
it in table cell without wrap? Or I need to create array with
approximate width of each char and then calculate width? Too slow, I
think...
Any ideas, please.
------------------------------
Date: Wed, 17 Jun 1998 13:50:37 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Getting TEXTWIDTH from Perl
Message-Id: <3587BB9D.5507A37A@nortel.co.uk>
Tim wrote:
>
> Hi!
>
> Sorry for my english.
>
> You now that default 'Times' font used by browsers has different width
> of characters and string of ten 'I' much shorter than string of ten
> 'W'. The question is how to determine width of string to correctly fit
> it in table cell without wrap? Or I need to create array with
> approximate width of each char and then calculate width? Too slow, I
> think...
>
> Any ideas, please.
What about using a fixed width font? check out the html specs.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Wed, 17 Jun 1998 13:21:43 +0200
From: "Ronald G\"oggel" <r.goeggel@atos-group.de>
Subject: Re: Having STDERR go to STDOUT in a system call
Message-Id: <6m890o$2mg$1@news.pop-stuttgart.de>
Brett Denner schrieb in Nachricht <3586A04A.A8C09387@lmco.com>...
>I have an executable program that is called through a Perl script.
The
>executable program periodically writes information to both STDOUT and
STDERR.
>I can redirect the output sent to STDOUT by running the program with:
>
> $ret = system "my_program > file.txt";
>
>but this does not catch the writes to STDERR.
>
>I have tried this approach:
>
> open (STDOUT, "> file.txt") or die;
> open (STDERR, "> file.txt") or die;
> $ret = system "my_program";
>
>but I don't know how to "undo" the two open statements so that future
writes
>or prints go to the original STDOUT and STDERR instead of file.txt.
If I
>close STDOUT and STDERR, any writes or prints later in the script do
not work.
>
>Can anyone suggestion a way to accomplish this?
>
>Thanks,
>
>Brett
>
Some weeks ago there was a posting from Tom:
To capture a command's stderr and stdout together:
$output = `cmd 2>&1`; # either with backticks
$pid = open(PH, "cmd 2>&1 |"); # or with an open pipe
while (<PH>) { } # plus a read
To capture a command's stdout but discard its stderr:
$output = `cmd 2>/dev/null`; # either with backticks
$pid = open(PH, "cmd 2>/dev/null |"); # or with an open pipe
while (<PH>) { } # plus a read
To capture a command's stderr and discard its stdout:
$output = `cmd 2>&1 1>/dev/null`; # either with backticks
$pid = open(PH, "cmd 2>&1 1>/dev/null |"); # or with an open pipe
while (<PH>) { } # plus a read
To exchange a command's stdout and stderr in order to capture the
stderr
but leave its stdout to come out our old stderr:
$output = `cmd 3>&1 1>&2 2>&3 3>&-`; # either with backticks
$pid = open(PH, "cmd 3>&1 1>&2 2>&3 3>&-|");# or with an open pipe
while (<PH>) { } # plus a read
To read both a command's stdout and its stderr separately, it's
easiest
and safest to redirect them separately to files, and then read from
those files when the program is done:
system("program args 1>/tmp/program.stdout
2>/tmp/program.stderr");
--tom
--
HTH
Ronald
------------------------------
Date: 17 Jun 1998 13:09:13 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Having STDERR go to STDOUT in a system call
Message-Id: <6m8f5p$8df$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Brett Denner <Brett.W.Denner@lmco.com> writes:
:I have an executable program that is called through a Perl script. The
:executable program periodically writes information to both STDOUT and STDERR.
Have you read the FAQ about this? It's in perlfaq8.
You should also read the open entry in perlfunc.
--tom
--
"Lazy people never bother to actually read the manual. Instead they
(like kids) pick something with big, colorful buttons."
--Eugene Tyurin <gene@insti.physics.sunysb.edu>
------------------------------
Date: Tue, 16 Jun 1998 12:17:38 -0700
From: "Yogish Baliga B." <baliga@synopsys.com>
Subject: Re: Help with using Time in PERL
Message-Id: <3586C4D2.360B@synopsys.com>
The problem lies in gm->wday().
U have to call it as $gm->wday()
Hope this works.
Bye,
Baliga
------------------------------
Date: 17 Jun 98 10:45:04 GMT
From: Todd Santos <0x74_0x6F_0x64_0x64@0x40.0x7A.0x65.0x72.0x6F.0x6B.0x61.0x72.0x6D.0x61.0x2E.0x64.0x79.0x6E.0x2E.0x6D.0x6C.0x2E.0x6F.0x72.0x67>
Subject: Re: HELP: Perl Scripts for a unix host using Apache
Message-Id: <35879e30.0@206.170.198.12>
[Not mailed to author, due to misconfig in tin that I'm not quite willing to
fix at the moment]
Christian Friedl got drunk in comp.lang.perl.misc and spewed as such:
: Hi,
: My problem is that I'm working on a Win95 machine at home and have to
: write scripts for a unix host that doesn't show me any error messages
: except "Internal Server Error".
Write a CGI script to run the programs on the server, so you can grab
their stdout/err. be careful with it, though -- if you can execute it,
anyone can execute it. chmod 0 when not in use.
: The provider tells me they're using Apache. I am past the state of
: forgetting to chmod 755, so this is not the problem. A simple script
: like the following
c[_]
: doesn't work. Is it possible there are bugs in CGI.pm?
Sure, but this isn't one of 'em. It is the responsibility of the script
to generate the HTTP headers.
And lo, W3 did speaketh, and they speweth as such:
'Thine scripts shalt spew out at least one arbitrary HTTP header
before they speweth whatever output thine script desires,
followed by a blank line, followed by thine script's normal output.'
Translation:
Insert a line like this...
print "Content-type: text/html\n\n";
...before your script says something on stdout/err.
: +++ please remove ".nospam" when replying via email +++
Please run:
perl -e'while(<STDIN>){@n=split(/0x/, $_);foreach $foo (@n){' \
-e'$foo =~ s/\D//g;' -e'printf("%c","0x$foo");}' -e'exit( 0 );'
...when replying via email. Alternatively, see the Reply-To header.
c[_]
- Todd
--
Eye of newt, toe of toad, PC Bugs and Unix code.
- LJ Cartoon / Ted Goff
------------------------------
Date: 17 Jun 1998 11:03:25 GMT
From: mrw@malay.entropic.co.uk (Mike Whitaker)
Subject: Re: HELP: Perl Scripts for a unix host using Apache
Message-Id: <slrn6of8da.gn6.mrw@malay.entropic.co.uk>
>: My problem is that I'm working on a Win95 machine at home and have to
>: write scripts for a unix host that doesn't show me any error messages
>: except "Internal Server Error".
>
>
>Write a CGI script to run the programs on the server, so you can grab
>their stdout/err. be careful with it, though -- if you can execute it,
>anyone can execute it. chmod 0 when not in use.
use CGI::Carp qw/fatalsToBrowser/;
--
Mike Whitaker: Sysadmin, Entropic Cambridge Research Labs
------------------------------
Date: Wed, 17 Jun 1998 08:57:26 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: How to delete a character from a string?
Message-Id: <1dard13.12n1lw3k5qdacN@slip-32-100-246-15.ny.us.ibm.net>
Kevin Reid <kpreid@ibm.net> wrote:
> Alex T <at@pixelfilm.com> wrote:
>
> > Hi!
> >
> > I have a variable, for example "$xy". If the first character is "0", the
> > character should be
> > deleted.
> > How can I compare and delete a character from a string???
>
> #!perl -w
>
> use Benchmark;
>
> timethese(500000, {
> 'substr1' => sub {
> $xy = '0101';
> $xy = substr($xy, 1) if substr($xy, 1) eq '0';
Oops. That should be:
$xy = substr($xy, 0, 1) if substr($xy, 0, 1) eq '0';
Running the program again gives:
Benchmark: timing 500000 iterations of regexp0, regexp1, substr0,
substr1...
regexp0: 7 secs ( 7.15 usr 0.00 sys = 7.15 cpu)
regexp1: 7 secs ( 7.55 usr 0.00 sys = 7.55 cpu)
substr0: 7 secs ( 7.98 usr 0.00 sys = 7.98 cpu)
substr1: 10 secs (10.27 usr 0.00 sys = 10.27 cpu)
Benchmark: timing 500000 iterations of regexp0, regexp1, substr0,
substr1...
regexp0: 6 secs ( 6.10 usr 0.00 sys = 6.10 cpu)
regexp1: 8 secs ( 7.58 usr 0.00 sys = 7.58 cpu)
substr0: 8 secs ( 8.22 usr 0.00 sys = 8.22 cpu)
substr1: 11 secs (11.25 usr 0.00 sys = 11.25 cpu)
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: Tue, 16 Jun 1998 12:28:07 -0700
From: "Yogish Baliga B." <baliga@synopsys.com>
Subject: Re: leading zeros
Message-Id: <3586C747.2D88@synopsys.com>
Go through the man page of printf on any unix system
Good Luck,
Baliga
> Being a newbie, I need a good tutorial or reference on printf (and Perl).
> Any suggestions?
>
> Thanks
> al
------------------------------
Date: 17 Jun 1998 11:34:20 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: obfuscated perl
Message-Id: <slrn6ofads.mtt.Tom.Grydeland@mitra.phys.uit.no>
On Tue, 16 Jun 1998 16:44:04 -0400,
the count <eglamkowski@angelfire.com> wrote:
> saw this as a .sig and am having trouble deciphering it:
It exists in a documented form as well.
> Become an arms trafficker! -export-a-crypto-system-sig -RSA-3-lines-PERL
> #!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
> $/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
> lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
> specifically, I don't know what those ] characters are doing, and what
> the deal is with that ^*
Most of that alledged Perl is in fact commands to dc, the calculator
program. Notice the |dc on the final line.
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
- Do radioactive cats have 18 half-lives? -
------------------------------
Date: Wed, 17 Jun 1998 11:03:39 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: perl 5 on NT4 problems
Message-Id: <3587A28B.702026E8@inlink.com>
Try:
http://reference.perl.com/query.cgi?windows
HTH,
Brent
------------------------------
Date: 17 Jun 1998 13:11:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Pod::Text -- Unix only?
Message-Id: <6m8f9g$8df$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, pehanna@my-dejanews.com writes:
:Is there any particular reason why Pod::Text uses "stty -a 2>/dev/null" as a
:one of its means of determining the screen width? Is there a portable
:alternative?
Maybe it's just that time of the mornin, but I take umbrage here.
Portable doesn't mean "runs on a Mac". I code for corss-platform
use. That means my code works on Linux, BSD, SunOS, *and* Solaris
-- and probably any other profession/open/POSIX/Unix-like system.
If you want more than that, you'll have to write the program yourself.
--tom
--
"Computer Science is no more about computers than astronomy
is about telescopes." --E.W. Dijkstra
------------------------------
Date: Wed, 17 Jun 1998 13:57:16 +0200
From: "Jan Inge Dalsbx" <dalsboji@sjo.statkart.no>
Subject: Problems with newlines in perl regexp
Message-Id: <3587AF1B.1EBD5918@sjo.statkart.no>
I have written a perl program to prepare C++ headerfiles for DOC++. The
perl program should
substitute som specific comments with DOC++-comments. Before each
subsitution a want to
present the match, including x number of lines above and x number of
lines under the match.
The problem comes when i want to present 1 line above the match and that
line is empty (newline only).
The following example show the problem. The example search for "123\n"
in the string
"abc\n\n123\n\ndef\n", and the both the line above/under "123\n" is
"\n".
It's woking fine if i search for 2 or more lines, or if the line line
above/under "123\n" is NOT "\n" only.
Here is the program........
#!/usr/local/bin/perl
use English;
# make a string to simulate a simple ASCII-file with newlines
$_ =
"abc
123
def
";
print "This is my \"file\":\n";
print; # print $_;
print "-EOF-\n\n";
/123\n/; # search for "123\n" in $_
$pre = $PREMATCH; # keep matching variables BEFORE next regexp
$m = $MATCH;
$post = $POSTMATCH;
print "This is the \"matching\" variables:\n";
print "PRE:($pre)\nMATCH:($m)\nPOST:($post)\n";
print "\nSo far, so good.\nI now want to present the fist line
above,\nand the firt line under the match.\n";
print "In this case, it should be a empty line (newline only) both above
and under!\n";
# this variable is normaly from getopts, so the user can decide how many
lines to present
$lines = 1;
# seach for zero to 1 line at the end of $pre
$pre =~ /(.*?\n){0,$lines}$/;
print "Above:($MATCH)\n";
print "Shit, where is the empty line after abc?!\n\n";
# seach for zero to 1 line at the beginning of $post
$post =~ /^(.*?\n){0,$lines}/;
print "Under:($MATCH)\n";
print "Looking good.\n";
------------------------------
Date: Wed, 17 Jun 1998 12:06:06 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <pudge-1706980803220001@dynamic464.ply.adelphia.net>
In article
<Pine.SOL.3.96.980616152042.11046A-100000@corona.pmel.noaa.gov>, Nathan
Franzen <franzen@pmel.noaa.gov> wrote:
# On Tue, 16 Jun 1998, Chris Nandor wrote:
#
# > # Beginners should get documentation that says that the array, the AV, is a
# > # real thing, and the the list is but a fiction.
# >
# > But it is not. That would be an untruth.
#
# I hope I did not give offense in my previous post. Unintended. What I
# aimed for was a constructive suggestion of how future documentation might
# reduce beginner confusion (and FAQ's to this newsgroup). To that end I
# suggested that the "list" be regarded as a fictional construct, helpful
# only in limited ways. In contrast, "list context" is an obviously vital
# concept. As is the idea of an AV.
No offense; I just cannot condone telling an untruth, whether it is a
beginner or not. And I also disagree with the gist: I think a list is
fundamental enough that it should be taught right at the beginning, to get
rid of these problems people are having.
# Since an array is indeed a Perl variable, it is relatively easy to pin it
# down and look at its behavior. I have been attempting to do the same with
# lists, to see some specific list characteristics which cannot be
# attributed simply to characteristics of the operators and to the
# invocation of "list context". It isn't easy.
I really don't see how it is tough. A list is just a bunch of loose
values in a ... list.
1, 2, 3 # list
1..3 # list
@a # not a list
1 # not a list
$b # not a list
qw(1 2) # list
# I wonder if it is appropriate to think of a list as a sequence of values
# without a home ... a list is to an array as a value is to a scalar.
Pretty much. A list is just a bunch of values floating around somewhere.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 17 Jun 1998 12:08:14 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <pudge-1706980805290001@dynamic464.ply.adelphia.net>
In article <6m82np$4up$1@samba.rahul.net>, c.c.eiftj@54.usenet.us.com
(Rahul Dhesi) wrote:
# In <pudge-1606980854110001@dynamic404.ply.adelphia.net> pudge@pobox.com
# (Chris Nandor) writes:
#
# >You have been given a completely unambiguous definition. You just don't
# >understand it. An array has an AV allocated, and a list is just some
# >values on a stack somewhere. Think of it like this: an array is accessed
# >through symbols like $ and @, and a list is not. A list cannot be changed
# >or altered in any way, an array can be. These are all unambiguous.
#
# 1. A definition in terms of the symbol AV is useless unless you first
# define that symbol. What's your definition of AV?
# 2. How do I know what is stored in an AV and what is not? Do I have
# to compile perl in debugging mode and make it dump the gnerated code
# in order to define arrays versus lists? If not, how else do we
# decide what is stored in an AV and what is not?
# 3. If the list/array distinction depends on the internal workings of
# the perl interpreter, then the distinction could become invalid if
# the perl interpreter is revised to behave differently without changing
# the language. You can't usefully define a programming langauge by
# depending on the internal data structures of the language compiler.
#
# So far the only simple definition distinguishing between arrays and
# lists, that does not depend on arbitrary code examples, and does not
# depending on knowing the internals of the perl interpreter, is my own:
#
# If we use subscript notation on something at least once, it's
# an array, otherwise it's not.
Rahul, you ignorant slut.
I gave you THREE definitions. Your problems above focus only on the
internals part of it; why did you willingly discard the other things I
said following the mention of AVs? Here it is, your definition, which was
already 100 percent inferrable from the above information:
an array is a variable. a list is not.
That simple. Go home now.
I didn't think this was necessary to say. It is obvious to anyone who
knows anything about Perl. Serves me right for overestimating people's
intelligence.
# > $; = '|';
# > $a{'a', 'b'} = 'z'; # $a{'a|b'} == 'z'
# > @a = ('a', 'b');
# > $a{@a} = 'y'; # $a{2} == 'y'
#
# Again, by looking at the code alone, it's impossible to say what is an
# array and what is a list.
Only if that nobody is a blockhead.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 17 Jun 1998 12:52:57 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6m8e79$6ga$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
c.c.eiftj@54.usenet.us.com (Rahul Dhesi) writes:
:lists, that does not depend on arbitrary code examples, and does not
:depending on knowing the internals of the perl interpreter, is my own:
:
: If we use subscript notation on something at least once, it's
: an array, otherwise it's not.
Damn it, that's *wrong*. It's an array if there had been an @{} involved,
or a [ ... ] anon-array composer. The rest are just lists. Arrays have
mutable lengths, but lists do not. That's because an AV has both a
length field and a list in it. A list nodesn't have that length field
separate from itself.
struct xpvav {
char* xav_array; /* pointer to first array element */
SSize_t xav_fill; /* Index of last element present */
SSize_t xav_max; /* Number of elements for which array has space */
IV xof_off; /* ptr is incremented by offset */
double xnv_nv; /* numeric value, if any */
MAGIC* xmg_magic; /* magic for scalar array */
HV* xmg_stash; /* class package */
SV** xav_alloc; /* pointer to malloced string */
SV* xav_arylen;
U8 xav_flags;
};
#define AvARRAY(av) ((SV**)((XPVAV*) SvANY(av))->xav_array)
Contrast then the xpvav structure with the "list" contained in AvARRAY.
Look how much more there is! An AV can know its size, its class, etc.
It can also be magical. Lists are none of these things.
--tom
--
"The reason you subscribe to a mailing list is you don't get all
the crap you get on netnews. "
--Dennis Ritchie
------------------------------
Date: 17 Jun 1998 12:54:14 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6m8e9m$6ga$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
c.c.eiftj@54.usenet.us.com (Rahul Dhesi) writes:
:Unfortunately you haven't told us how to decide, by examning perl code,
:whether or not there is an AV.
I just did. See my other posting.
:In the absence of any other useful definition, what choice do I have but
:to create my own? I find it logical and intuitive:
:
: If we use subscript notation on it at least once, it's an array;
: otherwise it's not.
Logical and intuitive though this may be, it's hopelessly incorrect.
--tom
--
QVIDQVID LATINE DICTVM SIT PROFVNDVM VIDITVR
------------------------------
Date: 17 Jun 1998 12:54:54 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: REVIEW: Perl CGI Programming - No Experience Required
Message-Id: <6m8eau$6ga$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
rpearce@my-dejanews.com writes:
:I hope this isn't a stupid question, but what is meant by "decode the form by
:hand"? I've been using what I thought was a fairly common snippet I've seen
:over and over: Read the Post output, tr/+/ /, change the %## back to ascii
:and assign the name/value pairs to a hash. Is this 'by hand'? I like it
:because I can make other minor changes as needed without relooping the hash.
Yes, that's doing it by hand. It's full of bugs. I won't list them.
--tom
--
": fighting for peace is like fucking for virginity (ado@bigcomm.gun.de)
Yes, but I did manage to increase the amount of virginity in the world
by that method." --Larry Wall
------------------------------
Date: Tue, 16 Jun 1998 12:24:11 -0700
From: "Yogish Baliga B." <baliga@synopsys.com>
Subject: Re: simple expression matching problem
Message-Id: <3586C65B.2356@synopsys.com>
Hello,
Here is the solution for this,
YOu can use \Q before the string
For example, if the string1 and string2 are stored in
$string1 and $string2 respectively,
You can use the statement like,
=~ s/\Q$string1\E/$string2/g;
Hope this solves your problem.
Good luck,
Baliga
gulam.faruque@csfp.co.uk wrote:
>
> Hi..
>
> I'm trying to write a replace script in perl.
> for example. scriptname filename string1 string2
>
> This will search for string1 in filename and replace it with
> string2 and print the results to the console.
> The problem is string1 and string2 can contain any characters such as \.*[]{}
> I dont want the person running the script to enter a \ before each special
> character.
>
> How is this done?
> Will I have to scan the strings first to insert a \ in front of any special
> characters before I do the replacement ?
>
> I am using win32-perl v5.004 on NT4
>
> Thanks
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 17 Jun 1998 13:12:13 GMT
From: "Dave" <hannum@oak.cat.ohiou.edu>
Subject: Re: Undefined subroutine CGI::pram
Message-Id: <Eup352.Mnp@boss.cs.ohiou.edu>
Thanks for the spanking! (I know you're right though)
>Hmm. What do you suppose that error message means?
>Could it mean that no subroutine named "pram" was defined in
>the CGI module?
>If that is the case, what would lead you to want to try to
>call a sub named "pram" in the CGI module? That is, why
>do you think (mistakenly) that there should be a sub named "pram"
>in the CGI module? Now, if your thinking was in error, what
>would be the most likely way to correct it? Perhaps, finding
>the name of subroutine in CGI which is the one you really wanted.
>Say, perhaps, "param". How would you find that, if it existed?
>Would you look in the file CGI.pm, maybe? Or type "perldoc CGI"
>at your command prompt?
>
>John Porter
------------------------------
Date: Wed, 17 Jun 1998 10:57:42 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Win NT- CGI script help please
Message-Id: <3587A126.5E347F98@inlink.com>
I have been running Perl on IIS for over 9 months now and have not come
across anything like this.
What version/maker of browser are you using? I would suspect that it is
the browser and not the server that is caching that output. I know that
Internet Exploder 3.x caches more than it should and can cause
problems...
HTH,
Brent
------------------------------
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 2890
**************************************