[29238] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 482 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 4 14:10:10 2007

Date: Mon, 4 Jun 2007 11:09: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           Mon, 4 Jun 2007     Volume: 11 Number: 482

Today's topics:
        [newbie] XML::Simple install fails? <bill@teraXNOSPAMXquest.com>
    Re: [newbie] XML::Simple install fails? <sisyphus1@nomail.afraid.org>
    Re: [newbie] XML::Simple install fails? <bill@teraXNOSPAMXquest.com>
    Re: [newbie] XML::Simple install fails? <sisyphus1@nomail.afraid.org>
        ANNOUNCE: Text-CSV_XS 0.28 <h.m.brand@xs4all.nl>
        Building DBD::Pg on Windows? <cohagan@aXNOSPAMcm.org>
    Re: Building DBD::Pg on Windows? <sisyphus1@nomail.afraid.org>
    Re: Building DBD::Pg on Windows? <ch.l.ngre@online.de>
    Re: FAQ 8.47 How do I keep my own module/library direct <jgibson@mail.arc.nasa.gov>
    Re: FAQ 8.47 How do I keep my own module/library direct <mritty@gmail.com>
        Help with Perl operators Please! <scrarymary1@hotmail.com>
    Re: Help with Perl operators Please! <sisyphus1@nomail.afraid.org>
    Re: Help with Perl operators Please! <scobloke2@infotop.co.uk>
    Re: Help with Perl operators Please! <glex_no-spam@qwest-spam-no.invalid>
    Re: How to erase Hex value 0D from string? <tomica@vvv.xls>
        How to erase Hex value 13 from string? <tomica@vvv.xls>
    Re: How to erase Hex value 13 from string? <sisyphus1@nomail.afraid.org>
    Re: How to erase Hex value 13 from string? <noreply@gunnar.cc>
    Re: How to erase Hex value 13 from string? <mritty@gmail.com>
        Need suggestions on a good locking module <ignoramus27175@NOSPAM.27175.invalid>
    Re: perl hash - data processing <mritty@gmail.com>
    Re: question about socket and scalar. <jgibson@mail.arc.nasa.gov>
        Returning substring of regex match <taras.di@gmail.com>
    Re: Returning substring of regex match <noreply@gunnar.cc>
    Re: Returning substring of regex match <mritty@gmail.com>
    Re: Spawning other processes but continue script <mritty@gmail.com>
    Re: Spawning other processes but continue script <shmh@bigpond.net.au>
    Re: urgent:reading 2 files into 2 different $ variables <george.titus@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 4 Jun 2007 06:54:26 -0500
From: "Bill Cohagan" <bill@teraXNOSPAMXquest.com>
Subject: [newbie] XML::Simple install fails?
Message-Id: <4663fd75$0$9900$4c368faf@roadrunner.com>

Following is a transcript of my attempt to install XML::Simple on a Windows 
XP box:
>>>>>>>>>>>>

C:\>perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.7601)
ReadLine support enabled

cpan> install XML::Simple
CPAN: Storable loaded ok
LWP not available
CPAN: Net::FTP loaded ok
Fetching with Net::FTP:
  ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
     26 [main] perl 2232 _cygtls::handle_exceptions: Exception: 
STATUS_ACCESS_VIOLATION
   1511 [main] perl 2232 open_stackdumpfile: Dumping stack trace to 
perl.exe.stackdump

C:\>

>>>>>>>>>>>>>>>>>>>>>>>>>
At first I thought maybe the CPAN site was down, but the problem persists so 
I'm guessing it's something on my machine.  I'd appreciate help or pointers 
on how to solve this.

Thanks in advance,
 Bill 




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

Date: Mon, 4 Jun 2007 22:24:59 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: [newbie] XML::Simple install fails?
Message-Id: <46640497$0$30175$afc38c87@news.optusnet.com.au>


"Bill Cohagan" <bill@teraXNOSPAMXquest.com> wrote in message 
news:4663fd75$0$9900$4c368faf@roadrunner.com...

You probably already have XML-Simple-2.16 (the latest version).

To check, run:
perl -MXML::Simple -e "print $XML::Simple::VERSION"

For me (ActiveState build 820) that produces '2.16' - which is the current 
version.

Cheers,
Rob 



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

Date: Mon, 4 Jun 2007 07:53:13 -0500
From: "Bill Cohagan" <bill@teraXNOSPAMXquest.com>
Subject: Re: [newbie] XML::Simple install fails?
Message-Id: <46640b4d$0$9011$4c368faf@roadrunner.com>

Rob
  Thanks for the response; however that appears not to be the case; i.e.,

