[25169] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7418 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 18 11:05:49 2004

Date: Thu, 18 Nov 2004 08: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, 18 Nov 2004     Volume: 10 Number: 7418

Today's topics:
    Re: Adding a unique user name in a file <jurgenex@hotmail.com>
    Re: Adding a unique user name in a file <jurgenex@hotmail.com>
    Re: CPAN shell as plain user <richard@zync.co.uk>
    Re: die and write to log file <bigj@kamelfreund.de>
    Re: die and write to log file <karel@e-tunity.com>
    Re: die and write to log file <tadmc@augustmail.com>
    Re: die and write to log file <and11@rol.ru>
        how to get data from POST? <sam.wun@authtec.net>
    Re: how to get data from POST? <sholden@flexal.cs.usyd.edu.au>
    Re: how to get data from POST? <bigj@kamelfreund.de>
    Re: how to get data from POST? (David Efflandt)
    Re: newbie-ish question <mritty@gmail.com>
    Re: newbie-ish question <do-not-use@invalid.net>
    Re: newbie-ish question <tadmc@augustmail.com>
    Re: newbie-ish question (Anno Siegel)
        Opening a listen socket on Windows 2000 (T. Jansma)
    Re: Outputs stop ignoring SIGINT with Event.pm (Brad)
        Perls use of Unicode <infor@wienerlibrary.co.uk>
    Re: Perls use of Unicode <flavell@ph.gla.ac.uk>
    Re: Perls use of Unicode <dog@dog.dog>
    Re: Please help on script failures (dan baker)
    Re: the antichomp <mritty@gmail.com>
    Re: the antichomp <responder_solo_en_el_grupo@yahoo.es>
    Re: the antichomp <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Nov 2004 12:13:20 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: Adding a unique user name in a file
Message-Id: <Al0nd.6998$m36.3282@trnddc02>

Josef Moellers wrote:
> Jrgen Exner wrote:
>> sam wrote:
>>
>>> Is there any perl module I can use to read in a list of user names
>>> from a file and do a binary search on the list base on the user
>>> name, if the user name is not found, add this user name to the file?
>>
>>
>> You don't need a module for this. It's probably 15-20 lines of code
>> only. Also, why do a binary search? If you read the user names into a 
>> hash
>> then you get an O(1) access instead of a O(log(n)) as with a binary
>> search.
>
> Why the repeated reference to a hash? If I was given a user name to
> look up in a file, I'd step through the file entry-by-entry. If I
> find the user, I'll process his entry, close the file and be done
> with it. If I didn't find him/her, I'll have reached the end of file
> and, given the proper open mode, append a record for the (new) user.
> No hash, no fancy legwork, just plain coding.

True! Sometimes the simplest methods are the best.
Thanks for reminding us that you have to read the file completely anyway. 
Then you can just as well do the search at the same time.

jue 




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

Date: Thu, 18 Nov 2004 12:17:26 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: Adding a unique user name in a file
Message-Id: <qp0nd.6999$m36.6339@trnddc02>

sam wrote:
>>> sam wrote:
>>>
>>>> Is there any perl module I can use to read in a list of user names
>>>> from a file and do a binary search on the list base on the user
>>>> name, if the user name is not found, add this user name to the
>>>> file?
>>
>> [Just check for the name while reading the file]
>>
> Right, this is for small number of users.
> To deal with large number of users, one would need to load all user
> records into memory when the system/server start up, and use hash/tree
> to speed up the search rather than using linear search.

You realize that the second description is a totally different problem then 
the first, do you?

jue 




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

Date: Thu, 18 Nov 2004 12:47:51 +0000
From: Richard Gration <richard@zync.co.uk>
Subject: Re: CPAN shell as plain user
Message-Id: <pan.2004.11.18.12.47.50.821372@zync.co.uk>

On Wed, 17 Nov 2004 22:45:20 +0100, Matija Papec wrote:
> Is it possible that tests are written only to function
> properly with root user in mind? 

It's possible, but very unlikely I think. I have seen modules fail tests
for reasons other than that the module isn't working though, for example
Apache::Test.

