[16599] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4011 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 14 14:10:32 2000

Date: Mon, 14 Aug 2000 11:10:22 -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: <966276621-v9-i4011@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 14 Aug 2000     Volume: 9 Number: 4011

Today's topics:
    Re: Perl for Palm? (matt venn)
        Perlshop having probs with sendmail in Win98 <jhorniblow@ntlworld.com>
    Re: print problem <ck@ix.heise.de>
    Re: print problem <care227@attglobal.net>
    Re: print problem <mail@mail.com>
    Re: print problem nobull@mail.com
    Re: print problem (Abigail)
    Re: rand() not random at all (Abigail)
    Re: regex <care227@attglobal.net>
    Re: regex <ayres@gold.cis.ohio-state.edu>
    Re: regex nobull@mail.com
    Re: round nobull@mail.com
    Re: round (Logan Shaw)
    Re: round <lr@hpl.hp.com>
        su.c tunin@my-deja.com
    Re: tag parsing. johnvert@my-deja.com
    Re: tag parsing. johnvert@my-deja.com
    Re: tag parsing. <godzilla@stomp.stomp.tokyo>
        XML::DOM question <no_spam_frage@post1.tele.dk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 14 Aug 2000 16:58:29 GMT
From: matt@NOSPAMcipherdesign.com (matt venn)
Subject: Re: Perl for Palm?
Message-Id: <3998252c.29428175@news.ntlworld.com>

shame


------------------------------

Date: Mon, 14 Aug 2000 18:55:28 +0100
From: "Jonathan Horniblow" <jhorniblow@ntlworld.com>
Subject: Perlshop having probs with sendmail in Win98
Message-Id: <yoWl5.5067$pR4.99170@news6-win.server.ntlworld.com>

I download Apache. Then ActivePerl. Then Perlshop.
Perlshops inbuilt sockets mailer wasn't having any of it (sendmail error -3)
so I downloaded a Win32 version of sendmail from
http://www.winsite.com/info/pc/winnt/netutil/sendmail.zip/
Got it all running and configured nicely by the end of the day.
Sendmail works fine on it's own.

However, when Perlshop comes to call Sendmail, the debug output from
Sendmail complains about not having a message body.

Here's the routine that calls Sendmail (I think).

