[12610] in Perl-Users-Digest
Perl-Users Digest, Issue: 19 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 6 17:47:14 1999
Date: Tue, 6 Jul 1999 14:36:22 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 6 Jul 1999 Volume: 9 Number: 19
Today's topics:
"Can't call method 'traverse' without a package or obje <hiller@email.com>
$scalars in s/// not working - anyone have any ideas? <dudeman@dude.com>
Re: $scalars in s/// not working - anyone have any idea <uri@sysarch.com>
Re: $scalars in s/// not working - anyone have any idea <dudeman@dude.com>
Re: $scalars in s/// not working - anyone have any idea <aperrin@mcmahon.qal.berkeley.edu>
Re: $scalars in s/// not working - anyone have any idea <james@rtweb.net>
Re: ** What's at the end of a string? (Abigail)
Re: ** What's at the end of a string? (Philip 'Yes, that's my address' Newton)
Re: ** What's at the end of a string? (Anno Siegel)
Re: ** What's at the end of a string? (Philip 'Yes, that's my address' Newton)
Re: ** What's at the end of a string? (Abigail)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 03 Jul 1999 19:14:06 GMT
From: Jordan Hiller <hiller@email.com>
Subject: "Can't call method 'traverse' without a package or object reference..."
Message-Id: <377E6146.F1B84F02@email.com>
I am trying to use HTML::FormatText to get the plain text from a web page. Here
is my test code:
-BEGIN CODE-
use HTML::FormatText;
$html = "<HTML><BODY>This is a test!</BODY></HTML>";
$ascii = HTML::FormatText->new->format($html);
-END CODE-
I get the following error message:
Can't call method "traverse" without a package or object reference at /usr/lib
/perl5/site_perl/HTML/Formatter.pm line 94, <GEN0> chunk 49.
I can't decipher what it means, and I especially don't get it because it is
referring to a package I'm not even directly using. Can anyone help me out?
Thanks,
Jordan Hiller (hiller@email.com)
--
JavaScript and Perl programs for
making online tests and quizzes:
http://web-shack.hypermart.net/quiz.html
------------------------------
Date: Mon, 5 Jul 1999 11:15:27 -0700
From: "Dude Man" <dudeman@dude.com>
Subject: $scalars in s/// not working - anyone have any ideas?
Message-Id: <7lqsni$siu$1@fir.prod.itd.earthlink.net>
Hi all,
I've a got a seemingly weird problem (perhaps because I just haven't worked
with substitution alot yet) where if I use a multidemensional array in an
s///, it won't replace anything - eg: (line 9, and no, the line numbers are
not in my code ;)
1 $lineCount=1;
2 while ($line ne "")
3 {
4 $colTmp=0;
5 while ($colTmp < $colCount)
6 {
7 $replace="<--##$fields[0][$colTmp]##-->";
8 $replaceWith=$fields[$lineCount][$colTmp]; # if I replace
$lineCount & $colTmp with a number it
9 $line =~ s/$replace/$replaceWith/; # works just
fine.
10 $colTmp++;
11 }
12 }
So it only seems that I can't use scalars in the multidemensional array when
doing s///'s.
If anyone has any idea how I can get around this, I'd be most appreciative.
Thanks in advance for any help!
-Arlo
------------------------------
Date: 05 Jul 1999 17:41:39 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: $scalars in s/// not working - anyone have any ideas?
Message-Id: <x7673yydt8.fsf@home.sysarch.com>
>>>>> "DM" == Dude Man <dudeman@dude.com> writes:
DM> I've a got a seemingly weird problem (perhaps because I just
DM> haven't worked with substitution alot yet) where if I use a
DM> multidemensional array in an s///, it won't replace anything - eg:
DM> (line 9, and no, the line numbers are not in my code ;)
well then they shouldn't be in your post. they make it very hard to read
the code. just insert good ol' english comments in your code when you post.
DM> 1 $lineCount=1;
DM> 2 while ($line ne "")
DM> 3 {
DM> 4 $colTmp=0;
DM> 5 while ($colTmp < $colCount)
DM> 6 {
DM> 7 $replace="<--##$fields[0][$colTmp]##-->";
DM> 8 $replaceWith=$fields[$lineCount][$colTmp]; # if I replace
DM> $lineCount & $colTmp with a number it
have you any idea what is in $lineCount & $colTmp? they could be out of range.
print them out and print out $replaceWith and see what you have. also
arrays are zero based yet you start $lineCount with 1.
DM> 9 $line =~ s/$replace/$replaceWith/; #
that is fine perl as it is. s/// doesn't care what the vars are or where
they got set. it has nothing to do with s/// not likeing
multidimensions. in fact as your code shows, s/// is getting scalar
values so that comment is off base.
DM> 10 $colTmp++;
where do you get a new $line or bump $lineCount? the context of this
code is very vague.
DM> So it only seems that I can't use scalars in the multidemensional
DM> array when doing s///'s.
that statement makes no sense at all. why would one affect the other?
how could s/// know what indexs you used to get the vars that are
interpolated indie it?
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Mon, 5 Jul 1999 15:48:22 -0700
From: "Dude Man" <dudeman@dude.com>
Subject: Re: $scalars in s/// not working - anyone have any ideas?
Message-Id: <7lrcna$qmb$1@fir.prod.itd.earthlink.net>
Hi (thanks taking a look!)
Here's the whole thing:
if ( open(CATBODYFILE, $CATBODY) )
{
$bodyLine = <CATBODYFILE>;
$lineCount=1;
while ($bodyLine ne "")
{
$colTmp=0;
while ($colTmp < $colCount)
{
$replace="<--##$fields[0][$colTmp]##-->";
$replaceWith=$fields[$count][$colTmp];
$bodyLine =~ s/$replace/$replaceWith/;
$colTmp++;
}
print "$bodyLine\n";
$bodyLine = <CATBODYFILE>;
$count++;
}
}
Here's the weird thing, if I print out $fields[$count][$colTmp], it prints
the
correct data (which is just a simple comma delimited file containing
catalog items.) Thats the strange thing is that the data appears to be
stored correctly (btw $fields[0][0] is header info that I don't need to
print.)
But I only have a problem with substitution function. If I change the line
$replaceWith=$fields[$count][$colTmp];
to read: $replaceWith=$fields[1][1]; as a test, then s/// works just
fine.
It's almost as its a bug, or I'm referencing the variable incorrectly. BTW,
I'm using ActivePerl 5.005_03 build 517 on NT (I know thats
a whole other discussion <g>).
Does that clear it up a bit?
-Arlo
Uri Guttman wrote in message ...
>>>>>> "DM" == Dude Man <dudeman@dude.com> writes:
>
> DM> I've a got a seemingly weird problem (perhaps because I just
> DM> haven't worked with substitution alot yet) where if I use a
> DM> multidemensional array in an s///, it won't replace anything - eg:
> DM> (line 9, and no, the line numbers are not in my code ;)
>
>well then they shouldn't be in your post. they make it very hard to read
>the code. just insert good ol' english comments in your code when you post.
>
> DM> 1 $lineCount=1;
> DM> 2 while ($line ne "")
> DM> 3 {
> DM> 4 $colTmp=0;
> DM> 5 while ($colTmp < $colCount)
> DM> 6 {
> DM> 7 $replace="<--##$fields[0][$colTmp]##-->";
> DM> 8 $replaceWith=$fields[$lineCount][$colTmp]; # if I replace
> DM> $lineCount & $colTmp with a number it
>
>have you any idea what is in $lineCount & $colTmp? they could be out of
range.
>print them out and print out $replaceWith and see what you have. also
>arrays are zero based yet you start $lineCount with 1.
>
> DM> 9 $line =~ s/$replace/$replaceWith/; #
>
>that is fine perl as it is. s/// doesn't care what the vars are or where
>they got set. it has nothing to do with s/// not likeing
>multidimensions. in fact as your code shows, s/// is getting scalar
>values so that comment is off base.
>
> DM> 10 $colTmp++;
>
>where do you get a new $line or bump $lineCount? the context of this
>code is very vague.
>
> DM> So it only seems that I can't use scalars in the multidemensional
> DM> array when doing s///'s.
>
>that statement makes no sense at all. why would one affect the other?
>how could s/// know what indexs you used to get the vars that are
>interpolated indie it?
>
>
>uri
>
>
>--
>Uri Guttman ----------------- SYStems ARCHitecture and Software
Engineering
>uri@sysarch.com --------------------------- Perl, Internet, UNIX
Consulting
>Have Perl, Will Travel -----------------------------
http://www.sysarch.com
>The Best Search Engine on the Net -------------
http://www.northernlight.com
>"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Tue, 06 Jul 1999 07:52:51 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: $scalars in s/// not working - anyone have any ideas?
Message-Id: <37821842.F90B8D93@mcmahon.qal.berkeley.edu>
Dude Man wrote:
> 3 {
> 4 $colTmp=0;
> 5 while ($colTmp < $colCount)
> 6 {
> 7 $replace="<--##$fields[0][$colTmp]##-->";
> 8 $replaceWith=$fields[$lineCount][$colTmp]; # if I replace
> $lineCount & $colTmp with a number it
I'd like to know what the values of $lineCount, $colTmp, $replace, and
$replaceWith are at this point - my guess is they're not being set properly. It
strains the imagination to think that when $replace and $replaceWith are
equivalent but set differently above, the following line would behave
differently. So use either a print statement or perl -d to figure out the values
here; if they're getting set properly, you've still got a problem; if not,
figure out how to set them properly.
> 9 $line =~ s/$replace/$replaceWith/; # works just
> fine.
> So it only seems that I can't use scalars in the multidemensional array when
> doing s///'s.
--
-------------------------------------------------------------
Andrew Perrin - NT/Unix/Access Consulting - aperrin@mcmahon.qal.berkeley.edu
http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------
------------------------------
Date: Tue, 06 Jul 1999 19:47:47 GMT
From: "James Mastros" <james@rtweb.net>
Subject: Re: $scalars in s/// not working - anyone have any ideas?
Message-Id: <01bec7e8$a41a9c20$5f66fad0@default>
Dude Man <dudeman@dude.com> wrote in article
<7lqsni$siu$1@fir.prod.itd.earthlink.net>...
> Hi all,
>
> I've a got a seemingly weird problem (perhaps because I just haven't
worked
> with substitution alot yet) where if I use a multidemensional array in an
> s///, it won't replace anything - eg: (line 9, and no, the line numbers
are
> not in my code ;)
>
> 1 $lineCount=1;
> 2 while ($line ne "")
> 3 {
> 4 $colTmp=0;
> 5 while ($colTmp < $colCount)
> 6 {
> 7 $replace="<--##$fields[0][$colTmp]##-->";
> 8 $replaceWith=$fields[$lineCount][$colTmp]; # if I replace
> $lineCount & $colTmp with a number it
> 9 $line =~ s/$replace/$replaceWith/; # works just
> fine.
> 10 $colTmp++;
> 11 }
> 12 }
Have you tried putting a print $replaceWith between line 8 and 9? The s///
on line 9 shouldn't be able to tell what $replaceWith came from, only it's
value, so it's value must be wrong. Specificly, I don't see where
$lineCount is incremented. I also note that a foreach is pretty well talor
made to this curcumstance:
(Note: untested code written by a novice)
my $cols=0;
my $totalLines=0;
COL: foreach $col (@fields) {
$cols++;
ROW: foreach $line (@$col) {
$totalLines++;
unless ($line) {
last COL;
}
my $replace="<--##$fields[0][$colTmp]##-->";
my $replaceWith="$fields[$totalLines][$cols]";
$line ~= s/$replace/$replaceWith/;
}
}
#There is probably a way to get rid of $totalLines and $cols by better
orgnization of $fields, but that is
#beyond the scope of this question.
-=- James Mastros
------------------------------
Date: 3 Jul 1999 04:37:32 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: ** What's at the end of a string?
Message-Id: <slrn7nrmeb.31h.abigail@alexandra.delanet.com>
Victor (penpendisarapen@my-deja.com) wrote on MMCXXXI September MCMXCIII
in <URL:news:377db6f5@news1.jps.net>:
?? I need to find out if the last character of a string is a "B". How would I
?? do this?
print "Yes, it is a B!!!!!!\n"
if chop (my $x = $str) lt 'C' &&
chop (my $y = $str) gt 'A';
Abigail
--
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 04 Jul 1999 05:55:29 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: ** What's at the end of a string?
Message-Id: <377ef4aa.1259495@news.nikoma.de>
On 3 Jul 1999 04:37:32 -0500, abigail@delanet.com (Abigail) wrote:
>print "Yes, it is a B!!!!!!\n"
> if chop (my $x = $str) lt 'C' &&
> chop (my $y = $str) gt 'A';
As I understand it, this may not work as expected if you're using
locales... there might be some letters besides 'B' (e.g. Á Â etc.)
between 'A' and 'C'.
HTH, HAND
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.net>
------------------------------
Date: 4 Jul 1999 19:32:18 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: ** What's at the end of a string?
Message-Id: <7locs2$l1l$1@lublin.zrz.tu-berlin.de>
Philip 'Yes, that's my address' Newton <nospam.newton@gmx.net> wrote in comp.lang.perl.misc:
>On 3 Jul 1999 04:37:32 -0500, abigail@delanet.com (Abigail) wrote:
>
>>print "Yes, it is a B!!!!!!\n"
>> if chop (my $x = $str) lt 'C' &&
>> chop (my $y = $str) gt 'A';
>
>As I understand it, this may not work as expected if you're using
>locales... there might be some letters besides 'B' (e.g. Á Â etc.)
>between 'A' and 'C'.
Not if he is using (an extension of) ascii (or ebcdic, for that matter).
Anno
------------------------------
Date: Mon, 05 Jul 1999 04:32:20 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: ** What's at the end of a string?
Message-Id: <3780327a.82632067@news.nikoma.de>
On 4 Jul 1999 19:32:18 -0000, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
>Philip 'Yes, that's my address' Newton <nospam.newton@gmx.net> wrote in comp.lang.perl.misc:
>>On 3 Jul 1999 04:37:32 -0500, abigail@delanet.com (Abigail) wrote:
>>
>>>print "Yes, it is a B!!!!!!\n"
>>> if chop (my $x = $str) lt 'C' &&
>>> chop (my $y = $str) gt 'A';
>>
>>As I understand it, this may not work as expected if you're using
>>locales... there might be some letters besides 'B' (e.g. Á Â etc.)
>>between 'A' and 'C'.
>
>Not if he is using (an extension of) ascii (or ebcdic, for that matter).
OK, badly put. There probably aren't many character encodings (is that
the right term?) where there are other letters besides 'B' between 'A'
and 'C'. However, I'm sure there are sort orders where other letters
*sort* between 'A' and 'C' -- such as possibly accented versions of
'A', e.g. (1) 'A Á Â À Ä Å Ã C Ç'. Or -- I'm told -- there are sort
order that sort upper-case and lower-case letters intermingled, e.g.
(2) 'A a B b C c' or (3) 'a A b B c C'.
And as I understand it, Perl's lt and gt operators grok locales if you
"use locale" (POSIX's LC_COLLATE I think is the important locale
here). So just because there are no characters with code points
between those of 'A' and 'C' doesn't mean that the following might not
be true:
for (1), 'Ä' lt 'C' && 'Ä' gt 'A' && 'Ä' ne 'B'
for (2), 'a' lt 'C' && 'a' gt 'A' && 'a' ne 'B'
for (3), 'c' lt 'C' && 'c' gt 'A' && 'c' ne 'B'
On the other hand,
if ord(chop (my $x = $str)) < ord('C') &&
ord(chop (my $y = $str)) > ord('A');
should work as expected on ASCII (and supersets) and EBCDIC (though
for the latter you'll have to watch out for the two(?) discontinuities
in the alphabet).
That's as I understand it. Feel free to correct me.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.net>
------------------------------
Date: 5 Jul 1999 01:07:12 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: ** What's at the end of a string?
Message-Id: <slrn7o0irs.h6v.abigail@alexandra.delanet.com>
that's my address' Newton (nospam.newton@gmx.net) wrote on MMCXXXIV
September MCMXCIII in <URL:news:3780327a.82632067@news.nikoma.de>:
&& On 4 Jul 1999 19:32:18 -0000, anno4000@lublin.zrz.tu-berlin.de (Anno
&& Siegel) wrote:
&&
&& >Philip 'Yes, that's my address' Newton <nospam.newton@gmx.net> wrote in comp.lang.perl.misc:
&& >>On 3 Jul 1999 04:37:32 -0500, abigail@delanet.com (Abigail) wrote:
&& >>
&& >>>print "Yes, it is a B!!!!!!\n"
&& >>> if chop (my $x = $str) lt 'C' &&
&& >>> chop (my $y = $str) gt 'A';
&& >>
&& >>As I understand it, this may not work as expected if you're using
&& >>locales... there might be some letters besides 'B' (e.g. Á Â etc.)
&& >>between 'A' and 'C'.
&& >
&& >Not if he is using (an extension of) ascii (or ebcdic, for that matter).
&&
&& And as I understand it, Perl's lt and gt operators grok locales if you
&& "use locale" (POSIX's LC_COLLATE I think is the important locale
&& here). So just because there are no characters with code points
&& between those of 'A' and 'C' doesn't mean that the following might not
&& be true:
&&
&& for (1), 'Ä' lt 'C' && 'Ä' gt 'A' && 'Ä' ne 'B'
&& for (2), 'a' lt 'C' && 'a' gt 'A' && 'a' ne 'B'
&& for (3), 'c' lt 'C' && 'c' gt 'A' && 'c' ne 'B'
&&
It's of course easily fixed:
{no locale;
print "It is a 'B'!\n"
if ord(chop (my $x = $str)) < ord('C') &&
ord(chop (my $y = $str)) > ord('A');
}
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 19
************************************