Anyway, I did forcing and everything is in
> place now and working. :)

Always worth a try :-)


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

Date: Thu, 18 Nov 2004 12:42:47 +0100
From: Janek Schleicher <bigj@kamelfreund.de>
Subject: Re: die and write to log file
Message-Id: <pan.2004.11.18.11.42.47.226769@kamelfreund.de>

On Thu, 18 Nov 2004 02:08:24 -0800, justme wrote:

> usually when opening a file, we should check whether it can be opened
> open(FILE,"textfile.txt") or die "Cannot open for reading:$!\n";
> 
> how can i also pipe a error message to a log file ? Something like "tee" ?

Have you already looked for the modules provided at cpan, e.g.
http://search.cpan.org/search?query=tee
especially the CPAN module
IO::Tee
looks like it would it solve your problem.


Greetings,
Janek


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

Date: Thu, 18 Nov 2004 15:18:13 +0100
From: Karel Kubat <karel@e-tunity.com>
Subject: Re: die and write to log file
Message-Id: <419caf26$0$29729$e4fe514c@dreader14.news.xs4all.nl>

Hi,

> usually when opening a file, we should check whether it can be opened
> open(FILE,"textfile.txt") or die "Cannot open for reading:$!\n";
> how can i also pipe a error message to a log file ? Something like "tee" ?

(1) Appending to a logfile from your Perl program:
sub handle_error {
    # Try to append to the logfile. If it fails, show a msg on stderr.
    if (open (my $of, ">>logfile")) {
        print $of (@_);
        close ($of);
    } else {
        print STDERR ("ERROR HANDLE: cannot append to logfile: $!\n");
    }
    # Now abort.
    die (@_);
}

# Sample usage:
open (my $input, "input.txt")
    or handle_error ("Cannot read input.txt: $!\n");

(2) Appending from the OS: use die() just as you would, but run your script
as:
        perl myscript.pl 2>logfile
Unix-ish only. I don't think DOS allows for stderr-redirection while stdout
remains un-redirected.

Hope that helps.
-- 
Karel Kubat <karel@e-tunity.com, karel@qbat.org>
Phone: mobile (+31) 6 2956 4861, office (+31) (0)38 46 06 125
PGP fingerprint: D76E 86EC B457 627A 0A87  0B8D DB71 6BCD 1CF2 6CD5

  From the Small Ads File:
  Have several very old dresses from grandmother in beautiful condition.



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

Date: Thu, 18 Nov 2004 07:51:12 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: die and write to log file
Message-Id: <slrncppa6g.447.tadmc@magna.augustmail.com>

justme <eight02645999@yahoo.com> wrote:

> how can i also pipe a error message to a log file ? Something like "tee" ?


   How do I print to more than one file at once?


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


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

Date: Thu, 18 Nov 2004 18:09:55 +0000
From: Andrew Tkachenko <and11@rol.ru>
Subject: Re: die and write to log file
Message-Id: <cnie4i$hqi$1@news.rol.ru>

You may also try to catch __DIE__ signal and replace its handler with your custom one.

{
local $SIG{__DIE__} = sub { open FH, ">>log.txt"; print FH "@_\n"; close FH; print STDERR "@_\n"; }
open FH, "somefile" or die "err: $!"
}


Regards, Andrew

justme wrote on 18 Ноябрь 2004 10:08:

> hi
> 
> usually when opening a file, we should check whether it can be opened
> open(FILE,"textfile.txt") or die "Cannot open for reading:$!\n";
> 
> how can i also pipe a error message to a log file ? Something like "tee" ?
> 
> thanks...

-- 
Andrew


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

Date: Thu, 18 Nov 2004 19:19:26 +0800
From: sam <sam.wun@authtec.net>
Subject: how to get data from POST?
Message-Id: <cni21d$fr0$1@news.hgc.com.hk>

Hi,

Does anyone know how to use perl(CGI) script to retrieve data from POST 
when the user click the Submit button in html form?

Thanks
Sam


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

