[28027] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9391 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 27 14:05:50 2006

Date: Tue, 27 Jun 2006 11:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 27 Jun 2006     Volume: 10 Number: 9391

Today's topics:
        Escaping escape characters in variables (in regexs) johnnykimble@gmail.com
    Re: Escaping escape characters in variables (in regexs) <David.Squire@no.spam.from.here.au>
    Re: Escaping escape characters in variables (in regexs) <johnnykimble@gmail.com>
    Re: Escaping escape characters in variables (in regexs) <benmorrow@tiscali.co.uk>
    Re: Escaping escape characters in variables (in regexs) <tadmc@augustmail.com>
    Re: Escaping escape characters in variables (in regexs) <tadmc@augustmail.com>
    Re: Escaping escape characters in variables (in regexs) <tadmc@augustmail.com>
        how to remote a unix server in my cgi script <Deb.Fang@gmail.com>
    Re: how to remote a unix server in my cgi script <harini.gopi@gmail.com>
    Re: how to remote a unix server in my cgi script <David.Squire@no.spam.from.here.au>
    Re: how to remote a unix server in my cgi script <jgibson@mail.arc.nasa.gov>
    Re: languages with full unicode support <tinman31337@gmail.com>
    Re: local variables and global variables <jurgenex@hotmail.com>
    Re: local variables and global variables <tadmc@augustmail.com>
    Re: making exe of a perl script <mwulfff@yahoo.de>
    Re: making exe of a perl script <1usa@llenroc.ude.invalid>
    Re: Need Search::Binary examples <nomail@sorry.com>
    Re: OO Perl help for a dot Net convert? <ced@blv-sam-01.ca.boeing.com>
    Re: Parsing data file, need help with the logic <dh@metrohm.ch>
    Re: Problem with Multi- threaded Server xhoster@gmail.com
    Re: Problem with Multi- threaded Server <tzz@lifelogs.com>
        References as hash keys (Srinivasan's "Advanced Perl Pr <a24061@yahoo.com>
    Re: References as hash keys (Srinivasan's "Advanced Per <jgibson@mail.arc.nasa.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 27 Jun 2006 07:22:32 -0700
From: johnnykimble@gmail.com
Subject: Escaping escape characters in variables (in regexs)
Message-Id: <1151418152.452295.246670@y41g2000cwy.googlegroups.com>

Hi all,

I've got to replace some characters in Base64 encoded data in a text
file but I'm having problems with the s/// operator mainly, I presume,
because of the presence of the '/' character in the input data.

For example, say I have a file containing the following:

<SomeNode>skdsSda3321/2=///==asda==////adasd/213/dw/ASDASd/ad</SomeNode>

I can pull out the Base64 here with:

$text = m/<SomeNode>(.+?)</SomeNode>/;
$base64stuff = $1;

Then I try to perform a substitution with:

$text =~ s/$base64stuff/hello/;

But this doesn't work. Anyone know what I can do to get this to work
properly?

Thanks,
JK



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

Date: Tue, 27 Jun 2006 15:27:07 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Escaping escape characters in variables (in regexs)
Message-Id: <e7rf7r$87n$1@news.ox.ac.uk>

johnnykimble@gmail.com wrote:
> Hi all,
> 
> I've got to replace some characters in Base64 encoded data in a text
> file but I'm having problems with the s/// operator mainly, I presume,
> because of the presence of the '/' character in the input data.
> 
> For example, say I have a file containing the following:
> 
> <SomeNode>skdsSda3321/2=///==asda==////adasd/213/dw/ASDASd/ad</SomeNode>
> 
> I can pull out the Base64 here with:
> 
> $text = m/<SomeNode>(.+?)</SomeNode>/;
> $base64stuff = $1;
> 
> Then I try to perform a substitution with:
> 
> $text =~ s/$base64stuff/hello/;
> 
> But this doesn't work. Anyone know what I can do to get this to work
> properly?

perldoc perlfunc

	- search for quotemeta.

See also \Q and \E in perldoc perlre.


DS


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

Date: 27 Jun 2006 08:09:46 -0700
From: "John Kimble" <johnnykimble@gmail.com>
Subject: Re: Escaping escape characters in variables (in regexs)
Message-Id: <1151420986.663248.296650@b68g2000cwa.googlegroups.com>

Thanks, applying quotemeta to the first part of the substitution
operator worked great.

David Squire wrote:
> johnnykimble@gmail.com wrote:
> > Hi all,
> >
> > I've got to replace some characters in Base64 encoded data in a text
> > file but I'm having problems with the s/// operator mainly, I presume,
> > because of the presence of the '/' character in the input data.
> >
> > For example, say I have a file containing the following:
> >
> > <SomeNode>skdsSda3321/2=///==asda==////adasd/213/dw/ASDASd/ad</SomeNode>
> >
> > I can pull out the Base64 here with:
> >
> > $text = m/<SomeNode>(.+?)</SomeNode>/;
> > $base64stuff = $1;
> >
> > Then I try to perform a substitution with:
> >
> > $text =~ s/$base64stuff/hello/;
> >
> > But this doesn't work. Anyone know what I can do to get this to work
> > properly?
>
> perldoc perlfunc
>
> 	- search for quotemeta.
> 
> See also \Q and \E in perldoc perlre.
> 
> 
> DS



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

Date: Tue, 27 Jun 2006 15:47:02 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Escaping escape characters in variables (in regexs)
Message-Id: <60t7n3-468.ln1@osiris.mauzo.dyndns.org>


Quoth David Squire <David.Squire@no.spam.from.here.au>:
> johnnykimble@gmail.com wrote:
> > I've got to replace some characters in Base64 encoded data in a text
> > file but I'm having problems with the s/// operator mainly, I presume,
> > because of the presence of the '/' character in the input data.

Nope, that's not a problem. The delimiters only delimit: once Perl knows
where the ends of the regex are, they are no longer special.

> > For example, say I have a file containing the following:
> > 
> > <SomeNode>skdsSda3321/2=///==asda==////adasd/213/dw/ASDASd/ad</SomeNode>
> > 
> > I can pull out the Base64 here with:
> > 
> > $text = m/<SomeNode>(.+?)</SomeNode>/;
                              ^
This match ends here..........|, probably not what you wanted. Is this
your real code?

You would be much better off with an XML module like XML::Simple and
MIME::Base64, I suspect.

> > $base64stuff = $1;
> > 
> > Then I try to perform a substitution with:
> > 
> > $text =~ s/$base64stuff/hello/;
> > 
> > But this doesn't work.

'Doesn't work' is about the least helpful thing you could say. What
*does* it do, and how is this different from what you were expecting?

> Anyone know what I can do to get this to work
> > properly?
> 
> perldoc perlfunc
> 
> 	- search for quotemeta.

 ...except none of the characters in Base64 are meta.

Ben

-- 
You poor take courage, you rich take care:
The Earth was made a common treasury for everyone to share
All things in common, all people one.                [benmorrow@tiscali.co.uk]
'We come in peace'---the order came to cut them down.


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

Date: Tue, 27 Jun 2006 09:52:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Escaping escape characters in variables (in regexs)
Message-Id: <slrnea2hh6.rd0.tadmc@magna.augustmail.com>

johnnykimble@gmail.com <johnnykimble@gmail.com> wrote:

> $text = m/<SomeNode>(.+?)</SomeNode>/;


Please don't post code with syntax errors.

(Unless your question is about the syntax errors.)


> $base64stuff = $1;
> 
> Then I try to perform a substitution with:
> 
> $text =~ s/$base64stuff/hello/;
> 
> But this doesn't work. Anyone know what I can do to get this to work
> properly?


You do not not need to match before substituting.

   $text = s#<SomeNode>(.+?)</SomeNode>#<SomeNode>hello</SomeNode>#;


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


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

Date: Tue, 27 Jun 2006 10:03:29 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Escaping escape characters in variables (in regexs)
Message-Id: <slrnea2i61.rd0.tadmc@magna.augustmail.com>

johnnykimble@gmail.com <johnnykimble@gmail.com> wrote:

> I've got to replace some characters in Base64 encoded data in a text
> file but I'm having problems with the s/// operator mainly, I presume,
> because of the presence of the '/' character in the input data.


That can't be it, because slash is never "meta" in data. 

It is only meta in code.


> For example, say I have a file containing the following:
> 
><SomeNode>skdsSda3321/2=///==asda==////adasd/213/dw/ASDASd/ad</SomeNode>
> 
> I can pull out the Base64 here with:
> 
> $text = m/<SomeNode>(.+?)</SomeNode>/;
       ^^^                 ^^^
       ^^^                 ^^^

Is this your real code?

If so, then why aren't you asking about the error messages that
it produces?

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


> $base64stuff = $1;
> 
> Then I try to perform a substitution with:
> 
> $text =~ s/$base64stuff/hello/;
> 
> But this doesn't work. 


Of course not, your program must compile before you can execute it,
and it must execute before you can see if it "works".

Please post a short and complete program *that we can run* that
illustrates your problem.


> Anyone know what I can do to get this to work
> properly?


It already works properly for me.

Here is a short and complete program *that you can run* that
illustrates your lack of problem:


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

my $text = '<SomeNode>skdsSda3321/2=///==asda==////adasd/213/'
         . 'dw/ASDASd/ad</SomeNode>';

if ( $text =~ m#<SomeNode>(.+?)</SomeNode># ) {
   my $base64stuff = $1;
   $text =~ s/$base64stuff/hello/;
}

print "$text\n";
--------------------


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


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

Date: Tue, 27 Jun 2006 10:06:50 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Escaping escape characters in variables (in regexs)
Message-Id: <slrnea2ica.rd0.tadmc@magna.augustmail.com>

David Squire <David.Squire@no.spam.from.here.au> wrote:
> johnnykimble@gmail.com wrote:


>> For example, say I have a file containing the following:
>> 
>> <SomeNode>skdsSda3321/2=///==asda==////adasd/213/dw/ASDASd/ad</SomeNode>


Note that there are not any regex metacharacters in that data.


>> $text = m/<SomeNode>(.+?)</SomeNode>/;
>> $base64stuff = $1;

>> $text =~ s/$base64stuff/hello/;


> perldoc perlfunc
> 
> 	- search for quotemeta.
> 
> See also \Q and \E in perldoc perlre.


Knowing about quotemeta is certainly a good thing, but it has
nothing to do with the OP's problem because slashes are not
meta in regular expressions, and so need no escaping.


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


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

Date: 27 Jun 2006 07:17:42 -0700
From: "debbie523" <Deb.Fang@gmail.com>
Subject: how to remote a unix server in my cgi script
Message-Id: <1151417862.372738.220860@y41g2000cwy.googlegroups.com>

I have a cgi script stay in one unix server A, and in this cgi script I
have to call a program which sits on another unix server B. so there
should have server lines to login B in my cgi script. Is there somebody
help me figure out what's the specific command I should use.

I appreciate your help!



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

Date: 27 Jun 2006 07:34:22 -0700
From: "harini.gopi@gmail.com" <harini.gopi@gmail.com>
Subject: Re: how to remote a unix server in my cgi script
Message-Id: <1151418862.733766.310850@y41g2000cwy.googlegroups.com>

debbie523 wrote:
> I have a cgi script stay in one unix server A, and in this cgi script I
> have to call a program which sits on another unix server B. so there
> should have server lines to login B in my cgi script. Is there somebody
> help me figure out what's the specific command I should use.
>
> I appreciate your help!



hi

I am fairly new to this group , and I had a situation similar to yours.
So I was just curious to see what was the best way to handle
communication between two servers especially if they sit on  2
different operating systems. I finally wrote a socket program that
communicates to the windows server -the arguments from the CGI and then
returns the result again via  a socket (to the linux server) to be
displayed back in the browser. Am not sure if this a good way to do it
but it worked in the end. Would like to hear other responses though!



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

Date: Tue, 27 Jun 2006 15:37:33 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: how to remote a unix server in my cgi script
Message-Id: <e7rfrd$8ej$1@news.ox.ac.uk>

harini.gopi@gmail.com wrote:
> debbie523 wrote:
>> I have a cgi script stay in one unix server A, and in this cgi script I
>> have to call a program which sits on another unix server B. so there
>> should have server lines to login B in my cgi script. Is there somebody
>> help me figure out what's the specific command I should use.
>>
>> I appreciate your help!
> 
> 
> 
> hi
> 
> I am fairly new to this group , and I had a situation similar to yours.
> So I was just curious to see what was the best way to handle
> communication between two servers especially if they sit on  2
> different operating systems. I finally wrote a socket program that
> communicates to the windows server -the arguments from the CGI and then
> returns the result again via  a socket (to the linux server) to be
> displayed back in the browser. Am not sure if this a good way to do it
> but it worked in the end. Would like to hear other responses though!
> 

You could use modules such as LWP::Simple, LWP::UserAgent or 
WWW::Mechanize to call the script on server B and capture the result.


DS


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

Date: Tue, 27 Jun 2006 09:28:11 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: how to remote a unix server in my cgi script
Message-Id: <270620060928117551%jgibson@mail.arc.nasa.gov>

In article <1151417862.372738.220860@y41g2000cwy.googlegroups.com>,
debbie523 <Deb.Fang@gmail.com> wrote:

> I have a cgi script stay in one unix server A, and in this cgi script I
> have to call a program which sits on another unix server B. so there
> should have server lines to login B in my cgi script. Is there somebody
> help me figure out what's the specific command I should use.

What protocol does your CGI program on server A use to run the program
on server B? SSH? RSH? RPC? HTTP/CGI? Is the program on server B
running all the time or does the program on server A have to launch it?
How do you run the program without using Perl?

The answers to these questions will greatly affect the answers.


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

Date: Tue, 27 Jun 2006 18:09:54 +0200
From: Tin Gherdanarra <tinman31337@gmail.com>
Subject: Re: languages with full unicode support
Message-Id: <4gd3iiF1md4lcU1@individual.net>

Oliver Bandel wrote:
> 
> こんいちわ Xah-Lee san ;-)

Uhm, I'd guess that Xah is Chinese. Be careful
with such things in real life; Koreans might
beat you up for this. Stay alive!


> 
> 
> Xah Lee wrote:
> 
>> Languages with Full Unicode Support
>>
>> As far as i know, Java and JavaScript are languages with full, complete
>> unicode support. That is, they allow names to be defined using unicode.
> 
> 
> Can you explain what you mena with the names here?
> 
> 
>> (the JavaScript engine used by FireFox support this)
>>
>> As far as i know, here's few other lang's status:
>>
>> C → No.
> 
> 
> Well, is this (only) a language issue?
> 
> On Plan-9 all things seem to be UTF-8 based,
> and when you use C for programming, I would think
> that C can handle this also.
> 
> But I only have read some papers about Plan-9 and did not developed on 
> it....
> 
> Only a try to have a different view on it.
> 
> If someone knows more, please let us know :)
> 
> 
> Ciao,
>    Oliver