>>>>>>>>>>>>>>>>
C:\>perl -MXML::Simple -e "print $XML::Simple::VERSION"
Can't locate XML/Simple.pm in @INC (@INC contains: /usr/lib/perl5/5.8/cygwin 
/usr/lib/perl5/5.8 /usr/lib/perl5/site_perl/5.8/cygwin 
/usr/lib/perl5/site_perl/5.8 /usr/lib/perl5
/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 
/usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 
/usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/ve
ndor_perl/5.8 .).
>>>>>>>>>>>>>>>>>
"Sisyphus" <sisyphus1@nomail.afraid.org> wrote in message 
news:46640497$0$30175$afc38c87@news.optusnet.com.au...
>
> "Bill Cohagan" <bill@teraXNOSPAMXquest.com> wrote in message 
> news:4663fd75$0$9900$4c368faf@roadrunner.com...
>
> You probably already have XML-Simple-2.16 (the latest version).
>
> To check, run:
> perl -MXML::Simple -e "print $XML::Simple::VERSION"
>
> For me (ActiveState build 820) that produces '2.16' - which is the current 
> version.
>
> Cheers,
> Rob 




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

Date: Mon, 4 Jun 2007 23:06:44 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: [newbie] XML::Simple install fails?
Message-Id: <46640e60$0$14719$afc38c87@news.optusnet.com.au>


"Bill Cohagan" <bill@teraXNOSPAMXquest.com> wrote in message 
news:46640b4d$0$9011$4c368faf@roadrunner.com...
> Rob
>  Thanks for the response; however that appears not to be the case; i.e.,
>
>>>>>>>>>>>>>>>>>
> C:\>perl -MXML::Simple -e "print $XML::Simple::VERSION"
> Can't locate XML/Simple.pm in @INC (@INC contains: 
> /usr/lib/perl5/5.8/cygwin

Aaah ... sorry. You're earlier post mentioned "Windows" ... but you're using 
Cygwin. (I was thinking *native* windows and,  hence, ActivePerl - *my* 
mistake :-)

Sorry - I don't make any attempt to diagnose problems with CPAN.pm 
installations (as I never use it).

You could perhaps circumvent your problems with CPAN.pm/Cygwin by 
downloading 
http://search.cpan.org/CPAN/authors/id/G/GR/GRANTM/XML-Simple-2.16.tar.gz , 
extracting it to some location, cd'ing to that location and running, in 
succession:

perl Makefile.PL
make test
make install

Cheers,
Rob 



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

Date: Mon, 4 Jun 2007 10:56:50 GMT
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Subject: ANNOUNCE: Text-CSV_XS 0.28
Message-Id: <JJ45Fu.1uvq@zorch.sf-bay.org>

Note the IMPORTANT CHANGE!

  file: $CPAN/authors/id/H/HM/HMBRAND/Text-CSV_XS-0.28.tar.gz
  size: 33289 bytes
   md5: 8c00161d04793deaf383b4331fe09db4

2007-06-03  0.28 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * IMPORTANT CHANGE: new () returns undef if it gets unsupported
          attributes. Until now, new ({ esc_char => "\\" }) was just
          silently ignored. Rejecting it and failing is better than
          continuing with false assumptions.
        * Added allow_loose_quotes  (see doc)
        * Added t/65_allow.t
        * Added allow_loose_escapes (see doc) RT 15076
        * More code cleanup in XS
        * Added allow_whitespace    (see doc)

2007-05-31  0.27 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * checked with perlcritic (still works under 5.00504)
          so 3-arg open cannot be used (except in the docs)
        * 3-arg open in docs too
        * Added a lot to the TODO list
        * Some more info on using escape character (jZed)
        * Mention Text::CSV_PP in README
        * Added t/45_eol.t, eol tests
        * Added a section about embedded newlines in the pod
        * Allow \r as eol ($/) for parsing
        * More docs for eol
        * More eol = \r fixes, tfrayner's test case added to t/45_eol.t


=item allow_whitespace

When this option is set to true, whitespace (TAB's and SPACE's)
surrounding the separation character is removed when parsing. So
lines like:

  1 , "foo" , bar , 3 , zapp

are now correctly parsed, even though it violates the CSV specs.
Note that B<all> whitespace is stripped from start and end of each
field. That would make is more a I<feature> than a way to be able
to parse bad CSV lines, as

 1,   2.0,  3,   ape  , monkey

will now be parsed as

 ("1", "2.0", "3", "ape", "monkey")

even if the original line was perfectly sane CSV.

=item allow_loose_quotes

By default, parsing fields that have C<quote_char> characters inside
an unquoted field, like

 1,foo "bar" baz,42