Date: 18 Nov 2004 11:37:12 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: how to get data from POST?
Message-Id: <slrncpp2b8.pne.sholden@flexal.cs.usyd.edu.au>

On Thu, 18 Nov 2004 19:19:26 +0800, sam <sam.wun@authtec.net> wrote:
> Hi,
>
> Does anyone know how to use perl(CGI) script to retrieve data from POST 
> when the user click the Submit button in html form?

Did none of the resorces listed in the answer to the FAQ: 

	Where can I learn about CGI or Web programmming in Perl?

provide an answer?

How about the documentation for the CGI module?

-- 
Sam Holden


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

Date: Thu, 18 Nov 2004 12:39:09 +0100
From: Janek Schleicher <bigj@kamelfreund.de>
Subject: Re: how to get data from POST?
Message-Id: <pan.2004.11.18.11.39.05.258977@kamelfreund.de>

On Thu, 18 Nov 2004 19:19:26 +0800, sam wrote:

> Does anyone know how to use perl(CGI) script to retrieve data from POST 
> when the user click the Submit button in html form?

Have you already read
perldoc CGI
?


Greetings,
Janek


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

Date: Thu, 18 Nov 2004 13:35:44 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: how to get data from POST?
Message-Id: <slrncpp99g.s6a.efflandt@typhoon.xnet.com>

On Thu, 18 Nov 2004 19:19:26 +0800, sam <sam.wun@authtec.net> wrote:
> Hi,
> 
> Does anyone know how to use perl(CGI) script to retrieve data from POST 
> when the user click the Submit button in html form?

The Perl CGI module can be used to create or process web forms.

perldoc CGI

Or do a web search for:  Perl CGI.pm


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

Date: Thu, 18 Nov 2004 13:31:15 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: newbie-ish question
Message-Id: <Du1nd.12042$wY2.2805@trndny05>

"Jack" <jack@yankeeboysoftware.com> wrote in message
news:bbd64220.0411180253.110ea247@posting.google.com...
> I am confused about how I can detect if the function jack has returned
> an UNDEFined value;

The function jack will NEVER return an undefined value.  It will always
return exactly three values.  And with the code you've shown, those
three values will always be defined values.  I will assume for the
remainder of this post that your actual function returns three values
which may or may not be defined.   (Have you read the Posting Guidelines
for this group?  Please post real code.)

> note that I don't want to catch the return from 'jack' in a single
> variable @array, rather I want it to return the seperate values, as
> indicated.
>
> Is there a way to detect if 'jack' returns undef (or null or
> whatever), without first catching it in an @array variable.

The use of the word 'whatever' indicates a severe lack of understanding,
and unfortunately implies a lack of caring to learn the correct
terminology.  There is no such thing as a 'null' value.  undef is a
scalar value which that means 'not defined'.

Again, the code as written CANNOT return undef.  It can only return a
list of three values.  undef is a single scalar value.

> The code below produces this:
> $ perl test
> defined(@array) is deprecated at test line 14.
>         (Maybe you should just omit the defined()?)
> the return from jack() is 0, 3.14159, Lemmings, all of them!
> $
>
> but if I remove the 'defined' and change jack to return an 'undef', I
> get this:

please don't tell us in English - tell us in Perl.  I don't understand
exactly what code change you've claimed to make.

> ////////////////////////////////////////////////////////////
> use strict;
> use warnings;
>
> sub jack{
>         my $int1 = 0;
>         my $float1 = 3.14159;
>         my $string = "Lemmings, all of them!";
>         ($int1, $float1, $string);
> };
>
> my $num;
> my $flt;
> my $str;
> if( defined(($num, $flt, $str) = jack)){
>         print "the return from jack() is $num, $flt, $str \n";
> }
> else{
>         print "return was undef";
> }
> ////////////////////////////////////////////////////////////

Once more, jack CANNOT return undef.  Therefore, you need to clarify
what test you're trying to create here.  Are you testing to see if all
three values are undefined?  Are you testing to see if at least one of
the values is undefined?  At least one is defined?  All are defined?