-- 
Lisp kann nicht kratzen, denn Lisp ist fluessig


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

Date: Tue, 27 Jun 2006 14:23:16 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: local variables and global variables
Message-Id: <obbog.15347$Gh.1461@trnddc02>

king wrote:
> How and what should be used to define a local variable and a global
> variable as well.

In Perl variables are defined by assigments. You simply do
    $var = <expr>;

> and if i have used a sub-routine in a script and i want to use that
> sub-routine in another script,
> how can i do that.

You define the subroutine in a module and then import that module in both 
scripts.

jue 




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

Date: Tue, 27 Jun 2006 10:13:35 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: local variables and global variables
Message-Id: <slrnea2iov.rd0.tadmc@magna.augustmail.com>

king <hara.acharya@gmail.com> wrote:

> How and what should be used to define a local variable and a global
> variable as well.


A local() variable *is* a global variable in Perl.

See:

   "Coping with Scoping":

      http://perl.plover.com/FAQs/Namespaces.html


> and if i have used a sub-routine in a script and i want to use that
> sub-routine in another script,
> how can i do that.


By using a "module":

   perldoc -q module

       What modules and extensions are available for Perl?  What is CPAN?
       What does CPAN/src/... mean?

       How do I find which modules are installed on my system?

       How do I create a module?

       How do I install a module from CPAN?

       How do I keep my own module/library directory?


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


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