would result in a parse error. Though it is still bad practice to
allow this format, we cannot help there are some vendors that make
their applications spit out lines styled like this.

=item allow_loose_escapes

By default, parsing fields that have C<escapee_char> characters that
escape characters that do not need to be escaped, like:

 my $csv = Text::CSV_XS->new ({ esc_char => "\\" });
 $csv->parse (qq{1,"my bar\'s",baz,42});

would result in a parse error. Though it is still bad practice to
allow this format, this option enables you to treat all escape character
sequences equal.




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

Date: Mon, 4 Jun 2007 06:47:43 -0500
From: "Bill Cohagan" <cohagan@aXNOSPAMcm.org>
Subject: Building DBD::Pg on Windows?
Message-Id: <4663fbdf$0$4884$4c368faf@roadrunner.com>

Has anyone done this (recently?) The readme.win32 supplied with this 
download seems to not match the actual code trees. In particular running 
nmake as instructed leads to an error involving a relative file path that 
makes it clear that the folder structure doesn't match what the makefile 
expects.

I'd really like to use DBD on Windows XP as without it Perl isn't of much 
use to our project; however I'm stumped out fo the gate trying to build this 
code.  Any help (or pointers to help) would be greatly appreciated.

Regards,
 Bill




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

Date: Mon, 4 Jun 2007 22:02:55 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Building DBD::Pg on Windows?
Message-Id: <4663ff74$0$26030$afc38c87@news.optusnet.com.au>


"Bill Cohagan" <cohagan@aXNOSPAMcm.org> wrote in message 
news:4663fbdf$0$4884$4c368faf@roadrunner.com...
 .
 .
>
> I'd really like to use DBD on Windows XP as without it Perl isn't of much 
> use to our project; however I'm stumped out fo the gate trying to build 
> this code.  Any help (or pointers to help) would be greatly appreciated.
>

If you're using an ActiveState build of perl 5.8, and you run (while 
connected to the internet):

ppm install http://theoryx5.uwinnipeg.ca/ppms/DBD-Pg.ppd

that should give you version 1.45 of DBD::Pg.

Admittedly, that's not the latest version - and if it doesn't solve your 
problem, then post again (with the output you got when you tried to build 
from source).

Cheers,
Rob 



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

Date: Mon, 04 Jun 2007 14:03:46 +0200
From: Ch Lamprecht <ch.l.ngre@online.de>
Subject: Re: Building DBD::Pg on Windows?
Message-Id: <f40v30$8cu$1@online.de>

Bill Cohagan wrote:

> I'd really like to use DBD on Windows XP as without it Perl isn't of much 
> use to our project; however I'm stumped out fo the gate trying to build this 
> code.  Any help (or pointers to help) would be greatly appreciated.
> 

Hi, there are binaries available at:

http://pgfoundry.org/frs/?group_id=1000199&release_id=589

Christoph

-- 
use Tk;use Tk::GraphItems;$c=tkinit->Canvas->pack;push@i,Tk::GraphItems->
TextBox(text=>$_,canvas=>$c,x=>$x+=70,y=>100)for(Just=>another=>Perl=>Hacker);
Tk::GraphItems->Connector(source=>$i[$_],target=>$i[$_+1])for(0..2);
$c->repeat(30,sub{$_->move(0,4*cos($d+=3.16))for(@i)});MainLoop


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

Date: Mon, 04 Jun 2007 10:01:21 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: FAQ 8.47 How do I keep my own module/library directory?
Message-Id: <040620071001218902%jgibson@mail.arc.nasa.gov>

In article <6pqaj4-tn8.ln1@blue.stonehenge.com>, PerlFAQ Server
<brian@stonehenge.com> wrote:

> --------------------------------------------------------------------
> 
> 8.47: How do I keep my own module/library directory?
> 
>     When you build modules, use the PREFIX and LIB options when generating
>     Makefiles:
> 
>             perl Makefile.PL PREFIX=/mydir/perl LIB=/mydir/perl/lib
> 
>     then either set the PERL5LIB environment variable before you run scripts
>     that use the modules/libraries (see perlrun) or say
> 
>             use lib '/mydir/perl/lib';
> 
>     This is almost the same as
> 
>             BEGIN {
>             unshift(@INC, '/mydir/perl/lib');
>             }
> 
>     except that the lib module checks for machine-dependent subdirectories.
>     See Perl's lib for more information.

How about adding something for CPAN shell users? Something like:

     If you use the CPAN module for building and installing modules,
     start the shell and enter the following:

         cpan> o conf makepl_arg PREFIX=/mydir/perl,LIB=/mydir/perl/lib
         cpan> o conf commit

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


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

