[27948] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9312 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 18 18:06:05 2006

Date: Sun, 18 Jun 2006 15:05:05 -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           Sun, 18 Jun 2006     Volume: 10 Number: 9312

Today's topics:
    Re: balanced paren regex's ivowel@gmail.com
    Re: balanced paren regex's ivowel@gmail.com
    Re: balanced paren regex's <benmorrow@tiscali.co.uk>
    Re: balanced paren regex's <xicheng@gmail.com>
    Re: File::Find - passing argument to &wanted <hobosalesman@gmail.com>
    Re: How to use threads? <jeffpeng@pobox.com>
        question in mysql_config <"v.niekerk at hccnet.nl">
    Re: question in mysql_config <sherm@Sherm-Pendleys-Computer.local>
    Re: question in mysql_config <"v.niekerk at hccnet.nl">
    Re: question in mysql_config <sherm@Sherm-Pendleys-Computer.local>
    Re: question in mysql_config <"v.niekerk at hccnet.nl">
    Re: question in mysql_config <"v.niekerk at hccnet.nl">
    Re: question in mysql_config <sherm@Sherm-Pendleys-Computer.local>
    Re: question on "if () " <"v.niekerk at hccnet.nl">
    Re: question on "if () " <"v.niekerk at hccnet.nl">
    Re: question on "if () " <jurgenex@hotmail.com>
    Re: question on "if () " <jurgenex@hotmail.com>
    Re: question on "if () " <christoph.lamprecht.no.spam@web.de>
    Re: question on "if () " <jurgenex@hotmail.com>
    Re: question on "if () " <"v.niekerk at hccnet.nl">
    Re: question on "if () " <tadmc@augustmail.com>
    Re: question on "if () " <corff@zedat.fu-berlin.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 18 Jun 2006 06:55:01 -0700
From: ivowel@gmail.com
Subject: Re: balanced paren regex's
Message-Id: <1150638901.511018.282860@p79g2000cwp.googlegroups.com>


thank you very much.   regards, /iaw



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

Date: 18 Jun 2006 13:15:24 -0700
From: ivowel@gmail.com
Subject: Re: balanced paren regex's
Message-Id: <1150661724.057819.3990@c74g2000cwc.googlegroups.com>


I am truly becoming greedy now.   is there a good/clever way to keep
track on which lineno the match was made on (i.e., how many \n occurred
before)?  [something similar to $., but in connection with a text
match.]

regards,

/iaw



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

Date: Sat, 17 Jun 2006 23:06:59 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: balanced paren regex's
Message-Id: <31bem3-1l3.ln1@osiris.mauzo.dyndns.org>


Quoth ivowel@gmail.com:
> 
> [posted earlier in perl.modules, but no answer.]
> 
> dear perl users:  I want to write a function that extracts "ordinary"
> subroutines from perl code.  (an equivalent task is extracting all
> macros from a latex file.)  I am not trying to be too clever.  let's
> presume I can recognize subs because subs and only subs always start at
> the first character of a line and are not anonymous.  a sub is followed
> by a name and can contain nested expressions.
> 
> I can do plain pattern matching to find the first occurance of the
> first sub: '^sub \w+'.  but now I am stuck.  I need to continue
> on with a Text::Balanced expression right after, and after the
> text::balanced is done, continue on with my regex search (\G).

You mentioned Text::Balanced; how does extract_codeblock not do what you
want?

Ben

-- 
  The cosmos, at best, is like a rubbish heap scattered at random.
                                                           Heraclitus
  benmorrow@tiscali.co.uk


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

Date: 18 Jun 2006 14:36:33 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: balanced paren regex's
Message-Id: <1150666593.208934.121850@r2g2000cwb.googlegroups.com>

ivowel@gmail.com wrote:
> I am truly becoming greedy now.   is there a good/clever way to keep
> track on which lineno the match was made on (i.e., how many \n occurred
> before)?  [something similar to $., but in connection with a text
> match.]