Date: 27 Jun 2006 06:57:04 -0700
From: "Michael Wulff" <mwulfff@yahoo.de>
Subject: Re: making exe of a perl script
Message-Id: <1151416624.304807.102140@p79g2000cwp.googlegroups.com>

> Can any-body suggest anything so that it will be easy for every-one to
> use without installing anything.

perl2exe: http://www.indigostar.com/perl2exe.htm



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

Date: Tue, 27 Jun 2006 14:17:20 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: making exe of a perl script
Message-Id: <Xns97EF68C34CD8Casu1cornelledu@127.0.0.1>

"Michael Wulff" <mwulfff@yahoo.de> wrote in news:1151416624.304807.102140
@p79g2000cwp.googlegroups.com:

>> Can any-body suggest anything so that it will be easy for every-one to
>> use without installing anything.
> 
> perl2exe: http://www.indigostar.com/perl2exe.htm

PAR is much recommended by others (I have not used it):

http://search.cpan.org/~smueller/PAR-0.941/script/pp

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: Tue, 27 Jun 2006 10:23:06 -0700
From: Arvin Portlock <nomail@sorry.com>
Subject: Re: Need Search::Binary examples
Message-Id: <e7rpjs$15k1$1@agate.berkeley.edu>

Ben Morrow wrote:

> Quoth Arvin Portlock :
>
> >I get confused and I'm too lazy to look up things I
> >don't use enough to remember. Hence my personal idiom
> >if ($var or $var eq '0').
>
> This doesn't cover '', which is also false.

Lightbulb! That explains, I think, the problems I've had with
defined and why I stopped using it. In all my programs where
I've used "if ($var or $var eq '0')" I was not interested in
'' and wanted to skip it. Looks I was doing the right thing
there after all. When I tried to use defined I didn't realize
it was true for ''. I've learned something new.

> >There's another personal
> >idiom I have. I'll often use [\w\W] in regular expressions
> >because I'm too lazy to remember or look up when . matches
> >\n or \r (I think it does if you put a /m at the end
> >but [\w\W] is faster than looking it up to be certain).
>
> No, it's /s. The way I remember it is
>
>     /s affects a *s*ingle metachar (.)
>     /m affects *m*any metachars (^ and $)

Heh, yeah. See, I told you. Your mnemonic is good. I think
I'll really try and dump that [\w\W] idiom I use which I've
always disliked and, as pointed out, is confusing for Those
Who Come After. If someone pointed a gun at my head and made
me guess I would have said that /s was what you do when you
want to pretty up your regular expressions with white Space
and comments. I'm not insane, though--I would have looked it
up first before actually trying to use it.