#------------------------------------------------------------------#
sub  sendmail
{
 my($to, $from, $subject,  $body) = @_;

 if (lc $mail_via eq 'sendmail')
  {
  open (MAIL, "|$sendmail_loc -t -oi") || &err_trap("Can't open
$sendmail_loc!\n");

  print MAIL "To: $to\n";
  print MAIL "From: $from\n";
  print MAIL "Subject: $subject\n";
  print MAIL "$body\n";
  close MAIL;
  }
 else
  {
  if (lc $mail_via eq 'blat')
   {
   open (MAIL, "|$blat_loc - -t $to -s $subject") || &err_trap("Can't open
$blat_loc!\n");
   print MAIL "To: $to\n";
   print MAIL "From: $from\n";
   print MAIL "Subject: $subject\n";   print MAIL "$body\n\x1a";
   close MAIL;
   }
  else
   {
   $err = &sockets_mail($to, $from, $subject, $body);
   if ($err < 1)
    {print "<br>\nSendmail error # $err<br>\n";}
   }
  }
}
#------------------------------------------------------------------#

I'm a bit of a newbie at this, and I don't mind doing the RTFM bit, and
indeed I have, but I'm a bit lost at this point, and any pointers would be
gratefully received.

If it helps, here's what the order confirmation page of Perlshop says:

 ...Shipping and handling charges are not refundable. Error: Must specify
message body or have at least one attachment. BCWare Sendmail/NT v1.1.4
built on Apr 9 1999 at 12:34:32. (c) Nigel R. Ellis 1994 - 1999 Usage:
sendmail [-help] [-to {ToList} | -list {File}] -from From [-cc {CcList}]
[-bcc {BccList}] [-subject Subject] [-F MsgBodyFile] [-A AttachFile [-A
AttachFile ...]] [-h localhostname] [-r smtphost] [-m transport] [-User
MAPIUser] [-Pass MAPIPasswd] [-Trace] sendmail -q DOMAIN Use sendmail -help
for further usage and licensing information. Error: Must specify message
body or have at least one attachment. BCWare Sendmail/NT v1.1.4 built on Apr
9 1999 at 12:34:32. (c) Nigel R. Ellis 1994 - 1999 Usage: sendmail [-help]
[-to {ToList} | -list {File}] -from From [-cc {CcList}] [-bcc {BccList}]
[-subject Subject] [-F MsgBodyFile] [-A AttachFile [-A AttachFile ...]] [-h
localhostname] [-r smtphost] [-m transport] [-User MAPIUser] [-Pass
MAPIPasswd] [-Trace] sendmail -q DOMAIN Use sendmail -help for further usage
and licensing information.

Thanks.




------------------------------

Date: Mon, 14 Aug 2000 17:06:03 +0200
From: Christian Kirsch <ck@ix.heise.de>
Subject: Re: print problem
Message-Id: <39980ADB.F94087FC@ix.heise.de>

Brian wrote:

> open( REC, "+<rec.txt" ) || die "Can't open rec.txt";
> while(<REC>) {
>     chomp;
>  $theLine = substr( $theLine, 0, 30 );
>  $subThisLine = substr( $_, 0, 30 );
>  if( $theLine eq $subThisLine ) {
> 
> ###### WHY ISN'T THIS PRINTING ###########
>    print REC $_, "...", $comment, "\n";
> ###### WHY ISN'T THIS PRINTING ###########

Do you seriously expect Perl to write something to a file
handle that has been opened for reading?


-- 
Christian Kirsch
ck@held.mind.de       ck@ix.heise.de
Tel +49-30-78702288   +49-511-5352-590   
Fax +49-30-78702289


------------------------------

Date: Mon, 14 Aug 2000 11:34:08 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: print problem
Message-Id: <39981170.21A4C4C7@attglobal.net>

Christian Kirsch wrote:
> 
> Brian wrote:
> 
> > open( REC, "+<rec.txt" ) || die "Can't open rec.txt";
> > while(<REC>) {
> >     chomp;
> >  $theLine = substr( $theLine, 0, 30 );
> >  $subThisLine = substr( $_, 0, 30 );
> >  if( $theLine eq $subThisLine ) {
> >
> > ###### WHY ISN'T THIS PRINTING ###########
> >    print REC $_, "...", $comment, "\n";
> > ###### WHY ISN'T THIS PRINTING ###########
> 
> Do you seriously expect Perl to write something to a file
> handle that has been opened for reading?
> 

From perlfunc:

You can put a '+' in front of the '>' or '<' to indicate that you 
want both read and write access to the file;


------------------------------

Date: Mon, 14 Aug 2000 11:48:18 -0500
From: Brian <mail@mail.com>
Subject: Re: print problem
Message-Id: <399822D2.9D2C0DCD@mail.com>

Yes, because I added the +.

Christian Kirsch wrote:

> Brian wrote:
>
> > open( REC, "+<rec.txt" ) || die "Can't open rec.txt";
> > while(<REC>) {
> >     chomp;
> >  $theLine = substr( $theLine, 0, 30 );
> >  $subThisLine = substr( $_, 0, 30 );
> >  if( $theLine eq $subThisLine ) {
> >
> > ###### WHY ISN'T THIS PRINTING ###########
> >    print REC $_, "...", $comment, "\n";
> > ###### WHY ISN'T THIS PRINTING ###########
>
> Do you seriously expect Perl to write something to a file
> handle that has been opened for reading?
>
> --
> Christian Kirsch
> ck@held.mind.de       ck@ix.heise.de
> Tel +49-30-78702288   +49-511-5352-590
> Fax +49-30-78702289



------------------------------

Date: 14 Aug 2000 17:48:23 +0100
From: nobull@mail.com
Subject: Re: print problem
Message-Id: <u9em3rdc14.fsf@wcl-l.bham.ac.uk>

Brian <mail@mail.com> writes:

> Would anyone have an idea as to why this wouldn't be printing?

No I have no idea. Indeed I suspect that it is printing.

However I'd expect it to do something different from what I suspect
you are trying to do.

See FAQ: "How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the beginning of
a file?"

> --------------8827D7A3CAF59477F46D1246
> Content-Type: text/html; charset=us-ascii

Please refrain from doing this.  This is a plain text newsgroup.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: 14 Aug 2000 17:51:37 GMT
From: abigail@foad.org (Abigail)
Subject: Re: print problem
Message-Id: <slrn8pgcc8.tj3.abigail@alexandra.foad.org>

Christian Kirsch (ck@ix.heise.de) wrote on MMDXL September MCMXCIII in
<URL:news:39980ADB.F94087FC@ix.heise.de>:
:) Brian wrote:
:) 
:) > open( REC, "+<rec.txt" ) || die "Can't open rec.txt";
:) > while(<REC>) {
:) >     chomp;
:) >  $theLine = substr( $theLine, 0, 30 );
:) >  $subThisLine = substr( $_, 0, 30 );
:) >  if( $theLine eq $subThisLine ) {
:) > 
:) > ###### WHY ISN'T THIS PRINTING ###########
:) >    print REC $_, "...", $comment, "\n";
:) > ###### WHY ISN'T THIS PRINTING ###########
:) 
:) Do you seriously expect Perl to write something to a file
:) handle that has been opened for reading?


