[18752] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 920 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 17 06:05:56 2001

Date: Thu, 17 May 2001 03:05:12 -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: <990093911-v10-i920@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 17 May 2001     Volume: 10 Number: 920

Today's topics:
        "listen" to a file <peter.sogaard@tjgroup.com>
    Re: $myexp =~ s/\%/[aeiou]/; ???? <gerhard.schwarz@fpg.de>
        -c: misses close FOO, or die "whatever" (cabney)
    Re: -c: misses close FOO, or die "whatever" (Anno Siegel)
        \n Woes <jtjohnston@courrier.usherb.ca>
    Re: \n Woes <thelma@alpha2.csd.uwm.edu>
    Re: \n Woes <wyzelli@yahoo.com>
    Re: \n Woes <skilchen@swissonline.ch>
    Re: \nhelp <jtjohnston@courrier.usherb.ca>
    Re: \npeter <jtjohnston@courrier.usherb.ca>
        An Example Of A Polite FAQ <godzilla@stomp.stomp.tokyo>
        ANNOUNCE: Perl6::Variables 0.01 (Damian Conway)
    Re: aol proxy (Dan Birchall)
    Re: Beginner's Language? <reply-via@my-web-site.com>
    Re: Bits and bytes (Dave Bailey)
        ceil() function- inconsistent results <salo@coastside.net>
    Re: ceil() function- inconsistent results (Tad McClellan)
        device::SerialPortmodem wierd characters received after (Phil)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 17 May 2001 11:12:38 +0200
From: "Peter Søgaard" <peter.sogaard@tjgroup.com>
Subject: "listen" to a file
Message-Id: <9e04lp$t0p$1@news.inet.tele.dk>

Hi,

Is it possible to have perl "listen to" a certain file, and then trigger
some event when this file is updated( i.e. overwritten ).
I can probably use sleep x seconds and then check the file status once in a
while and decide whether the file has been updated since last time i
checked...but is there a more correct way of doing this?...if so, how? :)




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

Date: Thu, 17 May 2001 11:06:51 +0200
From: Gerhard Schwarz <gerhard.schwarz@fpg.de>
Subject: Re: $myexp =~ s/\%/[aeiou]/; ????
Message-Id: <3B0394AB.46A15C57@fpg.de>

Hi,

> > $myexp =~ s/\%/[aeiou]/;
> >
> > I haven't found the meaning of that "%" (even on perldoc.com).
> > Maybe someone could explain it to me?

> I would scrap the example code and go elsewhere.  There are plenty of
> good books and online tutorials to learn from.

I know, but this thing has to do with my job.

> But to answer you'r question if $myexp is a string containing something
> like
> "hi there you just scored 100%"
> then doing $myexp =~ s/%/[aeiou]/;
> would change it into "hi there you just scored 100[aeiou]"
> so you can see, this doesn't do what was probably intended.
> also note that you don't need the '\' infront of the % sign.

It's exactly what I thought of..., but in the context of the
code it make no sense.

> Just one question.  Are you sure you've posted the correct code?

Sorry, hm, here's the complete loop:

$match is a String from 0 to n length, and does only contain
letters.

 ruleset: 
  while (defined $REGEL[$fr]) {
	for $r (@{$REGEL[$fr]}) {
	  next unless $r->[4] | $fc;
	  my $match = $r->[5];
	  $match =~ s/\+/[bcdfghjklmnpqrstvwxyz]/;
<>	  $match =~ s/\%/[aeiou\344\366\374]/;
	  #my $ns = $s.$e;
	  #$ns = substr($ns,0,length($ns)-$r->[1]);
	  #$e  = substr($e, length($e)-$r->[1]);
	  print "\tREGEL: $fr:", (join ':', @{$r}),"\t($s,$match)\n"
		if $debug > 1;
	  if ($s =~ /$match$/) {
		$did_match++;
		print "\tREGEL: $fr:", (join ':', @{$r}),"\t$s => "
		  if $debug;
		$s = (substr($s,0,length($s)-$r->[7])) if $r->[7];
		$s .= $r->[8] if $r->[8];
		print "$s\n" if $debug;
		if ($r->[6]) {
		  $v =~ s/^ge//;
		}
		$fr = $r->[0];
		$fc = $r->[3];
		if ($fr ne '000') {
		  next ruleset;
		} else {
		  #$s = substr($s,0,length($s)-$r->[1]);
		  last;
		}
	  }
	}
	last;
  }

> Paul

I think a Book cannot help here? ;)


Gerhard


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

Date: Thu, 17 May 2001 08:26:35 GMT
From: cabney@vespidae.occultbias.net (cabney)
Subject: -c: misses close FOO, or die "whatever"
Message-Id: <slrn9g72q8.p9t.cabney@vespidae.occultbias.net>