sure you can. the key for this method (you might want to read [1] for
more introduction about iteration) is how to use "closure" in Perl
subroutines. I revised the previous subroutine again and fixed some
bugs. :

1) 's' modifier is added in the s/// expression, otherwise .*? can not
match multiple lines;
2) capture two parts: $1, and $2, and use something like $1 =~ tr/\n//;
to count the number of newlines in a substring.
3) "return" statement is revised so that you can use the iterator in a
while loop;
4) two variables added: $line_num to count newlines in the whole
matched text block. $lineno is the line_number containing the keyword
'sub' of your function declaration...

###################################
sub getnextsub {
    my $text = shift;
    my $line_num = 0;
    return sub {
        my $num_subs = shift || 1;
        my ($sub_def, $cnt) = ("", 0);
        while ($text =~ s/(.*?(sub\s*\S+\s*{$pattern}))//s) {
            $line_num += ($1 =~ tr/\n//);
            if (++$cnt == $num_subs) {
                $sub_def = $2;
                my $lineno = $line_num + 1 - ($sub_def =~ tr/\n//);
                print "line_number is $lineno\n";
                last;
            }
        }
        print "undefined\n" if not $sub_def;
        return $sub_def;
    }
}   # end of getnextsub #
###################################

don't know where you want the line numbers to go, so just print them
out.

Good luck
Xicheng

[1] "Higher-Order Perl: Transforming Programs with Programs", by M.J.
Dominus.



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

Date: 18 Jun 2006 12:05:35 -0700
From: "Hobo Salesman" <hobosalesman@gmail.com>
Subject: Re: File::Find - passing argument to &wanted
Message-Id: <1150657535.363946.112220@u72g2000cwu.googlegroups.com>

Juha Laiho wrote:
> For the second point, I think you're correct - in perl world there's
> not nearly as many PHPNuke clones available as on the PHP side.
> "Elementary" modules (doing for whatever "small" thing), however, I think
> are more abundant in Perl (f.ex. how often would you like to be able
> to generate PostScript (not just text but with graphics primitives) from
> a web application).

This looks interesting:

http://www.zend.com/php5/articles/php5-perl.php

Best of both worlds?



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

Date: Sun, 18 Jun 2006 18:16:37 +0800
From: "pyh" <jeffpeng@pobox.com>
Subject: Re: How to use threads?
Message-Id: <e739kp$27t$1@news.cn99.com>

Hello,

You don't need threads here.Just fork the childs and call the 'exec' to do
the additional works in your CGI answers.

<veg_all@yahoo.com> ????
news:1150591735.968229.22370@u72g2000cwu.googlegroups.com...
> Once a day my perl cgi script tars and zips up the customer data and
> ftps it to a backup server. The script takes around 10 seconds to do
> this but normally runs in less than a second. Is there a way I can use
> threads to do the tarring and ftping parallel with the main script
> execution?
>
> I read perlthrtut but my perl installation does not seem to support the
> functionality in it. Is there any workaround besides upgrading the perl
> installation?
>




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

Date: Sun, 18 Jun 2006 16:56:25 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: question in mysql_config
Message-Id: <44956999$0$31064$e4fe514c@dreader27.news.xs4all.nl>

Hi,

I'm trying to install DBD::mysql. When I start cpan, I start "look 
DBD::mysql". Then in the terminal "perl Makefile.PL 
--testhost=<hostname>". Then I get this message:

Can't exec "mysql_config": No such file or directory at Makefile.PL line 76.

Do I have to install something else first?

Thanks,

Huub


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

Date: Sun, 18 Jun 2006 11:34:26 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: question in mysql_config
Message-Id: <m2ejxmwk8t.fsf@Sherm-Pendleys-Computer.local>

Huub <"v.niekerk at hccnet.nl"> writes:

> Hi,
>
> I'm trying to install DBD::mysql. When I start cpan, I start "look
> DBD::mysql". Then in the terminal "perl Makefile.PL
> --testhost=<hostname>". Then I get this message:
>
> Can't exec "mysql_config": No such file or directory at Makefile.PL line 76.
>
> Do I have to install something else first?

You don't *have* to, no. If you don't use --testhost and other options to
specify the host, port, etc. to connect to, and where to find the MySQL
client headers and libraries, then Makefile.PL will run the mysql_config
tool to get that information.

If you *have* given all the relevant information, then the failure to find
mysql_config will cause no harm.

Obviously, btw, you do need to have the MySQL client C library and headers
installed somewhere on your system.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Sun, 18 Jun 2006 18:37:24 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: question in mysql_config
Message-Id: <44958146$0$27269$e4fe514c@dreader32.news.xs4all.nl>

> 
> Obviously, btw, you do need to have the MySQL client C library and headers
> installed somewhere on your system.
> 

Thank you. Another problem: on another machine I installed it with help 
from you and others. With this new installation, I get this with "make":

> 
> /usr/bin/ld: cannot find -lz
> collect2: ld returned 1 exit status
> 
> 
> An error occurred while linking the DBD::mysql driver. The error
> message seems to indicate that you don't have a libz.a,
> or a libz.so. This is typically resolved by:
> 
> 1.) You may try to remove the -lz or -lgz flag from the libs list
>     by using the --libs switch for "perl Makefile.PL".
> 2.) On Red Hat Linux install libz-devel
> 3.) On other systems, please contact the mailing list
> 