It *is* opened for reading. But mixing reading and writing a loop is
a pretty dumb idea. Buffering will trash everything, and with buffering
turned off, it still is generally a very bad idea.


But I wrote that yesterday as well, saying that trying to the problem by
opening the file for read/write is *NOT* going to solve it.


Read in the entire file, or use a temporary file.


Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


------------------------------

Date: 14 Aug 2000 17:54:57 GMT
From: abigail@foad.org (Abigail)
Subject: Re: rand() not random at all
Message-Id: <slrn8pgcif.tj3.abigail@alexandra.foad.org>

Jonne Viljanen (Jonne.Viljanen@helsinki.fi) wrote on MMDXL September
MCMXCIII in <URL:news:3997E349.938F9F88@remove_this_from_address.helsinki.fi>:
{} Hi,
{} 
{} I'm trying to get a simple random number to specify a filename, but
{} whenever the script is run, I always get the same "random" number
{} (AUG3VRM6) as an output. What could be wrong?
{} 
{} ---clip
{} 
{} #create a random name having 8 characters
{} my @chars = ( 'A'..'Z', 0..9 );
{} my $len = 8 || shift;
{} my $random_name   = '';
{} 
{} $random_name .= $chars[int rand(@chars)] while length $random_name <
{} $len;


It doesn't generate the same strings for me.

Perhaps there's some more code that's relevant and you aren't showing us?

(This is NOT an invitation to paste your entire script. Try to make a tiny
(< 10 lines) program that exhibits your problem.)



Abigail
-- 
# Perl 5.6.0 broke this.
%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


------------------------------

Date: Mon, 14 Aug 2000 11:12:07 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: regex
Message-Id: <39980C47.D34B2C16@attglobal.net>

jponder9@my-deja.com wrote:
> 
> Hi all,
>       This is driving me mad!! I am testing for decimal places on a
> number and when encountering more than 2 i wish to substitute however
> many there are for just the 2 i.e. trimming them down to 2 decimal
> places. Trouble is i cant use printf (long story!) with which it would
> be a doddle.
>      Any ideas gratefully received
>                                    Jimbo
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


$string = 1234.567;
$string =~ s/(\d\.\d{2})\d*/$1/ if $string =~ /\d\.\d{3,}/;


------------------------------

Date: 14 Aug 2000 11:54:41 -0400
From: lee taggard ayres <ayres@gold.cis.ohio-state.edu>
Subject: Re: regex
Message-Id: <v9gya1zaldq.fsf@gold.cis.ohio-state.edu>

jponder9@my-deja.com writes:

> Hi all,
>       This is driving me mad!! I am testing for decimal places on a
> number and when encountering more than 2 i wish to substitute however
> many there are for just the 2 i.e. trimming them down to 2 decimal
> places. Trouble is i cant use printf (long story!) with which it would
> be a doddle.
>      Any ideas gratefully received
>                                    Jimbo
> 
> 

Is the goal to round the numeric value of the scalar or to display a
rounded representation of the scalar value?

Rounding the scalar is a trivial operation even without printf. The
first thing that comes to mind is $foo = (int($foo * 100))/ 100. floor
or ceil can be substituted for int depending on the desired result.

Display is a slightly different animal since print happily drops
trailing zeros.  Something like this should work fine if you just want
to drop the trailing decimal places.

