[26967] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8920 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 4 18:05:45 2006

Date: Sat, 4 Feb 2006 15:05:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 4 Feb 2006     Volume: 10 Number: 8920

Today's topics:
    Re: Fast pipe communication (See Website For Email)
        Morse code audio playout? <gan@starling.us>
    Re: Perl device IO on Win <toddrw69@excite.com>
        using a package <nospam@home.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 04 Feb 2006 11:35:16 -0800
From: "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail@moderncppdesign.com>
Subject: Re: Fast pipe communication
Message-Id: <Iu6H2t.1KtG@beaver.cs.washington.edu>

xhoster@gmail.com wrote:
>> I need to reopen perlin.tex
>> for that; the call to open will block until someone wrote to perlin.tex.
> 
> So it blocks at a slightly different place.  Why is that a problem?

You're right that the complexity of operation is the same, but generally 
  it's good to get away with as few system calls as it gets.

>> Is there any chance of avoiding the expensive trip of opening and
>> closing the whole thing over and over again?
> 
> You could move the opening of the perlout handle out of the loop, I see no
> reason it needs to be repeated each time.

I tried, but then TeX becomes unhappy (hangs), and I have exceedingly 
little control over the way TeX manipulates files...

> Anyway, assuming there were a way to hook a new process up to an existing
> but closed pipe on one end, why should that be significantly more efficient
> than re-opening the pipe?  Both operations seem to be of about the same
> complexity. The way to improve efficiency is to make the writing process
> stay on the line rather than hanging up every time.
> 
>> Can I tell perl, "read to
>> the EOF of this pipe, and then rewind and read again, blocking if nobody
>> wrote to it"?
> 
> I know of no way to do it.  It seems like that more a matter for the OS
> than for Perl.

Thanks for your input, Xho. Made me feel better :o). After all, the 
system runs very smooth as is.


Andrei


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

Date: Sat, 04 Feb 2006 13:45:03 -0600
From: "Gan Uesli Starling" <gan@starling.us>
Subject: Morse code audio playout?
Message-Id: <1139082303_1333@sp6iad.superfeed.net>

I want to write an open source script which does similar to
the CGI here...

http://morsecode.scphillips.com/translator.html

He only shares the Java version and not the CGI. So I am
thinking to trump him by writing my own, as best I can, and
giving my own away for free.

Some time back I heard of a morse-to-audio playout script
in Perl which was open source. That would be a good short
cut to start from...or at least to study first.

Anybody know where I can find it?

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Sat, 04 Feb 2006 22:24:47 GMT
From: "Todd W" <toddrw69@excite.com>
Subject: Re: Perl device IO on Win
Message-Id: <PQ9Ff.1187$rL5.954@newssvr27.news.prodigy.net>


"Jack Schmidt" <unnamed.netizen@invalid.com> wrote in message
news:1139019708.755409@hp-sdd.sdd.hp.com...
> I want to talk to a device through an RS232 port on a
> PC running WinXP.  Looks like I can use the POSIX::Termios
> class, but I don't know what the file descriptors are for
> the serial ports.  Anybody?
>
> Also, what about device IO via USB on the same PC?

Check out the misterhouse project or even the misterhouse mailing list.
There are some serious hardware <-> perl geeks there.

Todd W.




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

Date: Sat, 04 Feb 2006 21:37:05 GMT
From: "Nospam" <nospam@home.com>
Subject: using a package
Message-Id: <589Ff.39443$0N1.15447@newsfe5-win.ntli.net>

I am new to perl and trying to get the above google.pm module to search for
languages in spanish from span but I am a little stuck on how to go about
this, can someone give me a sample of how this package module is used?

package VROOM::Search::Google;

use strict;

use VROOM::Search qw(escape_query unescape_sequence);
use Time::HiRes   qw(gettimeofday);

@VROOM::Search::Google::ISA = qw(VROOM::Search);

sub prepare_request
{
    my $self   = shift;
    my $query  = escape_query(shift);
    my $params = shift;
    my $uri    = 'http://www.google.com';

    $params->{baseurl} = $uri unless defined $params->{baseurl};
    $params->{hl}      = 'en' unless defined $params->{hl};

    $self->{baseurl} = $uri = $params->{baseurl};

    $uri .= '/search?q='.$query;

    while (my ($name, $value) = each %$params) {
 next if $name =~ /baseurl/;
 $uri .= '&'.$name.'='.$value;
    }

    $self->{initime} = $self->{endtime} = [gettimeofday];

    $self->{request} = new HTTP::Request(GET => $uri);
}

sub store_results
{
    my $self = shift;
    my $res  = shift;

    $self->{endtime} = [gettimeofday];

    if ($res->code != 200) {
 $self->{request} = undef;
 return undef;
    }

    #
    # Google doesn't return Content-Length,
    # so ($res->headers)->content_length will be zero. We're forced to
    # use Perl function - length.
    #
    $self->{fetch}++;
    $self->{pgsize} += length($res->content);

    #
    # If we reach here, HTTP response is OK. Proceed to parse the html
    # document for search results
    #
    my ($HIT, $ENTRY, $NEXT) = (0, 1, 2);
    my $rank   = $self->count;
    my $hits   = 0;
    my $wish   = $HIT;
    my $result = undef;

    foreach (split(/(<p>|\n|<\/div>)/i, $res->content)) {
        next if /^$/;   # short circuit for blank lines
 last if $wish == $NEXT;

 if ($self->count == $self->maximum) {
     $self->{request} = undef;
     return $hits;
 }

 #print "#################################################\n";
 #print $_, "\n";

 #
 # Ah,found some results. Get approximate results and wish to
        # see the title/url of the first result.
 #
 if ($wish == $HIT && /Results.*?of.*?([0-9,]+).*?\./i) {
     my $count = $1;
     $self->approximate($count);
     $wish = $ENTRY;
 }
 #
 # Extract the url/title and wish to have abstract text
 #
 elsif ($wish == $ENTRY &&
        /^<a href=(.*?)>(.*?)<\/a><br><font.*?>(.*?)$/i) {

     my $url      = $1;
     my $title    = $2;
     my $abstract = $3;

     $url    =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
     $url    =~ s/(^http:\/\/|\/(index.htm|index.html)*$)//g;
     $title  =~ s/<.*?>//g;

     $result = new VROOM::Search::Result;
     $result->url($url);
     $result->title(unescape_sequence($title));
     $result->text(unescape_sequence($abstract));
     $result->rank(++$rank);
     $result->engine('Google');

     $self->add_result($result);
     $self->{pool}->insert($result) if $self->{pool};
     $hits++;
        }
 #
 # Extract the url for the next page
 #
 elsif ($wish == $ENTRY &&
        /<td nowrap><a href=(.*?)>.*?<span.*?>Next<\/span><\/a>/i) {

     $self->{request}->uri($self->{baseurl}.$1);

     $wish = $NEXT;
 }
    }

    #
    # This is important. It signals the search agent not to fetch more
pages.
    #
    $self->{request} = undef if $wish != $NEXT;


    return $hits;

}

1;

__END__





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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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