Your central problem is that the defined function takes only one
argument.  If you want to test each element's defined'ness, you need to
test each one:

if (grep {defined} (($num, $flt, $str) = jack)){
  print "At least one element is defined\n";
} else {
  print "All elements are undefined\n";
}

if (grep {!defined} (($num, $flt, $str) = jack)){
  print "At least one element is undefined\n";
} else {
  print "All elements are defined\n";
}


If I've misunderstood your problem, please re-post with actual code and
a more carefully worded question.

Hope this helps,
Paul Lalli



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

Date: 18 Nov 2004 15:12:11 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: newbie-ish question
Message-Id: <yzd6543b610.fsf@invalid.net>


jack@yankeeboysoftware.com (Jack) writes:
> I am confused about how I can detect if the function jack has returned
> an UNDEFined value;
> 
> note that I don't want to catch the return from 'jack' in a single
> variable @array, rather I want it to return the seperate values, as
> indicated.
> 
> Is there a way to detect if 'jack' returns undef (or null or
> whatever), without first catching it in an @array variable.
> 
> The code below produces this:
> $ perl test
> defined(@array) is deprecated at test line 14.
>         (Maybe you should just omit the defined()?)
> the return from jack() is 0, 3.14159, Lemmings, all of them!
> $
> 
> but if I remove the 'defined' and change jack to return an 'undef', I
> get this:
> $ perl test
> Useless use of private variable in void context at test line 8.
> Useless use of private variable in void context at test line 8.
> Useless use of private variable in void context at test line 8.
> Use of uninitialized value in concatenation (.) or string at test line
> 16.
> Use of uninitialized value in concatenation (.) or string at test line
> 16.
> Use of uninitialized value in concatenation (.) or string at test line
> 16.
> the return from jack() is , ,
> $
> 
> 
> ////////////////////////////////////////////////////////////
> use strict;
> use warnings;
> 
> sub jack{
>         my $int1 = 0;
>         my $float1 = 3.14159;
>         my $string = "Lemmings, all of them!";
>         ($int1, $float1, $string);
> };
> 
> my $num;
> my $flt;
> my $str;
> if( defined(($num, $flt, $str) = jack)){
>         print "the return from jack() is $num, $flt, $str \n";
> }
> else{
>         print "return was undef";
> }
> ////////////////////////////////////////////////////////////


It seems to me you want the function 'jack' to have a success and
a failure case: when successful it returns a list of three elements,
and when failing it returns 'undef'.

'undef' doesn't appear to me to be a very good value to return as
a failure indicator from a function that otherwise returns a list,
since if you call it like this

        my @list = jack();

and it fails, @list will not get the value 'undef' or become !defined;
it will contain one element, which is 'undef'.

It's probably better to return an empty list. Then you can use the
test
        if (@list)
to see whether the call succeeded. "if (defined @list)" will not
do anything useful.

If you call 'jack' like this

        ($v1, $v2, $v3) = jack();

and you are sure that the three values are all something other than
'undef' if the call succeeds, you can test any one of them:

        if (defined $v1)

to see whether the call succeeded.


In a more general case, where the function 'jack' might return a list
of any length, including zero, _or_ fail, I suggest returning a
reference to a list when succeeding, and 'undef' when failing. Maybe
someone has a better recommendation; I'm fairly new to Perl myself.


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

Date: Thu, 18 Nov 2004 08:25:00 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: newbie-ish question
Message-Id: <slrncppc5s.447.tadmc@magna.augustmail.com>

Jack <jack@yankeeboysoftware.com> wrote:

> Subject: newbie-ish question


Please put the subject of your article in the Subject of your article.

Your article is not about newbie-ish questions.

Have you seen the Posting Guidelines that are posted here frequently?


> I am confused about how I can detect if the function jack has returned
> an UNDEFined value;


You use the defined() function to test for undef values (but you
appear to already know that).


> note that I don't want to catch the return from 'jack' in a single
> variable @array, rather I want it to return the seperate values, as
> indicated.


You are calling jack() in list context.