print ($foo =~ /^(\d*)\.(\d{0,2})\d*$/)  ? 
      ($2 >= 10 ? "$1.$2" : "$1.$2"."0") :
      "Not a number";

-- 
Lee Ayres <ayres@cis.ohio-state.edu> www.cis.ohio-state.edu/~ayres


------------------------------

Date: 14 Aug 2000 18:24:29 +0100
From: nobull@mail.com
Subject: Re: regex
Message-Id: <u9aeefdacy.fsf@wcl-l.bham.ac.uk>

jponder9@my-deja.com writes:

> Hi all,
>       This is driving me mad!! I am testing for decimal places on a
> number and when encountering more than 2 i wish to substitute however
> many there are for just the 2 i.e. trimming them down to 2 decimal
> places. Trouble is i cant use printf (long story!) with which it would
> be a doddle.

s/(\.\d\d)\d+/\1/;

(You did say you wanted to truncate not round).


------------------------------

Date: 14 Aug 2000 17:36:10 +0100
From: nobull@mail.com
Subject: Re: round
Message-Id: <u9hf8ndclh.fsf@wcl-l.bham.ac.uk>

eastking@my-deja.com writes:

> I'd rather use a function such as round(). It is said in perlfaq that I
> can use sprintf to do this. following is my test script.
> 
> 
> my $a = 1.25;
> my $b = 1.250;
> printf("%1.1f",$a);
> print "\n";
> printf("%1.1f",$b);
> 
> it showed following under windows2000/Activeperl
>    1.3
>    1.3
> 
> but it showed following under pc-solaris
> 
>    1.2
>    1.3
> 
> and following under linux
> 
>    1.2
>    1.2
> 
> I'm really confused.

Don't worry, it doesn't matter.  Floating point numbers are only ever
appoximations to the real number.  Any code that assumes otherwise is
broken. As such when you say 1.25 you really mean 1.25 +/- a tiny bit.
If you round this to 1 decimal place then 1.2 and 1.3 are acceptable
answers.  I'm supprised that PC-Solaris interpreted 1.25 and 1.250
differently but it shouldn't break anything that's not already broken.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: 14 Aug 2000 11:50:40 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: round
Message-Id: <8n9810$2m6$1@provolone.cs.utexas.edu>

In article <u9hf8ndclh.fsf@wcl-l.bham.ac.uk>,  <nobull@mail.com> wrote:
>eastking@my-deja.com writes:
>Don't worry, it doesn't matter.  Floating point numbers are only ever
>appoximations to the real number.  Any code that assumes otherwise is
>broken. As such when you say 1.25 you really mean 1.25 +/- a tiny bit.
>If you round this to 1 decimal place then 1.2 and 1.3 are acceptable
>answers.  I'm supprised that PC-Solaris interpreted 1.25 and 1.250
>differently but it shouldn't break anything that's not already broken.

You're right that some decimal fractional numbers can't be represented
exactly in binary, but in this case it's not true.  Decimal 1.25 is
exactly equal to binary 1.01.  Likewise, decimal 1.250 is also exactly
equal to that.

So, I really don't understand what's going on in the situation
described above.  By the way, on the two Solaris systems I tried it on
(SPARC SunOS 5.7 and Intel SunOS 5.8), the printf just printed "1.2"
every time.

  - Logan


------------------------------

Date: Mon, 14 Aug 2000 10:12:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: round
Message-Id: <MPG.1401c867a9035598ac71@nntp.hpl.hp.com>

In article <8n8eh3$irv$1@nnrp1.deja.com> on Mon, 14 Aug 2000 09:35:31 
GMT, eastking@my-deja.com <eastking@my-deja.com> says...
> hello every one here.

Hello from one here.

> I'd rather use a function such as round(). It is said in perlfaq that I
> can use sprintf to do this. following is my test script.

You can't use a function that doesn't exist.  Indeed sprintf is the 
correct function to use for rounding.

> my $a = 1.25;
> my $b = 1.250;
> printf("%1.1f",$a);
> print "\n";
> printf("%1.1f",$b);
> 
> it showed following under windows2000/Activeperl
>    1.3
>    1.3

Evidently this implementation is using a 'round ties away from zero' 
rule, without the sophistication of the 'round ties to nearest even' 
modification -- see below.

> but it showed following under pc-solaris
> 
>    1.2
>    1.3