As the subject line states, I have a short piece of code in which

	close V, or die ("er, huh?: $!\n");

is valid syntax for perl -c... I even used both -w and 'use strict'.

I just can't see why perl shouldn't complain about that, and thought
if somebody might hit me with a camel jockey's prod to enlighten me.

Sorry about the munged Reply-To, a post is sufficient... :(

CA (will it be so in Perl v.6?)
-- 
There was a time
A wind that blew so young
For this could be the biggest sky
And I could have the faintest idea


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

Date: 17 May 2001 09:21:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: -c: misses close FOO, or die "whatever"
Message-Id: <9e0571$4h2$1@mamenchi.zrz.TU-Berlin.DE>

According to cabney <cabneySPAM@SPAM.SPAMcyberpass.net>:
> As the subject line states, I have a short piece of code in which
> 
> 	close V, or die ("er, huh?: $!\n");
> 
> is valid syntax for perl -c... I even used both -w and 'use strict'.
> 
> I just can't see why perl shouldn't complain about that, and thought
> if somebody might hit me with a camel jockey's prod to enlighten me.

Arguably the syntax is fine.  You have a comma operator in scalar
context whose right operand doesn't exist.  In list context, the
comma operator without a right operand common fare, as in

    my %h = (
        a => 1,
        b => 2,
    );

The documented behavior is to ignore the extra comma.

While the documentation is silent about this construct in scalar
context, it seems at least reasonable to assume that a trailing
comma will be likewise ignored.  After all, context can change
at runtime.

> Sorry about the munged Reply-To, a post is sufficient... :(

Spam is a nuisance, but a single bit won't explode your computer :)

Anno


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

Date: Thu, 17 May 2001 01:20:37 -0400
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: \n Woes
Message-Id: <3B035FA5.7EA60416@courrier.usherb.ca>

I have tempted this and failed. I wish to join any line that begins with && to
the previous line.

BEFORE:
Here is an example of before.
&&4; here is the second line.

AFTER:
Here is an example of after. &&4; here is the second line.

My code sort of works, but it doesn't restore every line?! Many are chopped
off. Here is the corpus of text I tested it on if anyone wishes to duplicate:
http://callisto.si.usherb.ca/~eslcafe/ccl-corpus.21-26.output.txt

Thanks,
John


#!perl -w
print "Content-type: text/html\n\n";

    $file1 = "ccl-corpus.21-26.output.txt";
    $file2 = "ccl-corpus.21-26.output2.txt";


    if ( ! open(INPUT1,"<$file1") ) {die("Can't open file \"$file1\" :
$!\n");}
    if ( ! open(OUTPUT,">$file2") ) {die("Can't create file \"$file2\" :
$!\n");}

 while (my $line = <INPUT1>)
 {
  my $next = <INPUT1>;
  while ($next =~ /^&&/) #note I'm searching for && to match &&4, &&5, etc.
  {
   chomp $line;
   $line .= " $next";
   $next = <INPUT1>;
  }
   $line = $next;
       print OUTPUT "$line\n";  #AM I DOING THIS RIGHT?
#      print OUTPUT "$next\n";  #AM I DOING THIS RIGHT?
       print "$line<br>\n";
 }
    close INPUT1;
    close OUTPUT;






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

Date: 17 May 2001 05:55:27 GMT
From: Thelma Lubkin <thelma@alpha2.csd.uwm.edu>
Subject: Re: \n Woes
Message-Id: <9dvp4f$rt$1@uwm.edu>

jtjohnston <jtjohnston@courrier.usherb.ca> wrote:
 ...
: BEFORE:
: Here is an example of before.
: &&4; here is the second line.

: AFTER:
: Here is an example of after. &&4; here is the second line.

: My code sort of works, but it doesn't restore every line?! 
                  <snip>
: Thanks,
: John

              <code snipped>

:  while (my $line = <INPUT1>)
:  {
:   my $next = <INPUT1>;


                You need to remove $next's \n:
                  chomp (my $next = <INPUT1>;
                          --thelma





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

Date: Thu, 17 May 2001 16:14:06 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: \n Woes
Message-Id: <MpKM6.37$uB1.4642@vic.nntp.telstra.net>

"jtjohnston" <jtjohnston@courrier.usherb.ca> wrote in message
news:3B035FA5.7EA60416@courrier.usherb.ca...
> I have tempted this and failed. I wish to join any line that begins with
&& to
> the previous line.
>
> BEFORE:
> Here is an example of before.
> &&4; here is the second line.
>
> AFTER:
> Here is an example of after. &&4; here is the second line.
>
> My code sort of works, but it doesn't restore every line?! Many are
chopped
> off. Here is the corpus of text I tested it on if anyone wishes to
duplicate:
> http://callisto.si.usherb.ca/~eslcafe/ccl-corpus.21-26.output.txt
>
> Thanks,
> John

Here's my approach:

open (IN, 'd:/perl/scripts/test/temp.txt') or die "Cant $!";
open (OUT, '>d:/perl/scripts/test/newtemp.txt') or die "Wont $!";
my $last;
my @lines = <IN>; # The file is only 461k
for (@lines){
    chomp;
    if ($last){ #make sure we have 'a' line
        if (m/^&&/){ # If the next line starts with &&
            $last = $last.$_; # join this and the last
            next; # grab the next line
        }
        else

            print OUT "$last\n"; # it didn't start with && so print the last
one
            $last = $_; # grab the next line that doesn't start with &&
        }
    }
    else {
        $last = $_; # store the first line
    }
}


Wyzelli

--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;






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

Date: Thu, 17 May 2001 11:56:30 +0200
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: \n Woes
Message-Id: <9e07b6$cka9$1@ID-13368.news.dfncis.de>

"Wyzelli" <wyzelli@yahoo.com> wrote in
news:MpKM6.37$uB1.4642@vic.nntp.telstra.net...
> "jtjohnston" <jtjohnston@courrier.usherb.ca> wrote in message
> news:3B035FA5.7EA60416@courrier.usherb.ca...
> > I have tempted this and failed. I wish to join any line that
> > begins with && to the previous line.
> >
> > BEFORE:
> > Here is an example of before.
> > &&4; here is the second line.
> >
> > AFTER:
> > Here is an example of after. &&4; here is the second line.
> >
>
> Here's my approach:
>

I like your approach with some modifications:

> open (IN, 'd:/perl/scripts/test/temp.txt') or die "Cant $!";
> open (OUT, '>d:/perl/scripts/test/newtemp.txt') or die "Wont $!";
> my $last;
> my @lines = <IN>; # The file is only 461k

No need to slurp the entire file into @lines

> for (@lines){

  while (<IN>) {

>    chomp;
>    if ($last){ #make sure we have 'a' line

Here you are skipping empty lines which might be a feature. But if you
want to keep empty lines you have to check for defined($last)

>       if (m/^&&/){ # If the next line starts with &&
>          $last = $last.$_; # join this and the last
>          next; # grab the next line
>       }
>       else {
>         print OUT "$last\n"; # it didn't start with && so print the
>         $last = $_; # grab the next line that doesn't start with &&
>      }
>    }
>    else {
>      $last = $_; # store the first line
>    }
> }
>
Here you miss the last line.

if ($last) {
  print OUT "$last\n";
}

Here's a similar approach:

my $buffer = <INPUT1>;
while (defined(my $line = <INPUT1>)) {
  if ($line =~ /^&&/) {
    chomp($buffer);
    $buffer .= " $line";
  }
  else {
    print OUTPUT $buffer;
    $buffer = $line;
  }
}
print OUTPUT $buffer;




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

Date: Thu, 17 May 2001 00:36:13 -0400
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Re: \nhelp
Message-Id: <3B03553D.B88941FE@courrier.usherb.ca>

Sorry, I thought I cancelled the first one???? It is not listed here
anywhere, which means the group only received one?

J




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

Date: Thu, 17 May 2001 00:39:28 -0400
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Re: \npeter
Message-Id: <3B035600.F1F130C6@courrier.usherb.ca>

Likely not small enough. 1.2 megs on a Windows NT server. Aaaagh. It would
choke.
Feel free to post an example that might do it for fun.

John

> If your file can fit in memory as a whole, just slurp it into a single
> scalar using any of the standard idioms, and then do
>   $text =~ s/\n(?=&&4;)//g;



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

Date: Wed, 16 May 2001 22:11:56 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: An Example Of A Polite FAQ
Message-Id: <3B035D9C.5BC348C6@stomp.stomp.tokyo>



Welcome to comp.lang.perl.misc newsgroup!

This newsgroup, commonly called clpm, is a technical newsgroup
intended to be used for discussion of any and all Perl related
issues, whether it be comments or questions. This is an unmoderated
newsgroup and all are invited to drop in and visit, even if just
to say hello!

As a technical newsgroup, clpm is a bit different than most
general topic newsgroups. As you would expect, clpm discussions
are usually very technical in nature and there are some guidelines
for usage of this newsgroup which are somewhat different than
the average. This document provides information to assist you
in both obtaining the best usage of clpm and to help you have fun! 

Before you read any further, if you are relatively new to
newsgroups, maybe could use some general advice on using
newsgroups, this is an excellent resource:

     http://andrew2.andrew.cmu.edu/rfc/rfc1855.html


**********************************************************************

Table Of Contents

 1. Before posting to comp.lang.perl.misc

     1a. Check the Perl Frequently Asked Questions (FAQ)
     1b. Check the other standard Perl docs (*.pod)
     1c. Lurk for a while before posting
     1d. Search a Usenet archive or discussion group
     1e. Check Other Resources

 2. Posting to comp.lang.perl.misc

     2a. Articles should be related to Perl programming
     2b. Carefully choose a Subject Line Topic
     2c. Use an effective followup style
     2d. Speak Perl Programming language when possible
     2c. Do your machine homework first
     2d. Be careful about typographical errors in code
     2e. Provide just the right amount of information
     2f. Avoid posting binaries, HTML, or MIME content 

3.  Social faux pas to avoid

     3a. Asking a Frequently Asked Question
     3b. Asking a question easily answered by a cursory doc search
     3c. Asking for emailed answers
     3d. Getting along with others

**********************************************************************


1. Before posting to comp.lang.perl.misc
________________________________________


 1a. Check the Perl Frequently Asked Questions (FAQ)

   A wonderful resource is avaiable for you. This resource
   is a very comprehensive time tested collection of questions
   most often asked. It is a resource written by long time
   Perl professionals and provides quick easy to understand
   answers to almost all questions you may have! You will
   find answers here quicker than in clpm. Have a look!

    ( several links to mirror sites for Perl FAQ )
    

 1b. Check the other standard Perl docs (*.pod)

   Should you have Perl installed on your home machine or
   have access to a Perl installation on your internet service
   provider, you have an extremely extensive resource data base
   right at your fingertips! Perl contains just about every bit
   of information you could ever want to know about Perl, right
   there behind your keyboard. Read your documentation for your
   Perl installation at home, or ask your server how to access
   these features. It is very simple! This is an extremely valuable
   resource. There are great search features, lots of explanations,
   all waiting there for you Don't overlook this!

   If you experience difficulties in making use of this feature,
   please feel free to visit clpm and ask how to do this! Lots
   of folks will assist you, very quickly.

     (possible examples of using the Perl search feature)


 1c. Lurk for a while before posting

   This is very important and is expected regardless of what newsgroup
   you are visiting. Lurking means to simply monitor a newsgroup for
   a period of time until you become very familiar with local customs.
   Think of a newsgroup as foreign culture. Each newsgroup has its own
   specific customs and rituals. Get to know those customs and rituals
   well before you participate. This will help you to avoid embarrassing
   social situations. Consider yourself to be a foreigner at first!
   Mind your manners lest we toss you in pot and cook you for dinner!


 1d. Search a Usenet archive or discussion group

   There are tens of thousands of Perl programmers. It is very likely
   your question has already been asked and answered many times! See
   if you can find where it has already been answered. If you are making
   a comment rather than asking a question, search the archives first!
   You will discover many interesting coversations about many topics
   related to Perl. Do your homework and make a great impression!

        Some searchable archives are:

        (list archives and discussion group links)


 1e. Check Other Resources

  You may want to check in books or at web sites to see if you can
  find an answer to your question or become more knowledgable about
  a specific Perl related topic for general discussion.

      (short list of Perl sites and Perl book list sites)


2. Posting to comp.lang.perl.misc
_________________________________


 2a. Is there a better place to ask your question?

   Questions should be related to Perl programming as this is the
   intent of the clpm newsgroup.

   It can be challenging to ascertain what is your actual programming
   problem. It might be Perl related or something which appears to be
   Perl related but is not. Make a conscious effort to determine if your
   concern is actually Perl related. There are many technical newsgroup
   covering just about everything concerning computers and programming.
   If you suspect your problem is Perl related, drop in and ask! If you
   have a hunch it is something else, perhaps an operating system problem
   or perhaps a server problem, work at locating a newsgroup related to
   those topics. You will attain faster and better answers in newsgroup
   directly related to your topic. If you are completely unsure, visit
   this newsgroup and ask for assistance. Many will direct you to better
   resources, to better newsgroups.

   Sometimes we need help simply finding a problem. There are many methods
   for narrowing a problem area in a program. Do a little research and you
   will find lots of good advice on pinpointing a problem. Feel free to
   drop in and ask about ways to narrow down a problem. We will help.


 2b.  Carefully choose the contents of your Subject header

   Choosing a good Subject Line Topic is truly an art. Give careful
consideration
   to your topic line. Work at keeping it as short as possible yet describe your
   topic clearly and concisely. There is no need for complete sentences nor even
   perfect grammar. Keep it short, sweet and descriptive. Do avoid using
expressions
   like, "Help! I am a newbie!" or "URGENT! I need help!". This is guarantee
your
   article will never be read and possibly, you may find yourself in trouble!
   As an example, if your program won't open a file to read, use a topic like,

     "File open failure" rather than "It won't work!"

   These are very good resources to assist you in choosing a topic:

      (list of several sites discussing subject line topics)


 2c. Use an effective followup style

   When composing a followup, quote only enough text of a responding
   author to establish context for comments you will add. Always 
   indicate who wrote the quoted material. Never quote an entire
   article. Never quote a signature or signature file. Edit! Edit!
   Edit previous comments down to a bare minimum with still retaining
   just enough to provide correct context.

   Keep everything in the original chronological order just like you
   are having a real time conversation! Attributes to an author come
   first so everyone will know who wrote what. Another person's comment
   comes next followed by your comment. Their comment, your comment.
   Their comment, your comment. Get the picture? Just like talking.

   Here is a good resource on quoting styles and response methods:

     http://www.geocities.com/nnqweb/nquote.html


 2d. Speak Perl Programming language when possible

   Perl is inherently a technical programming language. Try to speak
   in Perl as best you can! This, everyone will understand. Write out
   your problem using Perl code as much as possible. Very often, a little
   code goes a long ways in finding a problem. Add explanations as needed
   but try to keep Perl code and explanations sorted out, separated.

   Avoid this: I have variable with "foo\tbar" in it.

   Use this: I have $var = "foo\tbar".

   You see! Now everyone knows your variable name and can watch
   for problems associated with that variable name.


 2c. Do your machine homework first

   You can ask perl itself to help you find common programming mistakes!
   Perl has numerous built-in functions which will warn you about possible
   mistakes, even tell you what is your mistake! Use these features!

   These are a few examples of how Perl can help you.

   enable warnings (perldoc warnings)
   enable strictures (perldoc strict)
   use diagnostics

   Your Perl resources, such as books, internet sites, your own Perl
   installation can help you learn how to use these helpful functions
   and many more. They are great! They will tell you what is wrong and
   won't even call you dummy! If you need help in this area, drop right
   on into clpm and ask! Lots of good advice can be had for the asking.


 2d. Be careful about typographical errors in code

   Use copy and paste methods or your editor's "import" function rather 
   than attempt to type in your code. It is very easy to make a typical
   typographical error which can make a major difference in your code.
   Be sure your code is the actual code you are using, absolute verbatim.


 2e. Provide just the right amount of information
 
   Narrow your problem area down to as little Perl code as possible,
   code which can still be tested on a machine, this is, at least
   compiles without any errors, especially fatal errors.

   Most clpm regulars will copy your code directly from your article
   and test it. Be sure it works. This is very important.

   There is a very nice aspect of doing these things. Quite often
   you will discover your problem right off by localizing it to
   very a specific section of your program.

   Carefully describe input to your program. Make sure it is very
   clear and concise; set good parameters. Also provide example
   input data for your program. If you need to show file input,
   use the __DATA__ token (perldata.pod) to provide disk drive
   file contents for your Perl program. An alternative is to
   simple include,

      This is my input data: "Insert your data precisely!"

   Display your output verbatim, including the exact text of any 
   warning or error messages you receive.

   Provide a description of what you expect your program to output
   but is not. This is very helpful. Include your expected results.

   If you simply cannot figure out how to code a function, just don't
   know how to do something with code, describe what you intend to
   input and describe what you expect for output. This "stuff" goes
   in and I want this "stuff" to come out! Lots of people can quickly
   show you many different ways to attain your goal.

   Sometimes people post too much code. Avoid posting an entire program.
   Keep it short as possible. Too much code can be very difficult to
   read and understand. KISS. Keep It Simple Silly!

 2f. Avoid posting binaries, HTML, or MIME content 

   Never, never, NEVER post any binaries such as pictures and sound
   files nor html enabled posts or encoded posts. Always post in
   plaintext, old fashion typewriter text. This is a Golden Rule!


3.  Social faux pas to avoid

 3a. Asking a Frequently Asked Question

   People understand you may have missed an applicable FAQ when you
   checked, which is not a big deal. But if a Frequently Asked Question
   is worded similar to your own question, some folks might assume you
   did not look at all. Don't become indignant if pointers to a FAQ are
   provided. This is quite common and is human nature.

 3b. Asking a question easily answered by a cursory resource search

   There will be times people might assume you did not do your homework
   by researching available resources before posting your article. This
   might be a simple misunderstanding or maybe you didn't do your homework!

   Don't be surprised if some become a little cranky and perhaps express
   some harsh words. There are lots of people out there who don't do there
   homework and deserve to be chastised. Be sure to do your homework, be
   sure to word your Subject Topic Line carefully and give good thought
   to how you ask a question so others will know you have done your part.


 3c. Asking for emailed answers

   Emailed answers benefit one person. Posted answers benefit the
   entire community. If folks can take the time to answer your
   question, then you can take the time to go get the answer in the
   same place where you asked the question.

   It is OK to ask for a copy of the answer to be emailed, but many
   will ignore such requests anyway. If you munge your address, you
   should never expect or ask to get email in response.

   Your best bet is simply to never ask for an email response.


 3d. Getting along with others

   This is always a tough topic to address. You are an adult and
   expect to be treated as such. Treat others the same. Getting
   along with others is a simple matter of being polite and
   courtesy, as you are anyhow.

   As you know, there are trouble makers everywhere on the net,
   everywhere in life. Our newsgroup is no exception. There are
   trouble makers around. This is the nature of reality. Please
   work at ignoring these people, please don't allow them to
   anger you and prompt you to respond with harsh words. These
   situations are trying but your best weapon is to ignore a
   person who is causing trouble; deny troublemakers attention.
   Doing this will help you avoid becoming one yourself.



Godzilla!


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

Date: 17 May 2001 07:33:48 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Perl6::Variables 0.01
Message-Id: <9dvuss$j3u$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release

==============================================================================
                 Release of version 0.01 of Perl6::Variables
==============================================================================


NAME
    Perl6::Variables - Perl 6 variable syntax for Perl 5

DESCRIPTION
    The Perl6::Variables module lets you try out the new Perl variable
    access syntax in Perl 5.

AUTHOR
    Damian Conway (damian@conway.org)

COPYRIGHT
    Copyright (c) 2001, Damian Conway. All Rights Reserved. This module is
    free software. It may be used, redistributed and/or modified under the
    terms of the Perl Artistic License (see
    http://www.perl.com/perl/misc/Artistic.html)


==============================================================================

CHANGES IN VERSION 0.01

(No changes have been documented for this version)

==============================================================================

AVAILABILITY

Perl6::Variables has been uploaded to the CPAN
and is also available from:

	http://www.csse.monash.edu.au/~damian/CPAN/Perl6-Variables.tar.gz

==============================================================================


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

Date: 17 May 2001 08:05:25 GMT
From: djb@y77459fe5.scream.org (Dan Birchall)
Subject: Re: aol proxy
Message-Id: <slrn9g71t3.vch.djb@v2000.scream.org>

Patrick Joyce <joycefive@earthlink.net> wrote:
> i have a problem. what is up with aols proxy servers i have 
> written a perl script that needs a uniqe host name. but with 
> aol proxy the hostnames change often, how do i fix this and 
> or why is this

Without knowing the internals of AOL's systems personally, I would
guess that due to their huge userbase, a single proxy doesn't 
suffice, and they need to continually load-balance traffic across
multiple proxies.

You didn't say what your script did that depended on a unique host
name, but I would caution against using hostname as the key, or a
key, to a user session or anything similar.

As much as you might want there to be a one-to-one relationship
between user and hostname, and as much as that might be the case
most of the time on a low-traffic site, the model will break nastily
on a higher-traffic site.  And it's not just AOL.

1. If Joe is a dialup user of example.com, he might connect to your
   site from modem1.dial.example.com, get disconnected by an incoming
   call, timeout, or whatever, redial, and wind up reconnecting to
   modem2.dial.example.com, all within a short period of time (1 to
   2 minutes).  This is another 1 user : multiple hosts relationship,
   similar to what you're encountering with the AOL proxies.

2. If Joe is an employee of example.com, and their corporate network
   is firewalled and uses NAT for addresses in IANA reserved space, 
   he might show up as coming from gateway.example.com, regardless 
   of which computer he used within the company.  And his co-workers 
   would *also* show up as coming from gateway.example.com, potentially
   at the same, or overlapping, times.  This is the inverse of your
   problem, a multiple users : 1 host relationship.

3. Of course, with situations like #1 or AOL, you can also get into
   multiple users : multiple hosts relationships.  Maybe when Joe
   got disconnected in example 1, the whole modem bank power-cycled,
   also knocking off Jim, who had been on modem2.dial.example.com,
   and when Jim redialed, he got modem1.dial.example.com.  Wham, Joe
   and Jim have switched hostnames.
   
So anyway, like I said up yonder, I'd caution against using hostname
as a key for... well, anything.

-Dan

-- 
This address expires.  Take out the hostname if your reply bounces.
You may transmit e-mail ads to this address, for US$50 per message.
This address may not be distributed unless this notice is included.
Visit http://dan.scream.org/pay4spam.html for complete information.


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

Date: Thu, 17 May 2001 10:20:21 +0200
From: "Biep @ http://www.biep.org/" <reply-via@my-web-site.com>
Subject: Re: Beginner's Language?
Message-Id: <9e01ge$aqom$1@ID-63952.news.dfncis.de>

"Lex Spoon" <lex@cc.gatech.edu> wrote in message
news:m3ae4dyyck.fsf@chaos.resnet.gatech.edu...
> If the learner is happy averaging lists of numbers
> and generating sentences and things like that,
> then Scheme is a wonderful place to start,
> but many beginners would be happier playing with graphical objects..

 .. and for them (PLT) Scheme is a wonderful place to start.

--
Biep
Reply via http://www.biep.org






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

Date: 17 May 2001 07:52:29 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: Bits and bytes
Message-Id: <slrn9g6mi6.20f.dave@sydney.daveb.net>

On Wed, 16 May 2001 23:17:25 GMT, James Weisberg <chadbour@wwa.com> wrote:
[...]
>   Here is what I have coded so far:
[...]
>Let me show a couple examples:
>
># -> ./encode.pl 20010315 0 1 10 100 1 00 0 -1
>ird=20010315, size=8, length=11
>bitstr: (001100000011001001111011001010111011001010001000)
>[7] packet: (20010315,0,1,10,100,100,0,-1)
># -> ./encode.pl 20010315 9 1 10 100 1 00 0 -1
>ird=20010315, size=8, length=6
>bitstr: (01000001)
>[7] packet: (20010315,9,-1,-1,-1,-1,-1,-1)
>
>The first argument is the ird, and the second argument is a status flag for
>the entire record. As you can see, if the flag is nonzero, I encode a string
>which keeps the flag intact and I get a packet of -1s back. This instruction
>is the II = 01 instruction from what I described in my previous post.

Well, I can squeeze about a factor of 4.5 out of dbrec_pack and a factor
of about 2.5 out of dbrec_unpack by modifying them so that they operate
two bits at a time (below).  These factors are for the array

my @a = (20010315,0,1,10,100,1,0,0,-1);

For the other array,

my @a = (20010315,9,1,10,100,1,0,0,-1);

I can only get about a 20 to 30% speedup, but packing and unpacking those
records is much faster than packing valid records, it seems.  I don't 
think it can get much faster in Perl.  If unpacking speed is still a 
bottleneck, you'll have to go to XS and C.  


sub dbrec_pack2 {
  my $ird = pack("l", shift);
  my $v   = ''; 

  vec($v,0,8)=2+$#_;                # recsize
  
  if($_[0]) {
    if($_[0] > 16) { print "$_[0] overflow\n"; exit }
    else { vec($v,2,4)=2; vec($v,3,4)=$_[0]-1 }
  } else {
    my $o = 4;
    for ( @_ ) {
      if    ( $_ ==        0 ) { vec($v,$o++,2) = 0 } 
      elsif ( $_ ==       -1 ) { vec($v,$o++,2) = 1 } 
      elsif ( $_ <= 16843024 ) { 
	my ($a,$b,$c,$d)  = ($_,0,0,0);
	if    ( $a <=       16 ) { $b =     1; $c =  4; $d = 0 }
	elsif ( $a <=      272 ) { $b =    17; $c =  8; $d = 1 }
	elsif ( $a <=    65808 ) { $b =   273; $c = 16; $d = 2 }
	elsif ( $a <= 16843024 ) { $b = 65809; $c = 24; $d = 3 }
	$a -= $b;
	vec($v,$o++,2) =  3;
	vec($v,$o++,2) = $d;
	for ( my $i=0; $i<$c; $i+=2 ) {
	  vec($v,$o++,2) = $a >> $i;
	}
      } else { print "$_ overflow\n"; exit }
    }
  }
  return $ird.$v;    # concatenate ird and vector
}


sub dbrec_unpack2 {
  my ($ird,$sz,$v) = (unpack("lC",$_[0]),substr($_[0],5));

  my @l = ( 4,  8,  16,    24 );
  my @s = ( 1, 17, 273, 65809 );
  my @p = ( $ird );
  my $o = 0;
  foreach ( 1..$sz-1 ) {
    my $n = vec($v,$o++,2);
    if    ( $n == 0 ) { push ( @p,  0 ) }
    elsif ( $n == 1 ) { push ( @p, -1 ) }
    elsif ( $n == 2 ) { 
      my $m; map { $m |= vec($v,$o++,2)<<$_ } (0..3);
      push ( @p, $m+1, (-1)x($sz-2) );
      last;
    } elsif ( $n == 3 ) {
      my $k;
      $n = vec($v,$o++,2);
      for ( my $j=0; $j < $l[$n]; $j+=2 ) {
	$k |= vec($v,$o++,2)<<$j;
      }
      push ( @p, $k+$s[$n] );
    }
  }
  return @p;
}

--
Dave Bailey
davidb54@yahoo.com


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

Date: Wed, 16 May 2001 21:44:56 -0700
From: "Michael J. Salo" <salo@coastside.net>
Subject: ceil() function- inconsistent results
Message-Id: <tg6jvbobfvha9b@corp.supernews.com>

Hey all
I'm getting unreliable results from the ceil() function in Perl 5.  Some
specific values are being evaluated incorrectly.  Either I'm not
understanding the function or it's buggy.  Have a look at the following:

ceil(1942) evaluates to 1942 (correct)

ceil(10 * 194.2) evaluates to 1942 (correct)

ceil(100 * 19.42) evaluates to 1943 (incorrect)

ceil(1000 * 1.942) evaluates to 1942 (correct)

Any insights?  Further demonstration is at
http://strangefortune.com/cgi-bin/ceil.cgi

Michael J. Salo





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

Date: Thu, 17 May 2001 00:08:28 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: ceil() function- inconsistent results
Message-Id: <slrn9g6jls.ono.tadmc@tadmc26.august.net>

Michael J. Salo <salo@coastside.net> wrote:

[ snip about POSIX::ceil function ]

>Either I'm not
>understanding the function or it's buggy.  


It is neither of those :-)


>Any insights?

I think running this program will provide some:

--------------------------
#!/usr/bin/perl -w
use strict;

printf "%30.20f\n",  1942;

printf "%30.20f\n",  10 * 194.2;

printf "%30.20f\n",  100 * 19.42;

printf "%30.20f\n",  1000 * 1.942;
--------------------------

output:

     1942.00000000000000000000
     1942.00000000000000000000
     1942.00000000000022737368
     1942.00000000000000000000


Then have a look at the Perl FAQ, part 4:

   "Why am I getting long decimals (eg, 19.9499999999999) instead 
    of the numbers I should be getting (eg, 19.95)?"



-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 17 May 2001 08:39:50 GMT
From: eclipsephil@aol.comnospam (Phil)
Subject: device::SerialPortmodem wierd characters received after reset
Message-Id: <20010517043950.04979.00000139@ng-mh1.aol.com>

I am using mandrake linux a us robotics sportster voice 33.6 fax modem, perl
5.6.0 and device::SerialPort v.0.10

I can initialise my call out and perform the first operation fine.  However
when I or the other end drop the line I seem to have problems with wierd
characters in the buffer.  ie if I do something like this simplified version
(note I'm not worried about parameters just for this question)

do {

  setup modem;
  write_modem;
  waitfor;
  down_line;

} (while $running);

I get characters like below (the =(n) is the ascii number of the char)

NL = (10) e = (101) ÿ = (255)
or 
NUL = (0) " = (34) ÿ = (255)

Interestingly enough I am using 7 bit ascii so I should only be seeing
characters upto ascii 127 as this is the highest number you can transmit in one
7bit byte. This leads me to beleive that the ascii 255 comes from the modem
which I beleive represents the line going down.  However I can trap that but I
keep getting a few sets of several characters before I can get an empty buffer.
 The code I have used to down the line is below.  My question is how can I
reset the modem so when I start up again the buffers are completely clear.  

sub modem_write {

	my $string = shift;

	aborter ("write modem:no string to send") if (! (defined $string) );

	my $len_string = length($string);
	my $sent_bytes;
	
	eval { $sent_bytes=$modem_obj->write($string) };

	if ($@) {
		$dbg->$dbg_method ("write failed with $! "); 
		return;
	} elsif (! (defined $sent_bytes) ) {
		$dbg->$dbg_method("send 0 bytes");
		return;
	} elsif ($sent_bytes != $len_string ) { 
		$dbg->$dbg_method("send $sent_bytes but record is                            
  $len_string");
		return;
	}

	return 1;

} # modem_write

sub downline {

	$dbg->$dbg_method("Downline the phone");

	modem_write("$dle.$eot\r\n");

              modem_write("+++");
	sleep(3);
	modem_write('ATZ\r\n\n');  # note sure about this one
	sleep(3);

	$modem_status = 'Offline';
	eval { $modem_obj->close; };
	undef $modem_obj;

} # end of downline
Live the Journey!
For each destination is but a doorway to another!


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 920
**************************************


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