Sometimes it returns a 3-element list and sometimes it returns
a 1-element list (where the value of the 1 element is undef),
both of those are "true" when used in a list assignement, so
they can not be used to distinguish between the two cases.

It _should_ be returning either a 3-element list or 
a 0-element list (the empty list) instead.


> Is there a way to detect if 'jack' returns undef (or null or
> whatever), without first catching it in an @array variable.


> but if I remove the 'defined' and change jack to return an 'undef', I
> get this:


Try changing jack() to return the empty list instead of a 1-element list.

Then you can use the value of the list-assignment to detect a
populated list vs. the empty list:


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

sub jack{
        my $int1 = 0;
        my $float1 = 3.14159;
        my $string = "Lemmings, all of them!";
#        return($int1, $float1, $string);
        return ();
};

if( my($num, $flt, $str) = jack){
        print "the return from jack() is $num, $flt, $str \n";
}
else{
        print "return was the empty list\n";
}
-------------------------


The way you had it, $int1 is undef because that is what was in
the list returned from jack().

$flt and $str are also undef, but for a different reason
(because the RHS of a list assignment was "too short").


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


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

Date: 18 Nov 2004 14:35:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: newbie-ish question
Message-Id: <cnibvg$9j9$2@mamenchi.zrz.TU-Berlin.DE>

Arndt Jonasson  <do-not-use@invalid.net> wrote in comp.lang.perl.misc:
> 
> jack@yankeeboysoftware.com (Jack) writes:
> > I am confused about how I can detect if the function jack has returned
> > an UNDEFined value;
> > 
> > note that I don't want to catch the return from 'jack' in a single
> > variable @array, rather I want it to return the seperate values, as
> > indicated.
> > 
> > Is there a way to detect if 'jack' returns undef (or null or
> > whatever), without first catching it in an @array variable.
> > 
> > The code below produces this:
> > $ perl test
> > defined(@array) is deprecated at test line 14.
> >         (Maybe you should just omit the defined()?)
> > the return from jack() is 0, 3.14159, Lemmings, all of them!
> > $
> > 
> > but if I remove the 'defined' and change jack to return an 'undef', I
> > get this:
> > $ perl test
> > Useless use of private variable in void context at test line 8.
> > Useless use of private variable in void context at test line 8.
> > Useless use of private variable in void context at test line 8.
> > Use of uninitialized value in concatenation (.) or string at test line
> > 16.
> > Use of uninitialized value in concatenation (.) or string at test line
> > 16.
> > Use of uninitialized value in concatenation (.) or string at test line
> > 16.
> > the return from jack() is , ,
> > $
> > 
> > 
> > ////////////////////////////////////////////////////////////
> > use strict;
> > use warnings;
> > 
> > sub jack{
> >         my $int1 = 0;
> >         my $float1 = 3.14159;
> >         my $string = "Lemmings, all of them!";
> >         ($int1, $float1, $string);
> > };
> > 
> > my $num;
> > my $flt;
> > my $str;
> > if( defined(($num, $flt, $str) = jack)){
> >         print "the return from jack() is $num, $flt, $str \n";
> > }
> > else{
> >         print "return was undef";
> > }
> > ////////////////////////////////////////////////////////////
> 
> 
> It seems to me you want the function 'jack' to have a success and
> a failure case: when successful it returns a list of three elements,
> and when failing it returns 'undef'.
> 
> 'undef' doesn't appear to me to be a very good value to return as
> a failure indicator from a function that otherwise returns a list,
> since if you call it like this
> 
>         my @list = jack();
> 
> and it fails, @list will not get the value 'undef' or become !defined;
> it will contain one element, which is 'undef'.
> 
> It's probably better to return an empty list. Then you can use the
> test
>         if (@list)
> to see whether the call succeeded. "if (defined @list)" will not
> do anything useful.
> 
> If you call 'jack' like this
> 
>         ($v1, $v2, $v3) = jack();
> 
> and you are sure that the three values are all something other than
> 'undef' if the call succeeds, you can test any one of them:
> 
>         if (defined $v1)
> 
> to see whether the call succeeded.