Arvin



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

Date: Tue, 27 Jun 2006 17:41:27 GMT
From: Charles DeRykus <ced@blv-sam-01.ca.boeing.com>
Subject: Re: OO Perl help for a dot Net convert?
Message-Id: <J1J552.GME@news.boeing.com>

Dave wrote:
> <ben.wilder@gmail.com> wrote in message 
> news:1150794749.421759.108400@h76g2000cwa.googlegroups.com...
>> Hello all,
>>...
>>
> 
> You should have a look at Conway's 'Perl Best Practices' that has some 
> strong advise about how to implement OO Perl. It goes without saying that 
> this advice is not universally accepted in the Perl community but it is 
> worth considering nontheless. [I believe Schwarz's 'Intermediate Perl' has 
> different OO Perl recommendations but I have not read that one].
> 

s/Schwarz/Schwartz/.  I haven't read `Intermediate Perl` yet but I assumed
its OO approach and recommendations wouldn't differ greatly with PBP's. 
Can anyone who's read both contrast them...

-- 
Charles DeRykus







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

Date: Tue, 27 Jun 2006 17:21:01 +0200
From: dh <dh@metrohm.ch>
Subject: Re: Parsing data file, need help with the logic
Message-Id: <44A14CDD.3020004@metrohm.ch>

Hi,
try the following:
while (<>){
     ($hostname)=    /.+:(.*)/ if (/Host Name/);
     ($primdnssuf)=  /.+:(.*)/ if (/Primary Dns Suffix/);
     ($mediastate)=  /.+:(.*)/ if (/Media State/);
     ($physaddress)= /.+:(.*)/ if (/Physical Address/);
     ($ipaddress)=   /.+:(.*)/ if (/IP Address/);
     };

Daniel