Though both machines run Fedora, neither has libz-devel installed. And 
on the other machine I didn't get this message. Any clue?


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

Date: Sun, 18 Jun 2006 13:03:25 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: question in mysql_config
Message-Id: <m2hd2i4crm.fsf@Sherm-Pendleys-Computer.local>

Huub <"v.niekerk at hccnet.nl"> writes:

>> /usr/bin/ld: cannot find -lz
>> collect2: ld returned 1 exit status
>> An error occurred while linking the DBD::mysql driver. The error
>> message seems to indicate that you don't have a libz.a,
>> or a libz.so. This is typically resolved by:
>> 1.) You may try to remove the -lz or -lgz flag from the libs list
>>     by using the --libs switch for "perl Makefile.PL".
>> 2.) On Red Hat Linux install libz-devel
>> 3.) On other systems, please contact the mailing list
>> 
>
> Though both machines run Fedora, neither has libz-devel installed.

You've already identified the problem, and the solution is listed as #2
on the list above: Install libz-devel.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Sun, 18 Jun 2006 20:09:23 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: question in mysql_config
Message-Id: <44959259$0$31393$e4fe514c@dreader25.news.xs4all.nl>

>>>
>> Though both machines run Fedora, neither has libz-devel installed.
> 
> You've already identified the problem, and the solution is listed as #2
> on the list above: Install libz-devel.
> 
> sherm--
> 

That doesn't answer the question why the other machine posed not problem 
  in this situation, while it didn't have libz either.
BTW, the INSTALL.html indicates that libz is only necessary when 
installing from source. Assuming both "look DBD::mysql" or "install 
DBD::mysql" mean installing from source, what is installing from 
pre-compiled then?


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

Date: Sun, 18 Jun 2006 21:07:02 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: question in mysql_config
Message-Id: <4495a455$0$15694$e4fe514c@dreader27.news.xs4all.nl>

>>>
>> Though both machines run Fedora, neither has libz-devel installed.
> 
> You've already identified the problem, and the solution is listed as #2
> on the list above: Install libz-devel.
> 
> sherm--
> 

That doesn't answer the question why the other machine posed not problem
  in this situation, while it doesn't have libz either. On the other 
hand, zlib is installed, which turns out to be the successor tp libz. 
So, I fail to see what's going wrong and why.
BTW, the INSTALL.html indicates that libz is only necessary when
installing from source. Assuming both "look DBD::mysql" or "install
DBD::mysql" mean installing from source, what is installing from
pre-compiled then?


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