There is a better way:

    if ( my ( $v1, $v2, $v3) = jack() ) {
        # regular case, jack() has returned at least one scalar
        # do something with $v1, $v2, $v2
    } else {
        # failure, jack() has returned nothing
    }

> In a more general case, where the function 'jack' might return a list
> of any length, including zero, _or_ fail, I suggest returning a
> reference to a list when succeeding, and 'undef' when failing. Maybe
> someone has a better recommendation; I'm fairly new to Perl myself.

The question with arbitrary lists is whether an empty list is a
possible return value.  If it isn't, the same method can be used.
If it is, returning a reference on success and nothing on failure
is a common way to resolve this.

Anno



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

Date: 18 Nov 2004 07:38:49 -0800
From: naecke@gmx.net (T. Jansma)
Subject: Opening a listen socket on Windows 2000
Message-Id: <a5ca6d6c.0411180738.68feacbb@posting.google.com>

Hi everyone,

I've got a very weird problem. I'm writing a perl script that runs as
a service on windows 2000/xp/2003. It starts a seperate listening
thread to listen for connections and do the processing that's needed.
The multithreading part and running as a service part all work fine on
all platforms.
However, the opening of a listen socket only works on Windows XP. I
can't figure out why though, is the $! also remains empty. On Windows
2000 (server) and Windows 2003 (server) it just says that the
$listenSocket is undefined, $! remains empty. Can anyone see what's
happening in the code below?
I've tries a multitude of options in the IO::Socket::INET->new()
method, but nothing worked sofar. The options that are in there now
are only part of the last attempt :)

