[16293] in Perl-Users-Digest
Perl-Users Digest, Issue: 3705 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 09:07:56 2000
Date: Tue, 18 Jul 2000 06:07:31 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963925651-v9-i3705@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 18 Jul 2000 Volume: 9 Number: 3705
Today's topics:
"Perl Bowling" revisited with an array question (Jim Kauzlarich)
Re: "Perl Bowling" revisited with an array question (Abigail)
Re: "Perl Bowling" revisited with an array question (Abigail)
Re: "Text file busy" error message (Martin Jost)
$sth->{PrintError} and Huge Queries? ()
Re: $sth->{PrintError} and Huge Queries? (Mark W. Schumann)
$sth->{PrintError} and Large Queries? ()
Re: 'my' and references (Tad McClellan)
Re: -w and Use of uninitialized value at (Ala Qumsieh)
Re: -w and Use of uninitialized value at (mike solomon)
.dentifying user using htaccess i (Dave Johnson)
Re: .dentifying user using htaccess i (Bart Lateur)
???How to make Daemon in Perl without Cron? ()
Re: @ not piped in print << -> must escape as \@ (Tad McClellan)
Re: @ not piped in print << -> must escape as \@ (Tad McClellan)
Re: @ not piped in print << -> must escape as \@ (Keith Calvert Ivey)
Re: @ not piped in print << -> must escape as \@ (Keith Calvert Ivey)
Re: @ not piped in print << -> must escape as \@ (Shannon Jacobs)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Jul 2000 08:00:04 GMT
From: o1technospam@skyenet.nospam.net.bbs@openbazaar.net (Jim Kauzlarich)
Subject: "Perl Bowling" revisited with an array question
Message-Id: <3bOaO8$Vm0@openbazaar.net>
Ok, not wanting to beat a dead horse, but... I got started on this stuipd
thing, and I want to finish it.
You'll probably remember the "Is there a way in Perl to determine the lenght
of a string" question. Of course this got almost as many deriding comments
as it deserved, and then several people, including myself, had some fun
posting the nastiest code they could think of to do the job.
Anyway, I as fiddeled with LISP a few years ago (ok, more than a few), I was
thinking that recursion would be a (good?) way to handel this problem.
Unfortionatly, I seem to be either using the wrong tools, or using them
incorrectly.
The following is my code, inside of which are three supposidly
interchangable sections (two are commented out, so that the code actually
does work as posted). The first two work as expected. But the third
section does not. I have tracked down the problem to the fact that shift,
unlike join, returns the value of the element it shifted out of the array,
rather than the newly shifted array.
So, I guess my question is: Is there any function that will shrink (at this
point I don't care which end it comes off of) an array, and return the newly
shrunken array.
Thanks!
[Almost made the mistake of the "harmless" act of doing a search and replace
of 'crap' with 'stuff' to "clean up" my post. Luckily I cut & paste it
back and tried to run it. I am learning. (Though I don't think I've ever
posted untested code. Not that I've posted much.) ]
!/usr/bin/perl -w
use strict;
sub dumdum {
my (@crap) = split (//, $_[0]);
my ($crap);
if ($_[0] eq "") {
return 0;
}
########### The following 3 commented sections are supposed to be inter-
########### changeable, and infact, the first two are. But I'm having
########### trouble with the third version.
########### Fisrt version
########### 3 lines
# shift (@crap); # works
# $crap = join ("", @crap); # works
# return (dumdum ($crap)+1) # works
########### Second version
########### 2 lines
shift (@crap); # works
return (dumdum ( join ("", @crap))+1); # works
########### Third version
########### 1 line
# return (dumdum ( join ("", shift (@crap)))+1); # want somethin like this
########### End of sub dumdum
}
my ($string)="You suck!!";
print dumdum ($string)."\n";
JMK
------------------------------
Date: 17 Jul 2000 19:40:04 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: "Perl Bowling" revisited with an array question
Message-Id: <3bRNB5$VqV@openbazaar.net>
Ala Qumsieh (aqumsieh@hyperchip.com) wrote on MMDIX September MCMXCIII in
<URL:news:7abt00kcgy.fsf@merlin.hyperchip.com>:
:)
:) "Jim Kauzlarich" <o1technospam@skyenet.nospam.net> writes:
:)
:) > So, I guess my question is: Is there any function that will shrink (at this
:) > point I don't care which end it comes off of) an array, and return the newly
:) > shrunken array.
:)
:) Hmmm .. what's wrong with:
:)
:) my @all_except_last = @array[0 .. $#array - 1];
:) my @all_except_first = @array[1 .. $#array];
That leaves @array unmodified. So, if you write it as:
@array = @array [1 .. $#array];
it does both requirements. It removes 1 element from @array, and it returns
the "new" array.
Abigail
--
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: 17 Jul 2000 19:40:04 GMT
From: abigail@delanet.com.bbs@openbazaar.net (Abigail)
Subject: Re: "Perl Bowling" revisited with an array question
Message-Id: <3bRNB4$VmO@openbazaar.net>
Ilmari Karonen (iltzu@sci.invalid) wrote on MMDIX September MCMXCIII in
<URL:news:963583664.9274@itz.pp.sci.fi>:
[] In article <3971128f.37528294@nntp.idsonline.com>, Keith Calvert Ivey wrote:
[] >Eh? Like shift() and pop(), splice() returns the removed
[] >elements, not the newly shrunken array.
[]
[] Ah, but it's all in the way you look at it..
[]
[] my @all_but_first = splice @array, 1;
[]
[] my @all_but_last = splice @array, 0, -1;
But that doesn't shrink @array with one element.
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54"; s/<<EOT/<<EOT/e; print;
Just another Perl Hacker
EOT
------------------------------
Date: 17 Jul 2000 17:50:01 GMT
From: Martin.Jost@icn.siemens.de.bbs@openbazaar.net (Martin Jost)
Subject: Re: "Text file busy" error message
Message-Id: <3bRKHP$Vm4@openbazaar.net>
[Follow-up set to comp.lang.perl.misc; this doesn't seem to be a
module-problem]
laurie@swanharbor.com wrote:
>
> I'm configuring a guestbook CGI -- on running the script, I receive the
> following error message: "Text file busy". I get the same error when I
> go in on Telnet and type the file name, however when I type perl before
> the file name everything seems to be fine.
"Text file busy" means your trying to overwrite a executable file
which is at that moment running.
So what is your script named ?
What does
which NAME-OF-YOUR-SCRIPT
say ? (It should report the full path to your script)
(I guess (without the 'perl ...' you start not your script but
something else.)
HTH
Martin
------------------------------
Date: 17 Jul 2000 17:20:01 GMT
From: jlsimms@my-deja.com.bbs@openbazaar.net ()
Subject: $sth->{PrintError} and Huge Queries?
Message-Id: <3bRJS2$TLZ@openbazaar.net>
I am having an interesting problem to which I have found an even more
interesting solution. The problem arose when I was trying to execute
extremely large queries (on the order of > 1.2 million characters) on
the database (mySQL). Say I have a _very_ large query, that looks
something like this:
$sql = SELECT id, name from mytable where name IN ( name1, name2 ...
name1000000)
In my code, I can prepare it without a hitch:
$sth = $dbh->prepare($sql);
But when I go to execute it, doing a plain $sth->execute, it hangs...
The strange thing is that this query worked before, so I went to find
the difference in the old database code and my stuff. The only
difference was that in the original code, before the execute() but after
the prepare(), I set $sth->{PrintError} to 0.
After inserting this single line of code that sets $sth->{PrintError} to
0, the huge query executed without a problem and returned a correct
result set.
Why would PrintError allow or not allow a large query to go through? In
either case (whether PrintError is set to 1 or 0), smaller queries
execute fine. The threshold is something around a length() of 1.2
million characters... Any ingight? Again, this is on mySQL 3.22.32 on
RedHat Linux, with the standard Perl DBI.
Jason Simms
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 18 Jul 2000 00:10:01 GMT
From: catfood@apk.net.bbs@openbazaar.net (Mark W. Schumann)
Subject: Re: $sth->{PrintError} and Huge Queries?
Message-Id: <3bRUCT$Ubx@openbazaar.net>
In article <8kves2$19s$1@nnrp1.deja.com>, <jlsimms@my-deja.com> wrote:
>I am having an interesting problem to which I have found an even more
>interesting solution. The problem arose when I was trying to execute
>extremely large queries (on the order of > 1.2 million characters) on
>the database (mySQL). Say I have a _very_ large query, that looks
>something like this:
>
>$sql = SELECT id, name from mytable where name IN ( name1, name2 ...
>name1000000)
No it doesn't. That won't compile.
>In my code, I can prepare it without a hitch:
>
>$sth = $dbh->prepare($sql);
I don't believe you.
>But when I go to execute it, doing a plain $sth->execute, it hangs...
>The strange thing is that this query worked before, so I went to find
>the difference in the old database code and my stuff. The only
>difference was that in the original code, before the execute() but after
>the prepare(), I set $sth->{PrintError} to 0.
>
>After inserting this single line of code that sets $sth->{PrintError} to
>0, the huge query executed without a problem and returned a correct
>result set.
>
>Why would PrintError allow or not allow a large query to go through? In
>either case (whether PrintError is set to 1 or 0), smaller queries
>execute fine. The threshold is something around a length() of 1.2
>million characters... Any ingight? Again, this is on mySQL 3.22.32 on
>RedHat Linux, with the standard Perl DBI.
Hmmmm. Is this programming running under CGI?
In any case, try posting some cut-n-pasted code so we can see exactly
what you're trying to do.
------------------------------
Date: 17 Jul 2000 17:20:01 GMT
From: jlsimms@hotmail.com.bbs@openbazaar.net ()
Subject: $sth->{PrintError} and Large Queries?
Message-Id: <3bRJS1$THW@openbazaar.net>
I am having an interesting problem to which I have found an even more
interesting solution. The problem arose when I was trying to execute
extremely large queries (on the order of > 1.2 million characters) on
the database (mySQL). Say I have a _very_ large query, that looks
something like this:
$sql = SELECT id, name from mytable where name IN ( name1, name2 ...
name1000000)
In my code, I can prepare it without a hitch:
$sth = $dbh->prepare($sql);
But when I go to execute it, doing a plain $sth->execute, it hangs...
The strange thing is that this query worked before, so I went to find
the difference in the old database code and my stuff. The only
difference was that in the original code, before the execute() but after
the prepare(), I set $sth->{PrintError} to 0.
After inserting this single line of code that sets $sth->{PrintError} to
0, the huge query executed without a problem and returned a correct
result set.
Why would PrintError allow or not allow a large query to go through? In
either case (whether PrintError is set to 1 or 0), smaller queries
execute fine. The threshold is something around a length() of 1.2
million characters... Any ingight? Again, this is on mySQL 3.22.32 on
RedHat Linux, with the standard Perl DBI.
Jason Simms
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Jul 2000 17:10:03 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: 'my' and references
Message-Id: <3bNNdR$WXm@openbazaar.net>
On Wed, 12 Jul 2000 15:26:35 GMT, Peter Ip <ip@ariel.utcc.utoronto.ca> wrote:
>Consider:
OK, but you don't want to do what you are doing...
>my $a = "one";
>$b = "two";
>
>{
> $x = "a";
> print "$a $x -> $$x\n";
> $y = "b";
> print "$b $y -> $$y\n";
>}
>
>Why does $$x produce nothing while $$y produces the desired "two"?
Because *Evil* Symbolic References only work with dynamic variables
and $a is a lexical variable.
Perl FAQ, part 7:
"What's the difference between dynamic and lexical (static) scoping?
Between local() and my()?"
>I
>kept rereading the Cookbook and
>the perlsub man page about 'my' but get no answer.
The relevant doc to read is the "Symbolic references"
section in perlref.pod (you even mention references in your
Subject, so you must have already looked in perlref. You
must have missed that section...)
But you might not want to bother with that after seeing:
http://www.plover.com/~mjd/perl/varvarname.html
http://www.plover.com/~mjd/perl/varvarname2.html
http://www.plover.com/~mjd/perl/varvarname3.html
>(What I really want
>is foreach $key ( qw(a b c)) {...}
>to loop over a set of variables and do something with them.
Why not just do:
foreach $key ( $a, $b, $c) {...}
??
No evil symrefs. That is Very Good!
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 11 Jul 2000 14:40:01 GMT
From: aqumsieh@hyperchip.com.bbs@openbazaar.net (Ala Qumsieh)
Subject: Re: -w and Use of uninitialized value at
Message-Id: <3bMUK3$Vjf@openbazaar.net>
"mike solomon" <mike.solomon@eps.ltd.uk> writes:
> Since looking at this newsgroup I have decided to start experimenting with
> using the -w flag in my scripts
Good. The next step for you would be to start using the strict
pragma. Read more on it 'perldoc strict'.
> the following script is called from the Unix command line and gives
> information about a user or several users
>
> it can either be called as : name userid or just as name then it requests a
> user id
>
> if I run it without an argument I get :
>
> Use of uninitialized value at /usr/local/sscript/name line 10.
>
> the question i have is how can i stop this message
let's see.
> and is there any reason i shoulnt use unintialised values
Not if you know exactly what you're doing.
> i have looked at the faq and found no help there
>
> anyway the script is :
>
> #! /usr/local/bin/perl -w
> #name
> #Mon Jun 26 13:01:01 BST 2000 itdmjs
> #show user name
>
> use strict;
>
> my $NAME = $ARGV[0];
If you supply no arguments in the command line, @ARGV will be empty. So
$ARGV[0] will be undefined. Why not set $NAME to the empty string if
@ARGV is empty?
my $NAME = $ARGV[0] || '';
or, equivalently,
my $NAME = shift || '';
> while ( ${NAME} eq "" ) {
>
> print "\nENTER NAME TO FIND : \n";
>
> $NAME = <STDIN>;
> chomp($NAME);
You can do the above two steps in one:
chomp($NAME = <>);
> }
>
> #set name to lowercase
> $NAME = lc($NAME);
>
> #open password file for reading
> open(PASSWD,'/etc/passwd');
check for your opens:
open PASSWD, '/etc/passwd' or
die "Can't open /etc/passwd: $!\n";
> while(<PASSWD>) {
>
> my ( $USERID, $UNAME ) = (split(/:/))[0, 4];
>
> $_ = lc($_);
>
> if ( $_ =~ /$NAME/ ) {
> print "$USERID $UNAME\n";
> }
> }
> __END__
Why do you capitalize your variable names? By convention, all capital
variables refer to constants.
HTH,
--Ala
------------------------------
Date: 11 Jul 2000 15:40:01 GMT
From: mike.solomon@eps.ltd.uk.bbs@openbazaar.net (mike solomon)
Subject: Re: -w and Use of uninitialized value at
Message-Id: <3bMVl4$YO4@openbazaar.net>
thanks for this
I tried
my $NAME = $ARGV[0] || '';
and
my $NAME = shift || '';
but both unfortunately it still leaves me with the message if no argument is
supplied
the reason I use capitals is that I am not a programmer and learnt perl my
converting old awk scripts using a2p
I always used capitals as I found it more readable
Ala Qumsieh <aqumsieh@hyperchip.com> wrote in message
news:7awvisk9s9.fsf@merlin.hyperchip.com...
>
> "mike solomon" <mike.solomon@eps.ltd.uk> writes:
>
> > Since looking at this newsgroup I have decided to start experimenting
with
> > using the -w flag in my scripts
>
> Good. The next step for you would be to start using the strict
> pragma. Read more on it 'perldoc strict'.
>
> > the following script is called from the Unix command line and gives
> > information about a user or several users
> >
> > it can either be called as : name userid or just as name then it
requests a
> > user id
> >
> > if I run it without an argument I get :
> >
> > Use of uninitialized value at /usr/local/sscript/name line 10.
> >
> > the question i have is how can i stop this message
>
> let's see.
>
> > and is there any reason i shoulnt use unintialised values
>
> Not if you know exactly what you're doing.
>
> > i have looked at the faq and found no help there
> >
> > anyway the script is :
> >
> > #! /usr/local/bin/perl -w
> > #name
> > #Mon Jun 26 13:01:01 BST 2000 itdmjs
> > #show user name
> >
> > use strict;
> >
> > my $NAME = $ARGV[0];
>
> If you supply no arguments in the command line, @ARGV will be empty. So
> $ARGV[0] will be undefined. Why not set $NAME to the empty string if
> @ARGV is empty?
>
> my $NAME = $ARGV[0] || '';
>
> or, equivalently,
>
> my $NAME = shift || '';
>
> > while ( ${NAME} eq "" ) {
> >
> > print "\nENTER NAME TO FIND : \n";
> >
> > $NAME = <STDIN>;
> > chomp($NAME);
>
> You can do the above two steps in one:
>
> chomp($NAME = <>);
>
> > }
> >
> > #set name to lowercase
> > $NAME = lc($NAME);
> >
> > #open password file for reading
> > open(PASSWD,'/etc/passwd');
>
> check for your opens:
>
> open PASSWD, '/etc/passwd' or
> die "Can't open /etc/passwd: $!\n";
>
> > while(<PASSWD>) {
> >
> > my ( $USERID, $UNAME ) = (split(/:/))[0, 4];
> >
> > $_ = lc($_);
> >
> > if ( $_ =~ /$NAME/ ) {
> > print "$USERID $UNAME\n";
> > }
> > }
> > __END__
>
> Why do you capitalize your variable names? By convention, all capital
> variables refer to constants.
>
> HTH,
> --Ala
------------------------------
Date: 17 Jul 2000 07:20:04 GMT
From: davejohnson@lansdownsoftware.co.uk.bbs@openbazaar.net (Dave Johnson)
Subject: .dentifying user using htaccess i
Message-Id: <3bR3k4$VG4@openbazaar.net>
HI,
Can anyone tell me how I can pick up the identity of a user when they're
logged with password etc?
Is there some environment variable around indicating the current use's ID?
Thanks
Dave Johnson
begin 666 Dave Johnson.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..DIO:&YS;VX[1&%V90T*1DXZ
M1&%V92!*;VAN<V]N#0I.24-+3D%-13I$879E#0I/4D<Z3&%N<V1O=VX@4V]F
M='=A<F4-"E1%3#M73U)+.U9/24-%.BLT-" H,"D@,3(W,R T-S4W,30-"D%$
M4CM73U)+.CL[,C<@3&%N<V1O=VX@4&QA8V4[3&5W97,[4W5S<V5X.T).-R R
M2E4[1T(-"DQ!0D5,.U=/4DL[14Y#3T1)3D<]455/5$5$+5!224Y404),13HR
M-R!,86YS9&]W;B!0;&%C93TP1#TP04QE=V5S+"!3=7-S97@@0DXW(#)*53TP
M1#TP04="#0I%34%)3#M04D5&.TE.5$523D54.F1A=F5J;VAN<V]N0&QA;G-D
M;W=N<V]F='=A<F4N8V\N=6L-"E)%5CHR,# P,#<Q-U0P-S$W-#):#0I%3D0Z
'5D-!4D0-"@``
`
end
------------------------------
Date: 17 Jul 2000 08:40:03 GMT
From: bart.lateur@skynet.be.bbs@openbazaar.net (Bart Lateur)
Subject: Re: .dentifying user using htaccess i
Message-Id: <3bR624$UyH@openbazaar.net>
Dave Johnson wrote:
>Can anyone tell me how I can pick up the identity of a user when they're
>logged with password etc?
>Is there some environment variable around indicating the current use's ID?
$ENV{REMOTE_USER}
--
Bart.
------------------------------
Date: 18 Jul 2000 05:40:03 GMT
From: pastan@my-deja.com.bbs@openbazaar.net ()
Subject: ???How to make Daemon in Perl without Cron?
Message-Id: <3bRcf3$Wjv@openbazaar.net>
Hello All,
I need to schedule my tasks without. But unfortunately I don't have an
opportunity to use Cron or similar. How can I implement scheduling
by means of Perl functions such as fork, kill,...?
Thank You, all
Regards,
Andrew
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 14 Jul 2000 05:40:02 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: @ not piped in print << -> must escape as \@
Message-Id: <3bOWf3$XvY@openbazaar.net>
On Fri, 14 Jul 2000 02:17:08 GMT, Shannon Jacobs <shanen@my-deja.com> wrote:
>Okay, I've spent at least an hour trying to understand this without
>success. FAQs, newsgroups, camel, etc.
perldoc perldiag
--------------------------------
=item In string, @%s now must be written as \@%s
(F) It used to be that Perl would try to guess whether you wanted an
array interpolated or a literal @. It did this when the string was first
used at runtime. Now strings are parsed at compile time, and ambiguous
instances of @ must be disambiguated, either by prepending a backslash to
indicate a literal, or by declaring (or using) the array within the
program before the string (lexically). (Someday it will simply assume
that an unbackslashed @ interpolates an array.)
--------------------------------
>Situation: Static Web page designed with TopPage. Includes some email
>references. Converted it to dynamic page by cutting it up with print <<
>for the static parts,
You should use single quotes for constant strings. Single-quoted
strings don't care about @ signs.
You can get single-quoted here-docs too:
print <<'HEREDOC';
shanen@my-deja.com
tadmc@metronet.com
HEREDOC
>then use Perl in the gaps for the dynamic stuff.
>(Mostly form options with time or data file contingencies.) Technique
>is lazy and impatient, but @ from HTML source requires backslash. Why?
^^^^
Ah, finally. I was beginning to wonder if you were going to
actually ask a question.
I think the docs answer it though?
>Appears to be related to invocation via Web
>server (Apache under AIX).
I wouldn't know about that.
>However, probably similar problem disables
>perldoc--error is "In string, @sys now must be written as \@sys at...."
Huh?
>Hypothesis: weird@.
Use the docs, Luke.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Jul 2000 13:10:03 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: @ not piped in print << -> must escape as \@
Message-Id: <3bQNRT$U0G@openbazaar.net>
[ Usenet is a plain text medium. Please use plain text. ]
On Sun, 16 Jul 2000 09:42:05 +0900, Shannon Jacobs <shanen@my-deja.com> wrote:
>"Tad McClellan" <tadmc@metronet.com> wrote in
>> =item In string, @%s now must be written as \@%s
>This sort of appears to address the "why" that I was seeking, but I'm afraid
>that I still can't understand exactly what is going on here.
>
>The camel book (and the other sources I used for this aspect) did not say
>anything revealing about the use of "print <<foo;" or "print <<\"foo\";"
>which makes me hope that there is nothing deep to be revealed there.
There is not.
"here-docs" (that is the name of the << thingie) are merely a
different form of quoting a string.
You can use a quoted string many places, not just with print().
So you can use here-docs many places, it is not wedded to print().
>Or is
>there? It seems like the user's only responsibility should be to make sure
>that the terminal string does not appear anywhere in the text to be spewed
^^^^^^^^
>[in the simplest of possible worlds].
Actually in _can_ appear in the text, it just cannot appear as the
only thing on a line in the text:
$_ =<<ENDSTR;
line one
ENDSTR
line three
ENDSTR
:-)
>If I understand what you are saying [or quoting], Perl (but only at compile
>time?) is still trying to interpret the to-be-spewed text, and it is
>concerned about the possibly ambiguous use of @bar.com. But I would prefer
>it do nothing except watch for a literal occurrence of the terminal string.
So you don't need the here-doc to interpolate variables?
You can use a single-quoted here-doc then:
$_ =<<'ENDSTR';
line one
tadmc@metronet.com
line three
ENDSTR
>What else might it be doing to the HTML that TopPage has so carefully thrown
>at it? Are there other things I just haven't noticed or that I've luckily
>avoided so far?
I dunno.
I would need to know what the data is to answer that, and I
don't know what TopPage spews (or even what TopPage is :-)
><snip>
>> You should use single quotes for constant strings. Single-quoted
>> strings don't care about @ signs.
>>
>> You can get single-quoted here-docs too:
>>
>> print <<'HEREDOC';
>> shanen@my-deja.com
>> tadmc@metronet.com
>> HEREDOC
>
>Sorry, but you're confusing me again... Hopefully my confusion on this point
>is not critical? I've also seen it with no quotes at all and with double
>quotes,
no quotes defaults to "double quotish".
You can have here-docs that interpolate:
print <<HEREDOC; # a "double quotish string"
print <<"HEREDOC"; # same thing
And you can have here-docs that do not interpolate (as above).
Just as you can have more conventionally quoted strings that are double
quotish and ones that are not.
>but I trusted that Perl was doing one of it's apparently obscure
>conversions to something it liked? Or are you actually suggesting that using
>a ' in this situation would work around TopPage's use of " within the HTML?
I dunno what TopPage does (or is).
That sounds like something specific to the application that
you happen to be using Perl for. I know Perl, I do not know
your application.
>I'm trying to remember if all of the @s in the HTML source were within
>double quotes, though I'm sure that I used "print <<EOT;" without any...
^^^^^^^^^^^
So you got a double quotish string then.
Literal at signs must be escaped in double quotish strings.
It must be escaped regardless of whether you use "double quotes"
or a here-doc.
>
><snip>
>> Ah, finally. I was beginning to wonder if you were going to
>> actually ask a question.
>>
>> I think the docs answer it though?
>
>I rather believe they do, and even if they didn't, Perl answers by its
>behavior. But the answers to why questions can be tough, and right now I
>still don't capish. I have a fuzzy feeling that Larry is planning to do
>something more with @ in the future... Heaven forbid it isn't doing enough
>already! ;-)
Larry used @ to indicate an array data type.
He is already "doing something", not just "planning to" :-)
-----------------------------
#!/usr/bin/perl -w
use strict;
my @metronet = qw/zero one two/;
$_ =<<ENDSTR;
line one
tadmc@metronet.com
line three
ENDSTR
print;
-----------------------------
@metronet gets expanded just the same as if we had not used a here-doc.
$_ ="line one
tadmc@metronet.com
line three
";
><snip>
>> >However, probably similar problem disables
>> >perldoc--error is "In string, @sys now must be written as \@sys at...."
>>
>> Huh?
>
>You mean this isn't intuitively obvious to the most casual observer? ;-)
Strangle enough it is not.
We get asked several times a month how to fix the problem!
>Seriously, that's part of the error message that "perldoc" invokes on the
>Unix boxen.
perl's docs are the same on all platforms. No "on Unix" qualifier needed.
Or are you saying that the perldoc program has this bug?
>So here is a doc-related question whose answer I've yet to stumble across in
>the docs. A lot of the time in Perl-related matters strange characters are
>part of the question, but they are not easily searchable. In this particular
>case, if I had been able to figure out a good way to search for "<<"
perldoc -q '<<'
That finds a FAQ about here-docs...
>after
>"print" I hope I would have quickly come to some revealing information...
here-docs are not related to the print() function.
They are often used with print(), but they can be used *anywhere*
you would use a more conventionally quoted string.
here-docs are quoted strings.
They are not tricky. They are just strings.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Jul 2000 14:20:01 GMT
From: kcivey@cpcug.org.bbs@openbazaar.net (Keith Calvert Ivey)
Subject: Re: @ not piped in print << -> must escape as \@
Message-Id: <3bQPJ1$UiL@openbazaar.net>
"Shannon Jacobs" <shanen@my-deja.com> wrote:
>Sorry, but you're confusing me again... Hopefully my confusion on this point
>is not critical? I've also seen it with no quotes at all and with double
>quotes, but I trusted that Perl was doing one of it's apparently obscure
>conversions to something it liked? Or are you actually suggesting that using
>a ' in this situation would work around TopPage's use of " within the HTML?
>I'm trying to remember if all of the @s in the HTML source were within
>double quotes, though I'm sure that I used "print <<EOT;" without any...
It's not the easiest thing to search for in the documentation,
but the explanation you want is in perldata, under "Scalar value
constructors", starting from the sentence "A line-oriented form
of quoting is based on the shell ``here-doc'' syntax."
It has nothing to do with the occurrence of the " character in
your HTML. It has to do with whether the string is being
interpreted in double-quotish or single-quotish context. If you
pur double quotes or no quotes around the marker after <<, then
Perl interpolates scalar and array variables (just as in a
double-quoted string), so you have to escape all $ and @
characters that you want included literally; it also interprets
backslashed sequences like \n for newline. If you put single
quotes around the marker after <<, then Perl doesn't do that; it
sounds like that's the solution to your problem.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 16 Jul 2000 14:50:03 GMT
From: kcivey@cpcug.org.bbs@openbazaar.net (Keith Calvert Ivey)
Subject: Re: @ not piped in print << -> must escape as \@
Message-Id: <3bQQ8R$XLf@openbazaar.net>
tadmc@metronet.com (Tad McClellan) wrote:
>On Sun, 16 Jul 2000 09:42:05 +0900, Shannon Jacobs <shanen@my-deja.com> wrote:
>>You mean this isn't intuitively obvious to the most casual observer? ;-)
>
>Strangle enough it is not.
Freudian slip, Tad?
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: 16 Jul 2000 11:10:02 GMT
From: shanen@my-deja.com.bbs@openbazaar.net (Shannon Jacobs)
Subject: Re: @ not piped in print << -> must escape as \@
Message-Id: <3bQKLQ$Svc@openbazaar.net>
"Tad McClellan" <tadmc@metronet.com> wrote in
<snip>
> perldoc perldiag
Pretty sure I looked at that one, too. But diagnosing and even fixing the
problem wasn't too difficult.
> --------------------------------
> =item In string, @%s now must be written as \@%s
>
> (F) It used to be that Perl would try to guess whether you wanted an
> array interpolated or a literal @. It did this when the string was first
> used at runtime. Now strings are parsed at compile time, and ambiguous
> instances of @ must be disambiguated, either by prepending a backslash to
> indicate a literal, or by declaring (or using) the array within the
> program before the string (lexically). (Someday it will simply assume
> that an unbackslashed @ interpolates an array.)
This sort of appears to address the "why" that I was seeking, but I'm afraid
that I still can't understand exactly what is going on here.
The camel book (and the other sources I used for this aspect) did not say
anything revealing about the use of "print <<foo;" or "print <<\"foo\";"
which makes me hope that there is nothing deep to be revealed there. Or is
there? It seems like the user's only responsibility should be to make sure
that the terminal string does not appear anywhere in the text to be spewed
[in the simplest of possible worlds].
If I understand what you are saying [or quoting], Perl (but only at compile
time?) is still trying to interpret the to-be-spewed text, and it is
concerned about the possibly ambiguous use of @bar.com. But I would prefer
it do nothing except watch for a literal occurrence of the terminal string.
What else might it be doing to the HTML that TopPage has so carefully thrown
at it? Are there other things I just haven't noticed or that I've luckily
avoided so far?
<snip>
> You should use single quotes for constant strings. Single-quoted
> strings don't care about @ signs.
>
> You can get single-quoted here-docs too:
>
> print <<'HEREDOC';
> shanen@my-deja.com
> tadmc@metronet.com
> HEREDOC
Sorry, but you're confusing me again... Hopefully my confusion on this point
is not critical? I've also seen it with no quotes at all and with double
quotes, but I trusted that Perl was doing one of it's apparently obscure
conversions to something it liked? Or are you actually suggesting that using
a ' in this situation would work around TopPage's use of " within the HTML?
I'm trying to remember if all of the @s in the HTML source were within
double quotes, though I'm sure that I used "print <<EOT;" without any...
<snip>
> Ah, finally. I was beginning to wonder if you were going to
> actually ask a question.
>
> I think the docs answer it though?
I rather believe they do, and even if they didn't, Perl answers by its
behavior. But the answers to why questions can be tough, and right now I
still don't capish. I have a fuzzy feeling that Larry is planning to do
something more with @ in the future... Heaven forbid it isn't doing enough
already! ;-)
<snip>
> >However, probably similar problem disables
> >perldoc--error is "In string, @sys now must be written as \@sys at...."
>
> Huh?
You mean this isn't intuitively obvious to the most casual observer? ;-)
Seriously, that's part of the error message that "perldoc" invokes on the
Unix boxen. I've called it to the attention of the sysgods, but my English
may have confused them again... For now I bypass or use the lowly "man".
> >Hypothesis: weird@.
>
> Use the docs, Luke.
I have, and even the Japanese versions (but mostly indirectly). But Perl
does not seem to lend itself to convenient explication. Reminds me of trying
to talk about Lisp before I could use the language--and I think that's a big
chunk of why so few people care about Lisp anymore. Does a similar fate
await Perl?
So here is a doc-related question whose answer I've yet to stumble across in
the docs. A lot of the time in Perl-related matters strange characters are
part of the question, but they are not easily searchable. In this particular
case, if I had been able to figure out a good way to search for "<<" after
"print" I hope I would have quickly come to some revealing information... Is
there some search engine with such a capability linked to a significant body
of perl documentation?
Still, thanks for the information, and I'll try to digest it some more on
Monday, between battles with the new version of Notes...
--
.a/ssig
Spam not unto me! I shall decode thy email headers and trace thy routes,
and smite them, and I shall pursue thee and thy provider and thy provider's
upstream link. Yea, unto the seventh generation shall I pursue thy links,
and thou shall spam no more.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3705
**************************************