Date: Sun, 18 Jun 2006 16:11:15 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: question in mysql_config
Message-Id: <m2ejxmusv0.fsf@Sherm-Pendleys-Computer.local>

Huub <"v.niekerk at hccnet.nl"> writes:

>>>>
>>> Though both machines run Fedora, neither has libz-devel installed.
>> You've already identified the problem, and the solution is listed as
>> #2
>> on the list above: Install libz-devel.
>> sherm--
>> 
>
> That doesn't answer the question why the other machine posed not problem
>  in this situation, while it doesn't have libz either. On the other
> hand, zlib is installed, which turns out to be the successor tp
> libz. So, I fail to see what's going wrong and why.

Who knows? Different MySQL client libraries, different -dev packages, etc.
Any number of possibilities exist. I wouldn't waste time worrying about it.
I'd just do what the error message says to do (install libz-devel) and move
on.

> BTW, the INSTALL.html indicates that libz is only necessary when
> installing from source. Assuming both "look DBD::mysql" or "install
> DBD::mysql" mean installing from source, what is installing from
> pre-compiled then?

RPM or PPD packages, etc. - lots of ways to get pre-compiled modules on
a variety of platforms.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Sun, 18 Jun 2006 09:52:23 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: question on "if () "
Message-Id: <4495063a$0$31482$e4fe514c@dreader21.news.xs4all.nl>

> Your result will yield one line only.
> 
> : #       $bezorger = @bezorger;
> 
> Let @bezorger contain more than one scalar, then you probably want to say
> $bezorger=@bezorger[0].
> 

@bezorger will contain only 1 element or scalar. A print-call after 
$bezorger = @bezorger showed that the number of elements was assigned to 
$bezorger, not the value ( 1 instead of 3). Putting [] behind @bezorger 
leads to errors. Any more clues?

> if ($bezorger == 1) yields true if the scalar $bezorger is exactly equal to 
> the numerical value 1.
> 
> if (@bezorger == 1) yields true if the array @bezorger contains exactly one
> element, regardless of the numerical or textual value of that element.
> 

Thank you.


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

Date: Sun, 18 Jun 2006 11:35:41 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: question on "if () "
Message-Id: <44951e6b$0$420$e4fe514c@dreader24.news.xs4all.nl>

> Your result will yield one line only.
> 
> : #       $bezorger = @bezorger;
> 
> Let @bezorger contain more than one scalar, then you probably want to say
> $bezorger=@bezorger[0].
> 

@bezorger will contain only 1 element or scalar. A print-call after
$bezorger = @bezorger showed that the number of elements was assigned to
$bezorger, not the value ( 1 instead of 3). Putting [] behind @bezorger
leads to errors. Any more clues?

Solved it...thank you.

> if ($bezorger == 1) yields true if the scalar $bezorger is exactly equal to 
> the numerical value 1.
> 
> if (@bezorger == 1) yields true if the array @bezorger contains exactly one
> element, regardless of the numerical or textual value of that element.
> 

Thank you.


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

Date: Sun, 18 Jun 2006 10:26:07 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: question on "if () "
Message-Id: <3T9lg.4640$Za5.539@trnddc04>

Huub" <"v.niekerk at hccnet.nl wrote:
> I want to compare a variable with 1, but the code after "if" is
> executed anyway. This is the code immediately before "if":

> # $bezorger = @bezorger;
> if (@bezorger == 1)

This condition will yield true if the array @bezorger contains exactly one 
element. Is that what you meant to test?

> I did "if ($bezorger == 1)" and "if (@bezorger == 1)" but neither
> seems to work. Do I miss something?

Same for the assignment which will assign the lenght of @bezorger to 
$bezorger.

If you want to compare an element of @bezorger with 1, then you will have to 
specify that element.

jue





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