It is most surprising that an input-conversion routine would produce a 
different internal representation for the strings '1.25' and '1.250'.  I 
would characterize it as a bug.

> and following under linux
> 
>    1.2
>    1.2

The default rounding mode according to the IEEE floating-point standard 
is 'round ties to nearest even'.  This means that 1.25 rounds to 1.2 and 
1.75 rounds to 1.8.  The reason is to avoid an upward bias for all 
numbers that are exactly 0.1(binary) in the fraction being rounded away.  
(In binary, the number you are testing is 1.01).

> I'm really confused.

It is indeed a confusing issue.  IMO, the default rule, while 
mathematically sound, is wrongheaded because it deals counterintuitively 
with so many common cases, such as this one.  It should have been an 
option available to pedants who needed it.

Ultimately, the behavior is characterized by the implementation of the C 
library, which is evidently different for Windows and Linux.  I 
confirmed this behavior for HP-UX also.

> please help me. Thank in advance

HTH.  You're welcome.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Mon, 14 Aug 2000 16:52:24 GMT
From: tunin@my-deja.com
Subject: su.c
Message-Id: <8n9845$62a$1@nnrp1.deja.com>

could anybody help me. I am looking for the su.c source code on unix.

do you know where can i get it ?

thankx

 ./tunin/.


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Mon, 14 Aug 2000 15:11:17 GMT
From: johnvert@my-deja.com
Subject: Re: tag parsing.
Message-Id: <8n926h$u8$1@nnrp1.deja.com>

In article <SBIl5.17452$rd1.3870066@typhoon-news1.southeast.rr.com>,
 "Philip Garrett" <philipg@atl.mediaone.net> wrote:
 > <johnvert@my-deja.com> wrote in message
 news:8n7hgn$v2g$1@nnrp1.deja.com...
 > >
 > > However, if each of these lines is split across each element of an
 > > array, as in:
 > >
 > > @tlines=split(/\n/, $t);
 > >
 > > The regexp above will not work since parts of what I'm trying to
 > > retrieve is in different elements of 'tlines'.  So my question is:
 how
 > > would I parse such an array?
 >
 > ($data) = join( "", @tlines) =~ /\<T\>(.*)\<\/T\>/;
 >
 > That works for this small example, but if you want to do a lot of
 parsing
 > like this, you might want to check out the perldoc pages for
 HTML::Parser
 > and HTML::TokeParser.
 >
 > HTH,
 > Philip

 I want to use HTML::TokeParser, as it seems a lot more logical than
 quick-n-dirty regexps.  I tried the following:

    $p=HTML::TokeParser->new("file");
     while($line=$p->get_token("<T>"))
     {
       my $text=$p->get_trimmed_text;
       print "$text\n";
     }

 Taken from the HTML::TokeParser examples.  The problem is, the stuff
 between <T> and </T> is a bunch of tags, and I simply want to retrieve
 these tags -as is-.  Example:

    <T><f>f</f><d c="left"></d></T>

 I want it to return: <f>f</f><d c="left"></d>

 How can I achieve that with HTML::TokeParser?  The above does not work.

 Thanks a lot,
   -- john


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Mon, 14 Aug 2000 15:36:50 GMT
From: johnvert@my-deja.com
Subject: Re: tag parsing.
Message-Id: <8n93mi$23s$1@nnrp1.deja.com>

 In article <SBIl5.17452$rd1.3870066@typhoon-news1.southeast.rr.com>,
   "Philip Garrett" <philipg@atl.mediaone.net> wrote:
 > <johnvert@my-deja.com> wrote in message
 news:8n7hgn$v2g$1@nnrp1.deja.com...
 > >
 > > However, if each of these lines is split across each element of an
 > > array, as in:
 > >
 > > @tlines=split(/\n/, $t);
 > >
 > > The regexp above will not work since parts of what I'm trying to
 > > retrieve is in different elements of 'tlines'.  So my question is:
 how
 > > would I parse such an array?
 >
 > ($data) = join( "", @tlines) =~ /\<T\>(.*)\<\/T\>/;
 >
 > That works for this small example, but if you want to do a lot of
 parsing
 > like this, you might want to check out the perldoc pages for
 HTML::Parser
 > and HTML::TokeParser.
 >
 > HTH,
 > Philip

 I want to use HTML::TokeParser, as it seems a lot more logical than
 quick-n-dirty regexps.  I tried the following:

   $p=HTML::TokeParser->new("file");
     while($line=$p->get_token("<T>"))
     {
       my $text=$p->get_trimmed_text;
       print "$text\n";
     }

 Taken from the HTML::TokeParser examples.  The problem is, the stuff
 between <T> and </T> is a bunch of tags, and I simply want to retrieve
