[16608] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4020 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 15 06:10:28 2000

Date: Tue, 15 Aug 2000 03:10:18 -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: <966334217-v9-i4020@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 15 Aug 2000     Volume: 9 Number: 4020

Today's topics:
    Re: Perlshop having probs with sendmail in Win98 <gellyfish@gellyfish.com>
    Re: push (@INC (Villy Kruse)
    Re: rand() not random at all <Jonne.Viljanen@remove_this_from_address.helsinki.fi>
    Re: rand() not random at all <iltzu@sci.invalid>
    Re: regex nobull@mail.com
    Re: regular expression help <bcaligari@shipreg.com>
    Re: regular expression help nobull@mail.com
    Re: round (Anno Siegel)
    Re: Substituting newlines for HTML equivalent <gellyfish@gellyfish.com>
    Re: tag parsing. ( OFF TOPIC - IGNORE ) <godzilla@stomp.stomp.tokyo>
    Re: tag parsing. <gellyfish@gellyfish.com>
    Re: Updating flat text file problem (Logan Shaw)
    Re: what the heck is C<$_> ?? (Gwyn Judd)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 15 Aug 2000 07:34:15 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perlshop having probs with sendmail in Win98
Message-Id: <8nao97$oc$1@orpheus.gellyfish.com>

In comp.lang.perl.misc Jonathan Horniblow <jhorniblow@ntlworld.com> wrote:
> 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.
> 

You need an extra blank line between the header lines and the body of the
message.  As it stands you dont have a body but a big header with errors
in it.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 15 Aug 2000 07:37:38 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: push (@INC
Message-Id: <slrn8phsq1.oag.vek@pharmnl.ohout.pharmapartners.nl>

On Mon, 14 Aug 2000 22:16:24 GMT, Rodney Engdahl <red_orc@my-deja.com> wrote:
>In article <8n9qtq$lch$1@nnrp1.deja.com>,
>  Rodney Engdahl <red_orc@my-deja.com> wrote:
>> In article <8n9q1c$kqu$1@nnrp1.deja.com>,
>>   dschl@my-deja.com wrote:
>> > Why doesn't push(@INC,...) work?
>> >
>> > My source file contains these lines:
>> >
>> >   BEGIN{
>> >   push(@INC, '/var/ns-home/cgi-bin');
>>
>> ^^^ this happens at "run" time, after the BEGIN block has executed.
>^^^
>oops, like an idiot, i didn't even see the BEGIN around the whole block.
>
>ick!  I hate that.  Please ignore the less than totally factual attempt
>at an explanation.  5 full demerits, and back to the shadows to lurk
>some more until I learn some more.
>
>


Check perldoc lib for the easy way of doing it.


Other alternatives: Use 'require' instead of 'use' or move 'use' out of
the BEGIN block.




Villy


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

Date: Tue, 15 Aug 2000 11:23:37 +0300
From: Jonne Viljanen <Jonne.Viljanen@remove_this_from_address.helsinki.fi>
Subject: Re: rand() not random at all
Message-Id: <3998FE09.9BB9C9A1@remove_this_from_address.helsinki.fi>

Thanks everyone!!!

It seemed that the 5.003 perl required the use of srand prior to rand().

JV


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

Date: 15 Aug 2000 09:49:14 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: rand() not random at all
Message-Id: <966332716.15073@itz.pp.sci.fi>

In article <3998FE09.9BB9C9A1@remove_this_from_address.helsinki.fi>, Jonne Viljanen wrote:
>
>It seemed that the 5.003 perl required the use of srand prior to rand().

I would like to humbly express my personal opinion that what perl
5.003 needs is not srand(), but an upgrade.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: 15 Aug 2000 08:48:03 +0100
From: nobull@mail.com
Subject: Re: regex
Message-Id: <u9u2cnnd3d.fsf@wcl-l.bham.ac.uk>

Larry Rosler <lr@hpl.hp.com> writes:

> In article <u9aeefdacy.fsf@wcl-l.bham.ac.uk> on 14 Aug 2000 18:24:29 
> +0100, nobull@mail.com <nobull@mail.com> says...

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

> Change the /\1/ to /$1/ to avoid a warning.   

Eh, yes I've just been using EMACS - oops.

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


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

Date: Tue, 15 Aug 2000 11:31:45 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: regular expression help
Message-Id: <8nb219$kq7$1@news.news-service.com>


"Jesse Heffinger" <jheffinger@ipivot.com> wrote in message
news:sphl5taokn970@corp.supernews.com...
> I have a string I would like to parse into substrings using the whitespace
> as the delimiter as long as the whitespace is not within double quotes.
>
> ie.
>
> $line = "a = \"  two  \"    and  b=\"     three   \"";
>
> @tokens = split /regexpr/, $line;
>
> desire output:
>
> @tokens->[0]: a
> @tokens->[1]: =
> @tokens->[2]: "  two  "
> @tokens->[3]: and
> @tokens->[4]: b="   three   "
>
> I'm having a hard time coming up with an expression to ignore the
> whitespaces inside the quotations.  Any suggestions?
>
>

this is an ugly solution but it worked

@tokens = ();
for ($line =~ s/\s*//; $line; $line =~ s/\s*//) {
 $line =~ s/(^[^\s\"]*(\"[^\"]*\"){0,1})//;
 push(@tokens, $1);
}

Brendon
++++





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

Date: 15 Aug 2000 08:58:34 +0100
From: nobull@mail.com
Subject: Re: regular expression help
Message-Id: <u9og2uop34.fsf@wcl-l.bham.ac.uk>

"Jesse Heffinger" <jheffinger@ipivot.com> writes:

> I have a string I would like to parse into substrings using the whitespace
> as the delimiter as long as the whitespace is not within double quotes.

Please see the answer to your question in the FAQ "How can I split a
[character] delimited string except when inside [character]?"

> Any suggestions?

I suggest that in future you read the FAQ before you post.

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


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

Date: 15 Aug 2000 08:45:33 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: round
Message-Id: <8navvd$gql$1@lublin.zrz.tu-berlin.de>

Logan Shaw <logan@cs.utexas.edu> wrote in comp.lang.perl.misc:
>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.

In this case, the problem doesn't arise because a number cannot be
represented in binary but because it can.

The rule for rounding (replace by nearest integer[1]) is ambiguous for
numbers exactly in the middle between two integers.  This leads to
the inconsistent results the OP has seen.  This can only happen when
the number in question has an exact representation in binary, other
numbers will have a bias that makes rounding unambiguous.

Anno

[1] Modify accordingly for rounding to a multiple of 10**k


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

Date: 15 Aug 2000 08:00:30 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Substituting newlines for HTML equivalent
Message-Id: <8napqe$ql$1@orpheus.gellyfish.com>

On Mon, 14 Aug 2000 14:44:32 +0200 Marr, Lincoln [HOOF:4713:EXCH] wrote:
> I have a textarea in my web form, and when submitted the form puts the
> info in a pipe-delimited text file, which I later split on pipes and
> newlines. The problem is, if a user hits the 'enter' key in the textarea
> then the file gets a whole bunch of newlines in it, which disrupt the
> script pretty badly.
> I was thinking of using something like:
> 
> $field =~ s/\n/<BR>/g
> 
> But the thing is, I want one newline to be replaced with <BR> but 2
> consecutive newlines to be replaced with <P>. 

Perhaps you might want to do two substitutions with that of two newlines
first , although you should be aware that you might not have two consecutive
newlines as it may be sent as carriage return /linefeed pairs :

  $field =~ s/\r?\n\r?\n/<P>/g;

>                                              Is this possible? Also are
> there any other characters I need to watch out for when letting people
> enter things into a textarea (eg dollar symbols, ampersands etc)?
> 

There is a CERT advisory on this matter (CA2000-02 ?) please read that in
the first place (<http://www.cert.org>) ..  this is not specific to programs
written in Perl though.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Tue, 15 Aug 2000 00:58:00 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: tag parsing. ( OFF TOPIC - IGNORE )
Message-Id: <3998F808.7CEF33A9@stomp.stomp.tokyo>

johnvert@my-deja.com wrote:
 
> Could you please clarify what you mean by ``consistently changing your
> parameters with each response provided''?  I have no idea what you
> mean.  The only mistake I've made in this thread was posting the post
> more than once, which happened accidently.  If I did anything else wrong
> I'd like to know.  But please, before throwing accusations around, at
> least tell me what it is that you mean.

Sure, give me eighteen to twenty-four months to write
you an introduction, a very basic introduction, to human
nature quirks, linguistic analysis, unconscious idioms
in writing and a branch of human behavioral science based
upon basal ego motivation along with an introduction to
our simple notion of multi-personality mind games, of which,
I am a master. After I accomplish this, once you have spent
a decade researching my introduction, we can begin to talk.

Meanwhile, within twenty-four hours you will receive a dozen
or more secretive, albeit hateful emails from zealous regulars
here bent on a fascist ideology of silencing those voices
of people who refuse to toe and heel nor follow dictates of
the Perl Gods of Xah's Perl Perl Land; this Sissyfied Geek
Fantasyland. You will be commanded to killfile me lest you
be tossed for all eternity into a Cyber Land of Hellfire and..
hmm.. that other hot stuff, brimstone I think. That yellow
burning stuff of which road flares are made. Stinks like
an active volcanic cauldera or a sulphur hot spring.

Makes sense, I have a solid reputation for being quite
intellectually dangerous. Prime directive, first order
of business for a fascist regime, is to exterminate all
intellectuals, for all the good this does. Fascism is
not real popular with most folks these days.

There once was a gathering place for intellectuals, a
place called Mt. Fuji. I am the only surviving member
of this group of intellectuals, after a repugnant morally
corrupt fascist set about silencing wise voices. Mt. Fuji
is gone. However, I survive still and, always will.

If you are smart, you will toe and heel along with
killfiling me now. For just over decade, people here
on the net say,

"Don't talk with Kira. She is dangerous."


I will post no further articles on this topic.

Dr. Hannabellina Lector


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

Date: 15 Aug 2000 07:25:12 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: tag parsing.
Message-Id: <8nano8$nq$1@orpheus.gellyfish.com>

On Mon, 14 Aug 2000 15:11:17 GMT johnvert@my-deja.com wrote:
> 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.
> 

I'm not sure that HTML::Tokeparser is ideal for this - It might prove 
easier with HTML::Parser :

#!/usr/bin/perl -w

use strict;
use HTML::Parser;

my $tagged_string = '<blah><T><f>f</f><d c="left"></d></T></blah>';

my $parser = HTML::Parser->new(api_version => 3,
                               start_h => [\&start,"self, tagname"]);

$parser->parse($tagged_string);

sub start
{
  my ($self, $tagname ) = @_;

  if ($tagname eq 't' )
  {
    $self->handler(start => undef);
    $self->handler(end   => \&end, 'self, tagname,text');
    $self->handler(default => sub { print shift } , 'text' );
  }
}

sub end
{
   my ( $self, $tagname,$text ) = @_;
   if ( $tagname eq 't' )
   {
    $self->handler(start => \&start, 'self,tagname');
    $self->handler(default => '' );
    $self->handler(end => undef );
   }
   else
   {
     print $text;
   }
}

This requires some version 3 of HTML::Parser.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 15 Aug 2000 04:14:30 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Updating flat text file problem
Message-Id: <8nb1lm$5nr$1@provolone.cs.utexas.edu>

In article <1h1hps08vdg1sjjd143sh1glh3hjmuofk8@4ax.com>,
musicfan  <musicfan@punitiveart.com> wrote:
>The error I get in the debugger is:
>
>invalid type in pack: '1' at line 22

Your pack/unpack template doesn't match up with your variables, and not
only that, but you've omitted the template from the call to pack().

>This is the code:
>
>$typedef = 'L A12 A16'; 

This means one long (32-bit) integer, one 12-byte space padded string, and
one 16-byte space padded string, in that order.

>($username, $password, $clickthrough) = unpack($typedef, $buffer); 

These are, presumably, a string, another string, and an integer,
so they're in the wrong order.

>$buffer = pack($username, $password, $clickthrough); 

Again, wrong order.  But more importantly, even if you change $typedef
to 'A12 A16 L', you still need to add $typedef to this call:

	$buffer = pack ($typedef, $username, $password, $clickthrough);

By the way, you probably could accomplish the same thing with
significantly less effort by using a hash tied to some sort of DBM
file.

  - Logan


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

Date: Tue, 15 Aug 2000 07:11:13 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: what the heck is C<$_> ??
Message-Id: <slrn8phr86.6kr.tjla@thislove.dyndns.org>

I was shocked! How could John Stanley <stanley@skyking.OCE.ORST.EDU>
say such a terrible thing:
>In article <z7%l5.19517$f_5.91278@news1.rdc1.ct.home.com>,
>Decklin Foster <decklin+usenet@red-bean.com> wrote:
>>John Stanley <stanley@skyking.OCE.ORST.EDU> writes:
>>
>>> It's called "pod". It's "Yet Another Markup Language". People who want
>>> to impress you with their knowledge of perl will use such "markup" in
>>> their postings to this group, just to make reading what they have to say
>>
>>*plonk*
>
>Do YOU have an explanation why someone would use pod in the Subject of a
>USENET article?

Well no *he* won't cause he can't see what you just posted. :)

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Beware of altruism.  It is based on self-deception, the root of all
evil.


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

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


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