guser@packetstorm.org wrote:
> I have a set of files that get generated from a login script that I
> need to integrate into our database.
> 
> The format in each file is like this
> 
> Machine:blah
> User:foo
> Domain:foo.bar
> SN:nnnnnnn
> Asset:nnnnnnnnnnnnn
> OS:blah
> SP:blah
> 
> Windows IP Configuration
> 
>          Host Name . . . . . . . . . . . . : blah
>         Primary Dns Suffix  . . . . . . . : foo.bar
>         Node Type . . . . . . . . . . . . : Hybrid
>         IP Routing Enabled. . . . . . . . : No
>          WINS Proxy Enabled. . . . . . . . : No
>         DNS Suffix Search List. . . . . . : foo.bar
>                                             foo.bar
>                                             foo.bar
> 
> Ethernet adapter Wireless Network Connection:
> 
>         Media State . . . . . . . . . . . : Media disconnected
>         Description . . . . . . . . . . . : blah
> 
> 
> Ethernet adapter Local Area Connection:
> 
>         Connection-specific DNS Suffix  . : blah
>         Description . . . . . . . . . . . : blah Gigabit Integrated
> Controller
>         Physical Address. . . . . . . . . : mac
>         Dhcp Enabled. . . . . . . . . . . : Yes
>         Autoconfiguration Enabled . . . . : Yes
>         IP Address. . . . . . . . . . . . : n.n.n.n
>         Subnet Mask . . . . . . . . . . . : n.n.n.n
>         Default Gateway . . . . . . . . . : n.n.n.n
>         DHCP Server . . . . . . . . . . . : n.n.n.n
>         DNS Servers . . . . . . . . . . . : n.n.n.n
>                                             n.n.n.n
>         Primary WINS Server . . . . . . . : n.n.n.n
>         Secondary WINS Server . . . . . . : n.n.n.n
>                                             n.n.n.n
>         Lease Obtained. . . . . . . . . . : Tuesday, June 27, 2006
> 7:05:51 AM
>         Lease Expires . . . . . . . . . . : Wednesday, June 28, 2006
> 7:05:51 AM
> 
> Ethernet adapter Network Connect Adapter:
> 
> 
>         Description . . . . . . . . . . . : blah Virtual Adapter
>         Physical Address. . . . . . . . . : mac
> 
> 
> 
> Here is the logic I am trying to convert to code:
> 
> while (<FILE>)
>  do until $_ =~ /Windows IP Configuration/
>       get Machine:blah
>             User:foo
>             Domain:foo.bar
>             SN:nnnnnnn
>             Asset:nnnnnnnnnnnnn
>            OS:blah
>            SP:blah
>  }
>  do until $_ =~ /Ethernet adapter/
>       get Host Name . . . . . . . . . . . . : blah
>         Primary Dns Suffix  . . . . . . . : foo.bar
>         Node Type . . . . . . . . . . . . : Hybrid
>         IP Routing Enabled. . . . . . . . : No
>          WINS Proxy Enabled. . . . . . . . : No
>         DNS Suffix Search List. . . . . . : foo.bar
>                                             foo.bar
>                                             foo.bar
> 
>  #at this point i need some help as I have N interface chunks to loop
> through before reaching the end of file.
> 
> 
> any suggestions?
> 
> thanks.
> 


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

Date: 27 Jun 2006 16:17:19 GMT
From: xhoster@gmail.com
Subject: Re: Problem with Multi- threaded Server
Message-Id: <20060627121742.100$rS@newsreader.com>

"janicehwang1325@yahoo.com" <janicehwang1325@yahoo.com> wrote:
> Ya, I miss that part and I amend my program by putting the close with
> SSL_no_shutdown. However, this only help when the client program ends
> the connection and the server program would not hang. It does not
> actually solve the segmentation fault problem.

The SSLeay module seems to be fundamentally unsafe for threads.  I tried a
few things to hack it with CLONED, etc. but haven't been able to.  The mere
existence of a thread is enough to trigger the problem, the thread doesn't
need to do anything with the socket at all.  By changing the "close"
parameters, I could make it segfault either ealier (upon the initial close)
or later (half way through the 2nd accept) but couldn't get rid of it
altogether.


__SERVER__
use threads;
use POSIX ":sys_wait_h";
use IO::Socket::SSL qw(debug4);
use IO::Handle;
use strict;

my ($sock);

unless (@ARGV == 1) { die "usage: perl $0 <Port Number>" };
my ($port) = @ARGV;

if(!($sock = IO::Socket::SSL->new( Listen => 20, LocalPort => $port,
                                   Proto     => 'tcp', ReuseAddr     => 1,
                                   SSL_key_file => 'certs/newkey.pem',
                                   SSL_cert_file => 'certs/newcert.pem',
                                 )) ) {
    warn "unable to create socket: ", &IO::Socket::SSL::errstr, "\n";
    exit(0);

}

warn "SSL socket created: $sock.\n";
while(1){

        while((my $s = $sock->accept())) {
                warn "I accepted $s";
                print "new thread here .. \n";
                my $thread = threads->create(sub {sleep 5});
                $thread->join;
                warn "joined";
                $s->close(SSL_no_shutdown => 1);
        }
}