(It's the code that comprises the listener thread):

---
sub listenerThread() {
  my $listenSocket;
  my $processSocket;
  my $dataRcvd;
  my $peerIPAddr;
  my $peerHostname;
  my $peerDomainname;
  my @hosts;
  
  print DEBUG "This is the listener waking up!\n";
  
  $listenSocket = IO::Socket::INET -> new( Listen => 5,
                                          MultiHomed => 1,
                                         LocalPort => 6666,
                                         LocalHost => "172.24.2.6",
                                         Proto => "tcp",
                                         Reuse => 1,
                                         Blocking => 0
                                       );
  print DEBUG "Listening socket could not be created. Reason: $!\n" if
( ! $listenSocket );
  
  while ( $listenerControl eq "run" ) { 
    if ( $processSocket = $listenSocket->accept() ) {
      print DEBUG "Processing socket could not be created. Reason:
$!\n" if ( ! $processSocket );
      print DEBUG "Received data\n";
      
      open( TEST, ">>c:\\temp\\test.svc" );
      print TEST "Socket opened.\n"; 
      
      $peerIPAddr = $processSocket->peerhost();
      print TEST "$peerIPAddr\n";
      
      while ( defined( $dataRcvd = <$processSocket> ) ) { 
#->get_line();
        chomp( $dataRcvd );
        print TEST "$dataRcvd\n";
        
        if ( $dataRcvd =~ /Hostname:(.+)/ ) {
          $peerHostname = $1;
          print TEST "Matched hostname: $peerHostname\n";
        }
        
        if ( $dataRcvd =~ /Domainname:(.+)/ ) {
          $peerDomainname = $1;
          print TEST "Matched domainname: $peerDomainname\n";
        }
      }
        
      close( $processSocket );
      print TEST "Socket closed\n";
      
      #open( TEST, ">>c:\\temp\\test.svc" );
      print TEST "$peerIPAddr\t$peerHostname.$peerDomainname\t$peerHostname\n";
      close( TEST );
      
      if ( defined( $peerHostname ) && defined( $peerDomainname ) ) {
        updateHostsFile( $peerIPAddr, $peerHostname, $peerDomainname
);
      }
      
      undef( $peerIPAddr );
      undef( $peerHostname );
      undef( $peerDomainname );
    }
  }
  
  print DEBUG "This is the listener dying!\n";
}
---

Thanks in advance!
Tim.


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

Date: 18 Nov 2004 06:40:16 -0800
From: vanospam@cox.net (Brad)
Subject: Re: Outputs stop ignoring SIGINT with Event.pm
Message-Id: <f8be3ff0.0411180640.19ec0724@posting.google.com>

"Brad" <xxxxxxx@xxx.xxx> wrote in message news:<DhPmd.706$wa1.109@lakeread04>...
> Vital stats:
>     Perl Version:            5.6.1
>     Event.pm version:    0.85
>     OS:                           Solaris 8 (Sparc)
> 
> I have a perl script that runs 24/7.  It uses Event.pm to control various
> processes and commands.  To command it, I telnet into a particular port that
> it listening on.  If during the session I type a ^C the process would
> terminate.  I have attempted to ignore the ^C by two different methods:
> 
>     1.  $SIG{INT} = "IGNORE";
>     2. Event->signal(signal => 'INT', cb => sub{});
> 
> In both cases, output to the telnet process stops, but the perl scripts still
> responds to commands on the port.  If I break the connection and restablish
> all is fine.
> 
> So, what do I have to do to reestablish output?

This is not a perl issue but a telnet issue.  Telnet is the problem.  Thanx.

Brad


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

Date: Thu, 18 Nov 2004 12:29:25 -0000
From: "roddy" <infor@wienerlibrary.co.uk>
Subject: Perls use of Unicode
Message-Id: <1100780483.21238.0@iris.uk.clara.net>

Context: Perl 5.008 running on Win98

I wonder if anyone can help:
I have a script which opens a large text file (iso-latin 1) does some
processing and writes the results to another large text file (which,on
examination looks like a double byte code and has 'FF FE' marker bytes at
the begining of the file - which is the marker for utf-16 (little endian)
unicode encoding).

The conversion is causing problems with international characters (in this
case umlauts) used and I would like the output file to be iso-latin 1.

All I can findout about switching off unicode is the 'no uft8' pragma - I've
tried this but it doesn't seem to make any difference - any pointers would
be much appreciated - thanks.

Rod Digges
Wiener Library, London

info@wienerlibrary.co.uk





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

Date: Thu, 18 Nov 2004 13:14:36 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Perls use of Unicode
Message-Id: <Pine.LNX.4.61.0411181306260.5384@ppepc56.ph.gla.ac.uk>

On Thu, 18 Nov 2004, roddy wrote:

> Context: Perl 5.008 running on Win98
> 
> I wonder if anyone can help: I have a script which opens a large 
> text file (iso-latin 1) does some processing and writes the results 
> to another large text file (which,on examination looks like a double 
> byte code and has 'FF FE' marker bytes at the begining of the file - 
> which is the marker for utf-16 (little endian) unicode encoding).

I think we need a bit more detail than this.  Perl would not, by 
itself, unilaterally decide to write a file in utf-16LE format, but
that -is- the native Unicode format in Windows(NT).   Are you saying 
that you are trying to write to a pre-existing file that happens to be 
in this format, or are you saying that your Perl program creates a
new file and then you find to your surprise that utf-16LE has been
written to it?  If the latter, then I can't help feeling that the 
reason is to be found somewhere in your code.

Have you perhaps got a locale defined in your environment which is 
having the effect of telling Perl to use utf-16LE ?

> The conversion is causing problems with international characters (in 
> this case umlauts) 

If you're writing iso-8859-1 -encoded data into a file that already
contains utf-16LE -encoded data then indeed the result will make 
little sense.  But I still don't have a clear picture of why you're 
doing that.

> All I can findout about switching off unicode is the 'no uft8' 
> pragma

Have you read (at least) perldoc perluniintro (if not also 
perlunicode) ?

> - I've tried this but it doesn't seem to make any difference - any 
> pointers would be much appreciated - thanks.

I'm sure someone here will have the answer (even if it doesn't turn 
out to be me), but I'd rather understand the question better before 
suggesting what the answer might be.

Can you show us a bare-bones stripped-down but complete script which
demonstrates the behaviour?
 


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