these
 tags -as is-.  Example:

   <T><f>f</f><d c="left"></d></T>

 I want it to return: <f>f</f><d c="left"></d>

 How can I achieve that with HTML::TokeParser?  The above does not work.


 Thanks a lot,
   -- john


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Mon, 14 Aug 2000 10:51:11 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: tag parsing.
Message-Id: <3998318F.178A9F5@stomp.stomp.tokyo>

johnvert wrote:
 
> Philip Garrett wrote:
>  > johnvert wrote:

(snipped)

>  > ($data) = join( "", @tlines) =~ /\<T\>(.*)\<\/T\>/;

>  > That works for this small example, but if you want to 
>  > do a lot of  parsing like this, you might want to check
>  >  out the perldoc pages for  HTML::Parser and HTML::TokeParser.

>  I want to use HTML::TokeParser, as it seems a lot more logical than
>  quick-n-dirty regexps.  I tried the following:
 
>    $p=HTML::TokeParser->new("file");
>      while($line=$p->get_token("<T>"))
>      {
>        my $text=$p->get_trimmed_text;
>        print "$text\n";
>      }
 
>  Taken from the HTML::TokeParser examples.  The problem is, the stuff
>  between <T> and </T> is a bunch of tags, and I simply want to retrieve
>  these  tags -as is-.  Example:
 
>    <T><f>f</f><d c="left"></d></T>
 
>  I want it to return: <f>f</f><d c="left"></d>
 
>  How can I achieve that with HTML::TokeParser?  The above does not work.
 

Jeeesshh... unimaginative Techno-Geeksters and
their Cargo Cult modules. 

Some bare bones skeleton scripts showing some
alternative methods, per your stated parameters.

Do not respond with changed parameters and,

"This doesn't work."


Gozilla!



TEST SCRIPTS:
______________


#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";


## Single Line, Single T-Line Entry Method:

$string = 'Mule Manure<T><f>f</f><d c="left"></d></T> Mule Manure';

$string =~ s!.*<T>(.+)</T>.*!$1!;

print "Single String Method:\n\n  $string";


## Multiple Line, Multiple T-Line Method:

$/ = "";
open (TEST, "test.txt");
$string = <TEST>;
close (TEST);

if (!($string))
 { print "Danger Will Robinson! Danger!"; exit; }

$string =~ s/\n//g;
$string =~ s!<T>|</T>!¦!g;

@Array = split (/¦/, $string);

print "\n\nMultiple Line Method:\n\n";

foreach $element (@Array)
 { 
  if ($element =~/</)
   { print "  $element\n"; }
 }

print "\n\n\nAll Done Boss.";

exit;


CONTENTS OF TEST.TXT:
_____________________

<T><f>f</f><d c="left"> LINE ONE </d></T> Mule Manure
<T><f>f</f><d c="left"> LINE TWO </d></T>Some Gibberish<T><f>f
</f><d c="left"> LINE THREE </d></T>
Techno-Geeksters Have No Imagination<T><f>f</f>
<d c="left">
 LINE FOUR </d></T>


PRINTED RESULTS:
________________

Single String Method:

  <f>f</f><d c="left"></d>

Multiple Line Method:

  <f>f</f><d c="left"> LINE ONE </d>
  <f>f</f><d c="left"> LINE TWO </d>
  <f>f</f><d c="left"> LINE THREE </d>
  <f>f</f><d c="left"> LINE FOUR </d>



All Done Boss.


------------------------------

Date: Mon, 14 Aug 2000 19:19:49 +0200
From: "F. Geeb" <no_spam_frage@post1.tele.dk>
Subject: XML::DOM question
Message-Id: <39982A34.FC7A86BA@post1.tele.dk>

What would be the fastest way to navigate through a xml-document to a
node with an attribute which is unique in this document (id-number eg:
 ... <text id="21"> ...)?
Thanks in advance for your help!
F. Geeb



------------------------------

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 4011
**************************************


home help back first fref pref prev next nref lref last post