[26639] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8747 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 9 00:05:42 2005

Date: Thu, 8 Dec 2005 21:05:07 -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           Thu, 8 Dec 2005     Volume: 10 Number: 8747

Today's topics:
    Re: A simple inheritance question. <abigail@abigail.nl>
        anything wrong with this code for it not to work? <nospam@home.com>
    Re: anything wrong with this code for it not to work? <matthew.garrish@sympatico.ca>
    Re: anything wrong with this code for it not to work? <nospam@home.com>
    Re: perl 5.6.1 and Encode.pm <p_geni...@yahoo.fr>
        Problems with Device::SerialPort (Modem Carrier Detecti <hal@thresholddigital.com>
    Re: Removing duplicates with RegExp <noreply@gunnar.cc>
    Re: Removing duplicates with RegExp (Anno Siegel)
        using of hashes in threadqueues <mslists@256bit.org>
    Re: using of hashes in threadqueues xhoster@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 08 Dec 2005 20:02:35 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: A simple inheritance question.
Message-Id: <slrndph4ar.2k5.abigail@alexandra.abigail.nl>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMCDLXXXII
September MCMXCIII in <URL:news:dn9r8b$h3h$1@mamenchi.zrz.TU-Berlin.DE>:
@@  
@@  Of course, inside-out objects hadn't been invented when Perl OO was
@@  introduced, that took a few years.  Speaking of which, is there a
@@  single inventor?

Yes. I did stand on the shoulder of giants though, and I refined the
model after feedback.

@@                    I know that I have used classes where most of the
@@  info was stored in some lexical $hash{ "$object"}, but I never took
@@  the step of making the central object entirely meaningless.


That looks like 'fly-weight'-like techniques, who have been a source
of inspiration.


Abigail
-- 
A perl rose:  perl -e '@}-`-,-`-%-'


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

Date: Thu, 08 Dec 2005 22:25:39 GMT
From: "Nospam" <nospam@home.com>
Subject: anything wrong with this code for it not to work?
Message-Id: <Dp2mf.25921$7p5.20735@newsfe4-win.ntli.net>

use strict;
use WWW::Mechanize;
use URI::URL;


my $mech = WWW::Mechanize->new( autocheck => 1 );


$mech->agent_alias('Windows IE 6');

my $username1 = 'guesthere52';


my $subject = 'interesting';
  my $message = 'Just testing';

my $url =
'http://www.saiyan.ch/forum/posting.php?mode=reply&t=28&sid=26817f7e3810507e
a91e59a5b3820546';

$mech->get($url);





print $mech->content,"\n";

  my $form = $mech->current_form;
     if( $form->find_input( 'message' ) )
     {


$mech->set_visible($username1, $subject, $message );
$mech->click();

}




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

Date: Thu, 8 Dec 2005 18:32:29 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: anything wrong with this code for it not to work?
Message-Id: <bo3mf.8936$kt5.682593@news20.bellglobal.com>


"Nospam" <nospam@home.com> wrote in message 
news:Dp2mf.25921$7p5.20735@newsfe4-win.ntli.net...
>


Please don't use your subject line as an excuse not to write any text. It's 
also an incredibly terrible question. What doesn't work? The code below 
grabs the page just fine for me. Sure you don't just have firewall issues?


> use strict;
> use WWW::Mechanize;
> use URI::URL;
>
>
> my $mech = WWW::Mechanize->new( autocheck => 1 );
>
>
> $mech->agent_alias('Windows IE 6');
>
> my $username1 = 'guesthere52';
>
>
> my $subject = 'interesting';
>  my $message = 'Just testing';
>
> my $url =
> 'http://www.saiyan.ch/forum/posting.php?mode=reply&t=28&sid=26817f7e3810507e
> a91e59a5b3820546';
>
> $mech->get($url);
>
>
>
>
>
> print $mech->content,"\n";
>
>  my $form = $mech->current_form;
>     if( $form->find_input( 'message' ) )
>     {
>
>
> $mech->set_visible($username1, $subject, $message );
> $mech->click();
>
> }
>
> 




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

Date: Fri, 09 Dec 2005 04:33:16 GMT
From: "Nospam" <nospam@home.com>
Subject: Re: anything wrong with this code for it not to work?
Message-Id: <gO7mf.1825$n95.1041@newsfe4-gui.ntli.net>

sorry for not elaborating, the code is meant to post to the forum, but it
doesn't post, it grabs the page and prints out the html code, but nothing is
posted to the forum



"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:bo3mf.8936$kt5.682593@news20.bellglobal.com...
>
> "Nospam" <nospam@home.com> wrote in message
> news:Dp2mf.25921$7p5.20735@newsfe4-win.ntli.net...
> >
>
>
> Please don't use your subject line as an excuse not to write any text.
It's
> also an incredibly terrible question. What doesn't work? The code below
> grabs the page just fine for me. Sure you don't just have firewall issues?
>
>
> > use strict;
> > use WWW::Mechanize;
> > use URI::URL;
> >
> >
> > my $mech = WWW::Mechanize->new( autocheck => 1 );
> >
> >
> > $mech->agent_alias('Windows IE 6');
> >
> > my $username1 = 'guesthere52';
> >
> >
> > my $subject = 'interesting';
> >  my $message = 'Just testing';
> >
> > my $url =
> >
'http://www.saiyan.ch/forum/posting.php?mode=reply&t=28&sid=26817f7e3810507e
> > a91e59a5b3820546';
> >
> > $mech->get($url);
> >
> >
> >
> >
> >
> > print $mech->content,"\n";
> >
> >  my $form = $mech->current_form;
> >     if( $form->find_input( 'message' ) )
> >     {
> >
> >
> > $mech->set_visible($username1, $subject, $message );
> > $mech->click();
> >
> > }
> >
> >
>
>




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

Date: 08 Dec 2005 21:23:49 GMT
From: "=?UTF-8?B?UGllcnJlIEfDqW5pZXlz?=" <p_geni...@yahoo.fr>
Subject: Re: perl 5.6.1 and Encode.pm
Message-Id: <4398a464$0$78679$892e7fe2@authen.yellow.readfreenews.net>


Sherm Pendley wrote:
 
> 
> But that shouldn't keep you from installing another version as well. It's
> possible, and not too difficult, to keep as many copies of Perl...

Thank you for this help, I installed perl 5.8.7 on a non standard directory
because I dont have root permissions, Encode.pm is a default module 
in this distribution.

Pierre. 

________________________________________________________________
échangez opinions et commentaires dans les forums de discussion.
http://www.usenetgratuit.com/



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

Date: Thu, 08 Dec 2005 23:25:23 -0500
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Problems with Device::SerialPort (Modem Carrier Detection)
Message-Id: <S5adnfRTDNKsmgTeRVn-sw@comcast.com>

I have a program that communicates with a US Robotics external serial modem,
which has worked great until recently.  I've changed some hardware, or,
actually just moved it around, but it is not out of the question that the
boot sequence has changed some settings.

I've used this in a module that communicates with the modem:

my $device = "/dev/ttyS0";
our $spdev = Device::SerialPort->new($device);

And later I have the following routine:

sub checkonline {
        my ($state);
        $state = 0;
        if ($spdev->modemlines & $spdev->MS_RLSD_ON) {
                $state = 1;
        } else {
                $state = 0;
        }
        slog("DEBUG Online check, state: $state");
        return $state;
}

I do not know the internals, but my understanding is that this will tell if
a carrier is detected.  Many programs use this modem and the system it
connects to is hard to reach, so I have a management program that queues up
all the programs that need to use the modem to communicate with the
(difficult to reach) system on the other end.  Once one program finishes
using the modem, the next in the queue runs.  One of the first things it
does is call checkonline() (see above) to see if there is a connection. 
Until this past week, that worked perfectly, but now it rarely detects the
connection.

The entire point of this routine is that, when a new program is running, I
need a way to detect quickly if it is online.  If it is, then I can call
the main menu of the remote system.  If not, then I have to redial. 
Otherwise, I'd have to try to get the menu and examine all the returned
input to see if I am online or getting messages from the modem.

Are there conditions under which the above routine can't be relied on to
detect a carrier?  Are there settings I can specify that will make sure it
works every time?  Is there another way that is 100% reliable to detect if
there is a carrier?  Even detecting if the modem is on or off hook might
help, but ideally I need to know if it is online with another system.

I know some AT commands, but I do not have a very deep understanding of the
actual serial port communication and what I can trust as being true for all
(or most) modems and what is modem specific.

Thanks for any help on this!


Hal


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

Date: Thu, 08 Dec 2005 23:37:51 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Removing duplicates with RegExp
Message-Id: <3vrqu2F172u22U1@individual.net>

Anno Siegel wrote:
> Gunnar Hjalmarsson wrote:
>>Daniel Kaplan wrote:
>>>Was curious, is there a RegExp to remove duplicates?  Am trying to remove 
>>>duplicate spaces (when they are together) and replace them with one space.
>>>
>>>So that:
>>>"This     is    my example of      !"
>>>
>>>Becomes:
>>>"This is my example of !"
>>
>>This is more efficient than invoking the regexp engine:
>>
>>     tr/ //s;
>>
>>but it's not equivalent to s/\s+/ /g; see "perldoc perlop".
> 
> Because it only deals with blanks and not other white space?
> 
>     tr/ \t\n\r\f/ /s;
> 
> (untested) should do that.

Yes, it does. I think I had tested with

     tr/ \t\n\r\f//s;

which does not do the same thing if there are 'groups' of white space 
with different types of white space. (Does that description make sense?)

Thanks!

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 8 Dec 2005 22:56:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Removing duplicates with RegExp
Message-Id: <dnadng$s01$1@mamenchi.zrz.TU-Berlin.DE>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Gunnar Hjalmarsson wrote:
> >>Daniel Kaplan wrote:
> >>>Was curious, is there a RegExp to remove duplicates?  Am trying to remove 
> >>>duplicate spaces (when they are together) and replace them with one space.
> >>>
> >>>So that:
> >>>"This     is    my example of      !"
> >>>
> >>>Becomes:
> >>>"This is my example of !"
> >>
> >>This is more efficient than invoking the regexp engine:
> >>
> >>     tr/ //s;
> >>
> >>but it's not equivalent to s/\s+/ /g; see "perldoc perlop".
> > 
> > Because it only deals with blanks and not other white space?
> > 
> >     tr/ \t\n\r\f/ /s;
> > 
> > (untested) should do that.
> 
> Yes, it does. I think I had tested with
> 
>      tr/ \t\n\r\f//s;
> 
> which does not do the same thing if there are 'groups' of white space 
> with different types of white space. (Does that description make sense?)

Yes, it does no translation, so it squeezes only sequences of identical
characters.  When no replacement list is given to tr///, it uses the
search list, meaning no translation.  When a replacement is specified,
but is shorter than the search list, it repeats the last replacement
character as often as necessary.  But the "squeezing" operation refers
to translated characters, not the originals. So

    tr/...//s;

only squeezes sequences of identical characters, while

    tr/.../ /s;

first translates the entire search list to " " and squeezes that.

Next to split(), tr/// is one of the operators with more various
behavior than immediately obvious.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: 8 Dec 2005 22:52:12 GMT
From: Marc Schoechlin <mslists@256bit.org>
Subject: using of hashes in threadqueues
Message-Id: <slrndphe8s.psv.mslists@256bit.org>

Hi !

I would like to transfer hashes over a threadqueue, but It seems that
this is not possible.

Any hints ?

Any workarounds ?

Look at my testcase:
---
#!/usr/bin/env perl

use warnings;
use strict;
use threads;
use Thread::Queue;
use Data::Dumper;

my $q = new Thread::Queue;

sub ttest(){
  while (1){
  my %h;
  # compute something
  $h{tid} = threads->self->tid();$h{time} = time();
  print "DEBUG-IN:".Dumper(\%h)."\n";
  # enqueue the result
  $q->enqueue(\%h);
  sleep 1;
  }
}

# start two threads
threads->create("ttest");
threads->create("ttest");

# do something with the results of ttest()
while (1){
  my %f = $q->dequeue();
  print "DEBUG-OUT:".Dumper(\%f)."\n";
  print "DEBUG-OUT: time: ".$f{time}." tid:".$f{tid}."\n";
}

---

-- 
I prefer non-proprietary document-exchange.
http://sector7g.wurzel6.de/pdfcreator/
http://www.prooo-box.org/


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

Date: 08 Dec 2005 23:35:38 GMT
From: xhoster@gmail.com
Subject: Re: using of hashes in threadqueues
Message-Id: <20051208183538.398$9z@newsreader.com>

Marc Schoechlin <mslists@256bit.org> wrote:
> Hi !
>
> I would like to transfer hashes over a threadqueue, but It seems that
> this is not possible.
>
> Any hints ?

Yeah.  Shared variables cannot hold references to unshared variables.

>
> Any workarounds ?

Share the hash before you try to shove it into the queue.

>
> Look at my testcase:
> ---
> #!/usr/bin/env perl
>
> use warnings;
> use strict;
> use threads;
> use Thread::Queue;
> use Data::Dumper;
>
> my $q = new Thread::Queue;
>
> sub ttest(){
>   while (1){
>   my %h;

    my %h : shared;

>   # compute something
>   $h{tid} = threads->self->tid();$h{time} = time();
>   print "DEBUG-IN:".Dumper(\%h)."\n";
>   # enqueue the result
>   $q->enqueue(\%h);
>   sleep 1;
>   }
> }
>
> # start two threads
> threads->create("ttest");
> threads->create("ttest");
>
> # do something with the results of ttest()
> while (1){
>   my %f = $q->dequeue();

This is unrelated to the question you asked, but that should be:

    my %f = %{$q->dequeue()};

(Or probably better, use my $f = $q->dequeue() and the derefence when
needed upon use.)

>   print "DEBUG-OUT:".Dumper(\%f)."\n";
>   print "DEBUG-OUT: time: ".$f{time}." tid:".$f{tid}."\n";
> }



Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

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


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