Date: Thu, 18 Nov 2004 14:31:08 +0100
From: "Peter Michael" <dog@dog.dog>
Subject: Re: Perls use of Unicode
Message-Id: <cni878$29r$1@tgx093.str.allianz.de>

    Roddy,

"roddy" <infor@wienerlibrary.co.uk> schrieb im Newsbeitrag
news:1100780483.21238.0@iris.uk.clara.net...
> Context: Perl 5.008 running on Win98

    [snip]

> All I can findout about switching off unicode is the 'no uft8' pragma -
I've
> tried this but it doesn't seem to make any difference -

    This is certainly not what you want since the utf8
    pragma effects the interpretation of your source
    code.

    You should have a look at PerlIO::encoding maybe you are
    looking for something like

        open my $fh, ">:encoding(latin1)", "file" or die $!;

    HTH,

        Peter





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

Date: 18 Nov 2004 07:11:31 -0800
From: botfood@yahoo.com (dan baker)
Subject: Re: Please help on script failures
Message-Id: <13685ef8.0411180711.2aa00220@posting.google.com>

"Paul in San Diego" <me@you.com> wrote in message news:<poLmd.123153$cJ3.74480@fed1read06>...
> I just moved my Corvette Club's website ... I changed the info in the script config
> files to indicate where the site is now loaded, but all the scripts fail.
> -----------------------

the more specific you can be about error messages, the better guesses
people can make. Did you get a server 500 error? If you moved the
files and did not chmod the scripts to rwxr-xr-x that might be your
first problem. Then, you might want to ask the Host admin if there are
any special naming convensions they have set up to limit or control
execution...

d


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

Date: Thu, 18 Nov 2004 13:07:40 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: the antichomp
Message-Id: <w81nd.14671$2V4.14639@trndny06>

"James Willmore" <jwillmore@fastmail.us> wrote in message
news:pan.2004.11.18.04.29.35.485112@fastmail.us...
> On Wed, 17 Nov 2004 07:15:55 -0800, wana wrote:
>
> > Is there a better way to it than this?
> >
> > $_ .= "\n" for @ARGV;
>
> Maybe ...
>
> #append a newline to each element in @ARGV
> $_ = join("\n", @ARGV);
>
> (one liner)
> perl -e '$_ = join("\n", @ARGV);print "$_\n";' 1 2 3
>
> If all you want to do is append a newline to each element of @ARGV,
then
> 'join' is probably the best way to do it ...but, of course, TMTOWTDI
:-)

This doesn't at all do what the OP asked for.  Your join method creates
a string comprised of all of the elements in @ARGV seperated by
newlines.  The OP wanted a way to 'unchomp' the array @ARGV - that is to
modify @ARGV so that each element has a newline on the end.  Your method
creates a single new string and leaves @ARGV unmodified.

Paul Lalli



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

Date: Thu, 18 Nov 2004 14:01:24 +0000 (UTC)
From: Hue-Bond <responder_solo_en_el_grupo@yahoo.es>
Subject: Re: the antichomp
Message-Id: <cni9vk$3ap$1@cernicalo.emeteo.local>

Paul Lalli, Thu20041118@14:07:40(CET):
>
> The OP wanted a way to 'unchomp' the array @ARGV - that is to
> modify @ARGV so that each element has a newline on the end.

Then what about:

@ARGV = map { $_ . "\n" } @ARGV;


-- 
 Hue-Bond


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

Date: Thu, 18 Nov 2004 08:31:53 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: the antichomp
Message-Id: <slrncppcip.4ca.tadmc@magna.augustmail.com>

Hue-Bond <responder_solo_en_el_grupo@yahoo.es> wrote:
> Paul Lalli, Thu20041118@14:07:40(CET):
>>
>> The OP wanted a way to 'unchomp' the array @ARGV - that is to
>> modify @ARGV so that each element has a newline on the end.
> 
> Then what about:
> 
> @ARGV = map { $_ . "\n" } @ARGV;


or

   $_ .= "\n" for @ARGV;


Neither of which is an "unchomp" though, since they do not
take the value of $/ into account, so this is probably better:

   $_ .= $/ for @ARGV;


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


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

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


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