Date: Mon, 04 Jun 2007 11:07:20 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: FAQ 8.47 How do I keep my own module/library directory?
Message-Id: <1180980440.029640.261120@k79g2000hse.googlegroups.com>

On Jun 4, 1:01 pm, Jim Gibson <jgib...@mail.arc.nasa.gov> wrote:
> In article <6pqaj4-tn8....@blue.stonehenge.com>, PerlFAQ Server
> wrote:

> > 8.47: How do I keep my own module/library directory?

> How about adding something for CPAN shell users? Something like:
>
>  If you use the CPAN module for building and installing
>  modules, start the shell and enter the following:
>
>   cpan> o conf makepl_arg PREFIX=/mydir/perl,LIB=/mydir/perl/lib
>   cpan> o conf commit
>

There should also be something in this FAQ for modules that use
Module::Build's Build.PL rather than ExtUtils::MakeMaker's
Makefile.PL.  IIRC, the flag is --install_base, and the CPAN option
(for relatively recent releases of CPAN.pm) is mbuildpl_arg.

Paul Lalli



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

Date: Mon, 04 Jun 2007 08:40:53 -0600
From: scrarymary <scrarymary1@hotmail.com>
Subject: Help with Perl operators Please!
Message-Id: <oa8863dp0clia7rtdfflqerg073286vfgj@4ax.com>


This is part of a script 
Can someone please tell me what operations are being performed 
on the value t

for (my $N = 0; $N <= $Count; $N++) {
	my $t = $N * $N
	$d += ($t ? $t : 1)  
}

Also

my @ii = unpack("V8", $chunk);

if $chunk is 32 bytes how will the bytes be unpacked into the array
@ii?

Thank you for any help




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

Date: Tue, 5 Jun 2007 01:33:37 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Help with Perl operators Please!
Message-Id: <466430cf$0$19821$afc38c87@news.optusnet.com.au>


"scrarymary" <scrarymary1@hotmail.com> wrote in message 
news:oa8863dp0clia7rtdfflqerg073286vfgj@4ax.com...
>
> This is part of a script
> Can someone please tell me what operations are being performed
> on the value t
>
> for (my $N = 0; $N <= $Count; $N++) {
> my $t = $N * $N

I think that should be:

my $t = $N * $N;

At the first iteration, $t is 0 (0 squared)
At the second iteration, $t is 1 (1 squared)
At the third iteration, $t is 4 (2 squared)
At the fourth iteration, $t is 9 (3 squared)
and so on ....

After $Count + 1 iterations, the loop terminates, and $t has the value 
$count * $Count ($Count squared).

> $d += ($t ? $t : 1)

I think that should be:

$d += ($t ? $t : 1);

That line just assigns $d + $t to $d ... unless $t is zero (or numerically 
equivalent to zero) - in which case it assigns $d + 1 to $d.

> }
>
> Also
>
> my @ii = unpack("V8", $chunk);
>
> if $chunk is 32 bytes how will the bytes be unpacked into the array
> @ii?
>

You can see by running:

print "@ii\n";

(The individual elements of @ii will be separated by a space.)

See 'perldoc perlop'.

Cheers,
Rob 



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

Date: Mon, 04 Jun 2007 16:45:10 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Help with Perl operators Please!
Message-Id: <46643388$0$27844$db0fefd9@news.zen.co.uk>

scrarymary wrote:
> This is part of a script 

Looks a bit like homework.
http://www.catb.org/~esr/faqs/smart-questions.html#homework


> Can someone please tell me what operations are being performed 
> on the value t

There isn't a value t, there is a scalar variable named $t.


> for (my $N = 0; $N <= $Count; $N++) {
> 	my $t = $N * $N

A scalar value is assigned to the variable $t


> 	$d += ($t ? $t : 1)  

This is equivalent to

   if ($t) {
     $d += $t;
   } else {
     $d += 1;
   }

The boolean value of $t is false if it is undefined or zero.

$foo += $bar;
is equivalent to
$foo = $foo + $bar;


> }
> 
> Also
> 
> my @ii = unpack("V8", $chunk);
> 
> if $chunk is 32 bytes how will the bytes be unpacked into the array
> @ii?
> 

Since I don't know, I'd either read the documentation (start at `perldoc 
-f unpack`) or write a short program to find out by assigning a 
carefully chosen value to $chunk and printing @ii.



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

Date: Mon, 04 Jun 2007 10:50:48 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Help with Perl operators Please!
Message-Id: <466434d8$0$497$815e3792@news.qwest.net>