Date: Sun, 18 Jun 2006 10:31:01 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: question on "if () "
Message-Id: <FX9lg.4642$Za5.2670@trnddc04>

Huub" <"v.niekerk at hccnet.nl wrote:
>> Your result will yield one line only.
>>
>>> #       $bezorger = @bezorger;
>>
>> Let @bezorger contain more than one scalar, then you probably want
>> to say $bezorger=@bezorger[0].
>>
>
> @bezorger will contain only 1 element or scalar. A print-call after
> $bezorger = @bezorger showed that the number of elements was assigned
> to $bezorger, not the value ( 1 instead of 3).

Yes. That is the intended semantic of using an array in scalar context: it 
returns the lenght of that array, i.e. the number of its elements.

> Putting [] behind
> @bezorger leads to errors. Any more clues?

If you want the value of an element of that array then just select that 
element, e.g. @bezorger[5] if you want the sixth element (array indexing 
starts at 0).

jue 




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

Date: Sun, 18 Jun 2006 12:40:36 +0200
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: question on "if () "
Message-Id: <e73aj0$rkn$1@online.de>

Jürgen Exner wrote:
> Huub" <"v.niekerk at hccnet.nl wrote:

>>Putting [] behind
>>@bezorger leads to errors. Any more clues?
> 
> 
> If you want the value of an element of that array then just select that 
> element, e.g. @bezorger[5] if you want the sixth element (array indexing 
> starts at 0).

$bezorger[5]

if you are using perl5 ;)

Christoph
-- 

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"


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

Date: Sun, 18 Jun 2006 10:47:52 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: question on "if () "
Message-Id: <sbalg.4644$Za5.1642@trnddc04>

Ch Lamprecht wrote:
> Jürgen Exner wrote:
>> Huub" <"v.niekerk at hccnet.nl wrote:
>
>>> Putting [] behind
>>> @bezorger leads to errors. Any more clues?
>>
>>
>> If you want the value of an element of that array then just select
>> that element, e.g. @bezorger[5] if you want the sixth element (array
>> indexing starts at 0).
>
> $bezorger[5]
>
> if you are using perl5 ;)

Ooops, you are absolutely right, of course.
Brainfart on my side.

jue




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

Date: Sun, 18 Jun 2006 13:52:11 +0200
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: question on "if () "
Message-Id: <44953e6b$0$19464$e4fe514c@dreader17.news.xs4all.nl>

>>
>> If you want the value of an element of that array then just select 
>> that element, e.g. @bezorger[5] if you want the sixth element (array 
>> indexing starts at 0).
> 
> $bezorger[5]
> 
> if you are using perl5 ;)

Yes, found that out..thank you for helping out.


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

Date: Sun, 18 Jun 2006 10:02:35 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: question on "if () "
Message-Id: <slrne9aqob.f69.tadmc@magna.augustmail.com>

<corff@zedat.fu-berlin.de> <corff@zedat.fu-berlin.de> wrote:

> you probably want to say
> $bezorger=@bezorger[0].


You never want to say that, since you should always enable warnings
when developing Perl code.  :-)

So you should instead say:

   $bezorger = $bezorger[0];

or

   ($bezorger) = @bezorger;  # a "list assignment"


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


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

Date: 18 Jun 2006 21:34:32 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: question on "if () "
Message-Id: <4flv78F1im1njU2@uni-berlin.de>

Tad McClellan <tadmc@augustmail.com> wrote:
: <corff@zedat.fu-berlin.de> <corff@zedat.fu-berlin.de> wrote:

: > you probably want to say
: > $bezorger=@bezorger[0].


: You never want to say that, since you should always enable warnings
: when developing Perl code.  :-)

Oops. Major gaffe from my side. Please accept my apologies,
$bezorger=$bezorger[0] was intended.

Oliver.

-- 
Dr. Oliver Corff              e-mail:    corff@zedat.fu-berlin.de


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

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


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