__CLIENT__
#!/usr/bin/perl

use POSIX ":sys_wait_h";
use IO::Socket::SSL;
use IO::Handle;
use strict;
use warnings;

unless (@ARGV == 1) { die "usage: perl $0 <Port Number>" };
my ($port) = @ARGV;
my $sock = IO::Socket::SSL->new("localhost:$port") or die "$! $@ ",
&IO::Socket::SSL::errstr; use Data::Dumper;
warn "SSL socket created: $sock.\n";
warn Dumper $sock;

print $sock "asldfjalsdjfsadlfj\n";
__END__

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


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

Date: Tue, 27 Jun 2006 13:38:24 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Problem with Multi- threaded Server
Message-Id: <g693bdqa48f.fsf@CN1374059D0130.kendall.corp.akamai.com>

On 26 Jun 2006, janicehwang1325@yahoo.com wrote:

> Ya, I miss that part and I amend my program by putting the close with
> SSL_no_shutdown. However, this only help when the client program ends
> the connection and the server program would not hang. It does not
> actually solve the segmentation fault problem. I did send my problem to
> the maintainers of IO::Socket::SSL. While waiting for their reply, will
> keep debuggin. Thank you very much for your information. I appreciates
> a lot. Anyhow, any progressions on the program will be shared.

One last thing: you could try the `stunnel' program as your SSL
front-end, and run your server behind it.  I don't know if it's
available on Windows, or if something like it is available on Windows,
but it's definitely something you should consider if SSL breaks your
otherwise good threaded server.

Ted


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

Date: Tue, 27 Jun 2006 16:27:46 +0100
From: Adam Funk <a24061@yahoo.com>
Subject: References as hash keys (Srinivasan's "Advanced Perl Programming")?
Message-Id: <icv7n3-34l.ln1@news.ducksburg.com>

Srinivasan's "Advanced Perl Programming" (1997) says

--> Perl requires hash keys to be strings, so when you use a
--> reference as a key, Perl uses the reference's string
--> representation.... But when you later retrieve the key from
--> this hash, it will remain a string and will thus be unusable
--> as a reference. It is possible that a future release of Perl
--> may lift the restriction that hash keys have to be strings,
--> but for the moment, the only recourse ... is to use the
--> Tie::RefHash module.... There are few algorithms that
--> require references to be used as hash keys and fewer still
--> that cannot live with this restriction.

Is this still (5.8.x) the case?  What practical effect does this
limitation have?


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

Date: Tue, 27 Jun 2006 09:43:22 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: References as hash keys (Srinivasan's "Advanced Perl Programming")?
Message-Id: <270620060943222163%jgibson@mail.arc.nasa.gov>

In article <icv7n3-34l.ln1@news.ducksburg.com>, Adam Funk
<a24061@yahoo.com> wrote:

> Srinivasan's "Advanced Perl Programming" (1997) says
> 
> --> Perl requires hash keys to be strings, so when you use a
> --> reference as a key, Perl uses the reference's string
> --> representation.... But when you later retrieve the key from
> --> this hash, it will remain a string and will thus be unusable
> --> as a reference. It is possible that a future release of Perl
> --> may lift the restriction that hash keys have to be strings,
> --> but for the moment, the only recourse ... is to use the
> --> Tie::RefHash module.... There are few algorithms that
> --> require references to be used as hash keys and fewer still
> --> that cannot live with this restriction.
> 
> Is this still (5.8.x) the case?  What practical effect does this
> limitation have?

Yes, it is still true. See 'perldoc -q hash' "How can I use a reference
as a hash key?", which was modified recently and was misleading in
5.8.6 but corrected in 5.8.8. See

<http://perldoc.perl.org/perlfaq4.html#How-can-I-use-a-reference-as-a-ha
sh-key%3f>

The practical effect is that if you do want to use references as hash
keys, you can, but if you need to dereference the references, you can't
store the references only in the hash as keys unless you use the
Tie::RefHash module. Without using that module, you need to store the
references separately from the hash, in an array for example, and
dereference those values and use them as keys to the hash.

Like the documents say, this is rarely necessary. I only contemplated
doing it once in many years of Perl programming, and, although it
worked, I soon found it unnecessary and abandoned it.


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

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


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