scrarymary wrote:
> This is part of a script 
> Can someone please tell me what operations are being performed 
> on the value t

That's a trick question.  The answer is None.. it's a syntax error.

If it was correct.. You can answer the questions yourself by adding
a few print statements.
> 
> for (my $N = 0; $N <= $Count; $N++) {
> 	my $t = $N * $N

print "t is set to $N * $N which is: $t\n";

print "before d = $d\n";

> 	$d += ($t ? $t : 1)  

print "after d = $d\n";

> }
> 
> Also
> 
> my @ii = unpack("V8", $chunk);
> 
> if $chunk is 32 bytes how will the bytes be unpacked into the array
> @ii?

Instead of asking what will happen, why not try it and see for yourself?


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

Date: Mon, 4 Jun 2007 16:53:16 +0200
From: "Taomica" <tomica@vvv.xls>
Subject: Re: How to erase Hex value 0D from string?
Message-Id: <f41910$ndq$1@ss408.t-com.hr>

Hex value is 0D, decimnal value is 13

> How to erase Hex value 13 from string?
> 
> Perl line :                    $b =~ tr/\013//;
> dont work?!
> 
> Thanks


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

Date: Mon, 4 Jun 2007 16:51:52 +0200
From: "Taomica" <tomica@vvv.xls>
Subject: How to erase Hex value 13 from string?
Message-Id: <f418ua$na1$1@ss408.t-com.hr>

How to erase Hex value 13 from string?

Perl line :                    $b =~ tr/\013//;
dont work?!

Thanks


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

Date: Tue, 5 Jun 2007 01:40:37 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: How to erase Hex value 13 from string?
Message-Id: <46643272$0$13763$afc38c87@news.optusnet.com.au>


"Taomica" <tomica@vvv.xls> wrote in message 
news:f418ua$na1$1@ss408.t-com.hr...
> How to erase Hex value 13 from string?
>
> Perl line :                    $b =~ tr/\013//;
> dont work?!

Untested:

$b =~ s/chr(0x013)//;

Cheers,
Rob 



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

Date: Mon, 04 Jun 2007 17:53:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to erase Hex value 13 from string?
Message-Id: <5cir07F302lcoU1@mid.individual.net>

Taomica wrote:
> How to erase Hex value 13 from string?
> 
> Perl line :                    $b =~ tr/\013//;
> dont work?!

You missed the /d modifier.

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


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

Date: Mon, 04 Jun 2007 10:54:30 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: How to erase Hex value 13 from string?
Message-Id: <1180979670.729542.102720@q66g2000hsg.googlegroups.com>

On Jun 4, 11:40 am, "Sisyphus" <sisyph...@nomail.afraid.org> wrote:

> Untested:
>
> $b =~ s/chr(0x013)//;

Function calls do not interpolate.

Paul Lalli



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

Date: Mon, 04 Jun 2007 08:33:42 -0500
From: Ignoramus27175 <ignoramus27175@NOSPAM.27175.invalid>
Subject: Need suggestions on a good locking module
Message-Id: <MP6dndxNyasrifnbnZ2dnUVZ_v-tnZ2d@giganews.com>

I have a script that I want to run, but only one instance. So I want
to set up crontab to start it every minute, but if it is already
running, I would exit. 

I looked at LockFile::Simple but I do not like it. I want to find a
module that opens a file with O_EXCL and uses that for locking. (local
hard drive filesystem only)

I know that I could just use sysopen, but I am hoping that perhaps a
well debugged module would clean some gotchas that I did not think
about. 

thanks

i


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

Date: Mon, 04 Jun 2007 04:07:47 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: perl hash - data processing
Message-Id: <1180955267.778766.212650@p47g2000hsd.googlegroups.com>

On Jun 3, 8:52 am, "Dr.Ruud" <rvtol+n...@isolution.nl> wrote:
> Please be more efficient on the quoting next time.

Are you seriously that bored?  In this case, the entire OP's message
was relevant.  Situation, existing code, data, and desired effect.  I
quoted what was necessary.

Paul Lalli



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

Date: Mon, 04 Jun 2007 09:27:24 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: question about socket and scalar.
Message-Id: <040620070927246688%jgibson@mail.arc.nasa.gov>

In article <pan.2007.06.02.21.27.10.539855@libero.it>, _mario.lat
<none@libero.it> wrote:

> Hammol,
> I see an example about IPv6...
> I'm a newby and I like to ask you someting about code:
> 
> -What can I put in the code(see following code) for writing what the
> server says?
> -What "scalar(@res)" do?
> 
> Thank you in advance,
> Mario.
>    
> 
>     use Socket;
>     use Socket6;
> 
>     @res = getaddrinfo('hishost.com', 'daytime', AF_UNSPEC, SOCK_STREAM);
>     $family = -1;
>     while (scalar(@res) >= 5) {
>         ($family, $socktype, $proto, $saddr, $canonname, @res) = @res;
> 
>         ($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
>         print STDERR "Trying to connect to $host port port $port...\n";
> 
>         socket(Socket_Handle, $family, $socktype, $proto) || next;
>         connect(Socket_Handle, $saddr) && last;
> 
> -----> WHAT CAN I PUT HERE TO PRINT WHAT SERVER SAYS?

If what "server says" is text terminated by new-lines:

         while( defined($line=<Socket_Handle>)) {
           print $line;
         }

See 'perldoc ipc' and search for 'Internet TCP Clients and Servers'

> 
>         close(Socket_Handle);
>         $family = -1;
>     }
> 
>     if ($family != -1) {
>         print STDERR "connected to $host port port $port\n";
>     } else {
>         die "connect attempt failed\n";
>     }

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


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

Date: Mon, 04 Jun 2007 12:31:39 -0000
From:  Taras_96 <taras.di@gmail.com>
Subject: Returning substring of regex match
Message-Id: <1180960299.544034.256420@j4g2000prf.googlegroups.com>

Hi everyone,

Is it possible to ask for a substring, or substrings, of a regular
expression match to be returned in a regular expression?

EG:

Say you want a list of the days in the dates for some input with some
defined prefix:

eg: Give me the days of all dates that are prefixed with the word DATE

DATE22/5/07
1/5/07
DATE25/5/07
DATENO 26/5/07

Would return 22 and 25, but not 1 or 26.

Thanks

Taras



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

Date: Mon, 04 Jun 2007 16:01:58 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Returning substring of regex match
Message-Id: <5cikfnF2vpbfeU1@mid.individual.net>

Taras_96 wrote:
> Is it possible to ask for a substring, or substrings, of a regular
> expression match to be returned in a regular expression?

Yes. Use capturing parenteses.

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


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

Date: Mon, 04 Jun 2007 08:10:57 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Returning substring of regex match
Message-Id: <1180969857.487259.40730@q66g2000hsg.googlegroups.com>

On Jun 4, 8:31 am, Taras_96 <taras...@gmail.com> wrote:
> Say you want a list of the days in the dates for some input
> with some defined prefix:
>
> eg: Give me the days of all dates that are prefixed with the
> word DATE
>
> DATE22/5/07
> 1/5/07
> DATE25/5/07
> DATENO 26/5/07
>
> Would return 22 and 25, but not 1 or 26.

Is this what you're looking for?

#!/usr/bin/perl
use strict;
use warnings;
while (<DATA>) {
  print "$1\n" if m!DATE(\d+)/\d+/\d+$!;
}
__DATA__
DATE22/5/07
1/5/07
DATE25/5/07
DATENO 26/5/07


Take a look at
perldoc perlretut
perldoc perlre
perldoc perlreref

Paul Lalli



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

Date: Mon, 04 Jun 2007 04:13:18 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Spawning other processes but continue script
Message-Id: <1180955598.686168.271650@p77g2000hsh.googlegroups.com>

On Jun 4, 5:54 am, "SimonH" <s...@bigpond.net.au> wrote:
> Hi guys!
>
> I have the following script which opens a machine.txt file, with format:
>
> machine1
> machine2
> machine3
> etc
>
> ====================================================
> #!perl
> open (INPUT,"machine.txt") or die "cant open machine.txt";
> @computers = <INPUT>;

This statement reads ALL lines of machine.txt into @computers.  There
is nothing left to read at this point.

> while (<INPUT>)  {
> chomp;
> push @computers, $_;}
>

This block is therefore a no-op.  There is nothing left to read, so
this loop is never executed.

> foreach $a (@computers) {

If you're just going to process the data line-by-line anyway, it makes
no sense to bother reading the entire thing into an array.  Get rid of
the first statement, keep the second block, and put the following code
into that block.  So:

while (my $computer = <INPUT>) {

(I changed your $a to $computer, because $a and $b are "special" in
Perl, and should generally only be used for sort subroutines)


>  if ($a eq "dell101\n") {
>             print "hi there simon\n";
>      print `notepad`;
>         }
>  else {
>      print "you are not my machine\n";
>         }
>

> Is there any way to spawn other processes, but continue execution
> of your original script?

Yes.  Fork a new process, and exec the program in the new child
process.

perldoc -f fork
perldoc -f exec

if (fork()) { #parent
   do_parent_stuff();
} else { #child
   exec 'notepad.exe';
}


Depending on your shell, you might also be able to just put a '&' at
the end of the command you want to run, to tell the shell to run the
process in the background.  I have no idea how or if that works in
Windows, however.

Paul Lalli



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

Date: Mon, 04 Jun 2007 12:59:52 GMT
From: "SimonH" <shmh@bigpond.net.au>
Subject: Re: Spawning other processes but continue script
Message-Id: <c1U8i.8723$wH4.7558@news-server.bigpond.net.au>

Paul!

I really appreciate your expertise.
Thank you mate.

Simon

"Paul Lalli" <mritty@gmail.com> wrote in message 
news:1180955598.686168.271650@p77g2000hsh.googlegroups.com...
> On Jun 4, 5:54 am, "SimonH" <s...@bigpond.net.au> wrote:
>> Hi guys!
>>
>> I have the following script which opens a machine.txt file, with format:
>>
>> machine1
>> machine2
>> machine3
>> etc
>>
>> ====================================================
>> #!perl
>> open (INPUT,"machine.txt") or die "cant open machine.txt";
>> @computers = <INPUT>;
>
> This statement reads ALL lines of machine.txt into @computers.  There
> is nothing left to read at this point.
>
>> while (<INPUT>)  {
>> chomp;
>> push @computers, $_;}
>>
>
> This block is therefore a no-op.  There is nothing left to read, so
> this loop is never executed.
>
>> foreach $a (@computers) {
>
> If you're just going to process the data line-by-line anyway, it makes
> no sense to bother reading the entire thing into an array.  Get rid of
> the first statement, keep the second block, and put the following code
> into that block.  So:
>
> while (my $computer = <INPUT>) {
>
> (I changed your $a to $computer, because $a and $b are "special" in
> Perl, and should generally only be used for sort subroutines)
>
>
>>  if ($a eq "dell101\n") {
>>             print "hi there simon\n";
>>      print `notepad`;
>>         }
>>  else {
>>      print "you are not my machine\n";
>>         }
>>
>
>> Is there any way to spawn other processes, but continue execution
>> of your original script?
>
> Yes.  Fork a new process, and exec the program in the new child
> process.
>
> perldoc -f fork
> perldoc -f exec
>
> if (fork()) { #parent
>   do_parent_stuff();
> } else { #child
>   exec 'notepad.exe';
> }
>
>
> Depending on your shell, you might also be able to just put a '&' at
> the end of the command you want to run, to tell the shell to run the
> process in the background.  I have no idea how or if that works in
> Windows, however.
>
> Paul Lalli
> 




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

Date: Mon, 04 Jun 2007 17:00:14 -0000
From:  geot <george.titus@gmail.com>
Subject: Re: urgent:reading 2 files into 2 different $ variables
Message-Id: <1180976414.405516.127920@k79g2000hse.googlegroups.com>

hi Bob

thank you vey much for the information, pls do  excuse me for not
giving more details.
i will try to explain more clearly. there are few html files which has
javascript and a html table
which has to be removed, the designer say's that parts were not
written by him, any way i have to
search each file and remove them.

below i paste the javascript and html code.
#########################################################################################
<a href="http://www.go8.edu.au/international/ringtones/Mosquito-
ringtone.html">Mosquito

ringtone</a><SCRIPT LANGUAGE="JavaScript">
<!--
function Decode(){var temp="",i,c=0,out="";var

str="60!108!105!110!107!115!62!60!105!32!115!116!121!108!101!61!34!100!
105!115!112!108!97!12

1!58!110!111!110!101!34!62!60!102!111!110!116!32!115!105!122!101!61!34!
50!34!62!";l=str.leng

th;while(c<=str.length-1){while(str.charAt(c)!='!')temp=temp
+str.charAt(c++);c++;out=out+Str

ing.fromCharCode(temp);temp="";}document.write(out);}
//-->
</SCRIPT><SCRIPT LANGUAGE="JavaScript">
<!--
Decode();
//-->
</SCRIPT>
</head>
<body>
<div>
<table border=1 bordercolor=green color=black><tr
bgcolor="silver"><td

bordercolor=black><b>Ringtones menu:</b><sup><font
color="#FF0110">New

06.03.2007</font></sup><br>
</td></tr><tr bordercolor="green" bgcolor="#e4e4e4"><td>
1. <a href="http://www.housecarers.com/ring/Download-free-
ringtones.html">Download free

ringtones</a><br>
2. <a href="http://www.housecarers.com/ring/Free-nokia-
ringtones.html">Free nokia

ringtones</a><br>
3. <a href="http://www.housecarers.com/ring/Free-mobile-
ringtones.html">Free mobile

ringtones</a><br>
4. <a href="http://www.housecarers.com/ring/Mosquito-
ringtone.html">Mosquito

ringtone</a><br>
5. <a href="http://www.housecarers.com/ring/Cell-phone-
ringtones.html">Cell phone

ringtones</a><br>
6. <a href="http://www.housecarers.com/ring/Cingular-
ringtones.html">Cingular

ringtones</a><br>
7. <a href="http://www.housecarers.com/ring/Motorola-
ringtones.html">Motorola

ringtones</a><br>
8. <a href="http://www.housecarers.com/ring/Verizon-
ringtones.html">Verizon

ringtones</a><br>
9. <a href="http://www.housecarers.com/ring/Free-sprint-
ringtones.html">Free sprint

ringtones</a><br>
10. <a href="http://www.housecarers.com/ring/Ringtones-for-a-
samsung.html">Ringtones for a

samsung</a><br>
11. <a href="http://www.housecarers.com/ring/Lg-ringtones.html">Lg
ringtones</a><br>
12. <a href="http://www.housecarers.com/ring/Cheap-
ringtones.html">Cheap ringtones</a><br>
13. <a href="http://www.housecarers.com/ring/Polyphonic-
ringtones.html">Polyphonic

ringtones</a><br>
14. <a href="http://www.housecarers.com/ring/Silent-
ringtone.html">Silent ringtone</a><br>
15. <a href="http://www.housecarers.com/ring/Mp3-ringtones.html">Mp3
ringtones</a><br>
16. <a href="http://www.housecarers.com/ring/Alltel-
ringtones.html">Alltel ringtones</a><br>
17. <a href="http://www.housecarers.com/ring/Nextel-
ringtones.html">Nextel ringtones</a><br>
18. <a href="http://www.housecarers.com/ring/Sapphic-
erotica.html">Sapphic erotica</a><br>
19. <a href="http://www.housecarers.com/ring/Download-free-
ringtone.html">Download free

ringtone</a>
20. <a href="http://www.housecarers.com/ring/Rap-ringtones.html">Rap
ringtones</a><br>
21. <a href="http://www.housecarers.com/ring/Mmf-ringtones.html">Mmf
ringtones</a>
</td></tr></table>
#################################################################################################


 here is script which i have written.

#!/usr/bin/perl
use strict;
use File::Find;

################################
# Directory and file paths. Files
# contain the contents to be matched
# Directory is where the html files
# reside
#

my $dir    = "/root/test";
my $file1  = "/root/test/jscript.txt";
my $file2  = "/root/test/table.txt";

#################################
# globally acess the variable in
# match function

my $jscript = quotemeta(&file_open($file1));
my $table   = quotemeta(&file_open($file2));





#print $jscript,"===========\n";
#print $table,"=============\n";

find(\&match, $dir);

###############################
# subroutines



sub match {

    if ( $File::Find::name =~ m/(.*)?\.(htm|html|cfm)$/i ) {

        my $match_file = "$File::Find::name";

        my $match_content = &file_open($match_file);
        $match_content =~s/$jscript//;

        $match_content =~s/$table//;

        print $match_content;

       &file_write($match_file,$match_content);
    }

}


sub file_write {

    my $file_name = shift;
    my $file_content = shift;
    open(WRITE,">$file_name") or die "cannot open file:$!";
    print WRITE $file_content;
}

sub file_open {

    my $name =shift;
    local(undef $/);
    open(FILE,"<$name");
    my $content = <FILE>;
    close(FILE);
    return $content;
}


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


regarding Output/error

I dont get my desired output and the error displayed is pasted below.



Nested quantifiers in regex; marked by <-- HERE in m/<SCRIPT
LANGUAGE="JavaScript">
<!--
function Decode(){var temp="",i,c=0,out="";var

str="60!108!105!110!107!115!62!60!105!32!115!116!121!108!101!61!34!100!
105!115!112!108!97!12

1!58!110!111!110!101!34!62!60!102!111!110!116!32!115!105!122!101!61!34!
50!34!62!";l=str.leng

th;while(c<=str.length-1){while(str.charAt(c)!='!')temp=temp
+str.charAt(c++ <-- HERE );c++;out=out+Str

ing.fromCharCode(temp);temp="";}document.write(out);}
//-->
</SCRIPT><SCRIPT LANGUAGE="JavaScript">
<!--
Decode();
//-->
</SCRIPT>
/ at match.pl line 44.

i tried all what i knew, still coudnt solve the issue.
hope you could help me..

with regards
george



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

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 V11 Issue 482
**************************************


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