perl.beginners http://www.nntp.perl.org/group/perl.beginners/ Re: Tell me how to use CGI.pm in table by timothy adigun

From: timothy adigun Hi Masayoshi,

On Sat, May 18, 2013 at 12:51 AM, Masayoshi Fujimoto <
m.fujimoto@rocketmail.com> wrote:

> Hi
> Please help me.
> I can only see Hilary Duff.
> I can not see Taylor Momsen.
> I would like to use table for that.
> How should I do?
>
> ## Here is my script.
> #!/usr/bin/perl
> use Modern::Perl;
> use autodie;
> use CGI;
>
>
> my $q = CGI->new;
>
> my %label = (
> celeb => 'Who do you fancy? : ',
> );
>
> my %form = (
> celeb => $q->radio_group(-name=>'celeb',
> -values=>['Hilary
> Duff','Taylor Momsen'],
> -default=>'Hilary Duff'),
>

The line above gives a warning message: Odd number of elements in hash
assignment.

You can re-write that like so:

my $radio = $q->radio_group(
-name => 'celeb',
-values => [ 'Hilary Duff', 'Taylor Momsen' ],
-default => 'Hilary Duff');

my %form = (
celeb => $radio,
submit => $q->submit,
reset => $q->reset,
);


> say $q->header;
> say $q->start_html;
> say $q->start_form;
> say $q->table(
> $q->Tr([
> $q->td([$label{celeb},$form{celeb}]),
> $q->td([$form{submit},$form{reset}]),
> ])
> );
> say $q->end_form;
> say $q->submit;
> say $q->end_form;
> say $q->end_html;
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>


--
Tim

2013-05-18T08:19:07Z
Battling with threaded TCP server by Chris Knipe

From: Chris Knipe Hi,

I am looking for assistance in programing an TCP Socket server. Effectively,
I am looking for a skeleton to do the following:

- Server starts up, and starts x amounts of threads (working)
- All threads connects to an remote server via TCP and idles, keeping
the connections alive (working)
- Server starts an listening socket using IO::Socket::INET (working)
- Server forks (non-blocking) when an client connects (working)
- Client must now give an command, and that command must be passed to
the thread queues, to be executed by the thread pool as threads becomes
available *whilst the client waits on the socket*.
- The thread will respond with content to the client via the socket
- Client quits

The threads implementation is based on Jerry Hedden's example of thread
pooling (
http://cpansearch.perl.org/src/JDHEDDEN/threads-1.86/examples/pool_reuse.pl
). The code via term does -exactly- what I require, and I've had no issues
what so ever to amend and change this to work as I require it to do over
term. However, I am having significant issues combining this with a socket.
I am absolutely sure however that this is something that I am doing wrong,
more than likely, the entire application needs to be threaded and therefore
re-written from scratch.

The basic theory is that there will be x amount of sleeping threads, and the
socket will receive more connections than what there is threads. The entire
application thus pools connections to retrieve content from remote servers.

My IO::Socket::INET has successfully started and is listening, and I fork
using
print "Server waiting for connections\n";
my $Client;
while ($Client = $Socket->accept()) {
my $pid;
while (not defined ($pid = fork())) {
sleep 0.5;
}
if ($pid) {
close($Client);
} else {
$Client->autoflush(1);
close $Socket;
&DoClientSocket();

And following Jerry's example code, the threads work by (this is what the
client socket would need to execute as far as I can see):
# Work loop
do {
# Indicate that were are ready to do work
printf("Idle -> %2d\n", $tid);
$IDLE_QUEUE->enqueue($tid);

# Wait for work from the queue
my $work = $work_q->dequeue();

# If no more work, exit
last if ($work < 0);

# Do some work while monitoring $TERM
printf(" %2d <- Working\n", $tid);
while (($work > 0) && ! $TERM) {
$work -= sleep($work);
}

# Loop back to idle state if not told to terminate
} while (! $TERM);

But I am really at a loss as to how to integrate the two. The sub used by
IO::Socket::INET (even if passing the variables and hash refs as parameters,
i.e. &ClientSocket(\%work_queues, $tid)) does not successfully pass any work
to the thread pool, and the thread pool also seems to be 'idling' rather
than checking and processing work given to it. I believe this is because
IO::Socket::INET waits for client connections, and does not give the thread
pool time to look for and do it's queued work as well.

Can anyone please assist a semi newbie? I need this to work relatively
urgently and I would prefer to rather take this off list and spend half an
hour or an hour with an individual able to assist (just don't want to sit
here spamming the lists). At this stage, I'm even willing to pay if that's
what it needs to come down to...

Many thanks,
Chris.



2013-05-18T07:53:56Z
Re: What does $$ mean ? by *Shaji Kalidasan* <p>From: *Shaji Kalidasan* Dr. Ruud,<br/><br/>Thank you very much for your kind explanation. The pointers you suggested is very handy in understanding the complex data structures.<br/><br/>&nbsp;<br/>best,<br/>Shaji <br/>-------------------------------------------------------------------------------<br/>Your talent is God&#39;s gift to you. What you do with it is your gift back to God.<br/>-------------------------------------------------------------------------------<br/><br/><br/>________________________________<br/> From: Dr.Ruud &lt;rvtol+usenet@isolution.nl&gt;<br/>To: beginners@perl.org <br/>Sent: Friday, 17 May 2013 6:17 PM<br/>Subject: Re: What does $$ mean ?<br/> <br/><br/>On 17/05/2013 14:39, *Shaji Kalidasan* wrote:<br/><br/>&gt; [CODE1]<br/>&gt; keys %{$$disk_type_ref{$pool}};<br/>&gt; [/CODE1]<br/>&gt;<br/>&gt; Moreover, what does $$ mean here<br/><br/>&nbsp; %{$$disk_type_ref{$pool}};<br/><br/>can also be written as<br/><br/>&nbsp; %{ $disk_type_ref-&gt;{ $pool } };<br/><br/>See further perldsc.<br/><br/>&gt; -------------------------------------------------------------------------------<br/>&gt; Your talent is God&#39;s gift to you. What you do with it is your gift back<br/>&gt; to God.<br/>&gt; -------------------------------------------------------------------------------<br/><br/>https://www.facebook.com/pages/David-Bowie-is-GOD/133491090062327<br/><br/>-- <br/>Ruud<br/><br/><br/>-- <br/>To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>For additional commands, e-mail: beginners-help@perl.org<br/>http://learn.perl.org/<br/></p> 2013-05-18T04:53:04Z Tell me how to use CGI.pm in table by Masayoshi Fujimoto

From: Masayoshi Fujimoto Hi
Please help me.
I can only see Hilary Duff.
I can not see Taylor Momsen.
I would like to use table for that.
How should I do?

## Here is my script.
#!/usr/bin/perl
use Modern::Perl;
use autodie;
use CGI;


my $q = CGI->new;

my %label = (
celeb => 'Who do you fancy? : ',
);

my %form = (
celeb => $q->radio_group(-name=>'celeb',
-values=>['Hilary Duff','Taylor Momsen'],
-default=>'Hilary Duff'),
submit => $q->submit,
reset => $q->reset,
);

say $q->header;
say $q->start_html;
say $q->start_form;
say $q->table(
$q->Tr([
$q->td([$label{celeb},$form{celeb}]),
$q->td([$form{submit},$form{reset}]),
])
);
say $q->end_form;
say $q->submit;
say $q->end_form;
say $q->end_html;

2013-05-17T23:51:40Z
RE: What does $$ mean ? by Frank K.

From: Frank K. Gosh, I always thought "$$" is what you have to pay when you get a divorce <vbg>.. flk k

-----Original Message-----
From: Dr.Ruud [mailto:rvtol+usenet@isolution.nl]
Sent: Friday, May 17, 2013 7:47 AM
To: beginners@perl.org
Subject: Re: What does $$ mean ?

On 17/05/2013 14:39, *Shaji Kalidasan* wrote:

> [CODE1]
> keys %{$$disk_type_ref{$pool}};
> [/CODE1]
>
> Moreover, what does $$ mean here

%{$$disk_type_ref{$pool}};

can also be written as

%{ $disk_type_ref->{ $pool } };

See further perldsc.

> ----------------------------------------------------------------------
> --------- Your talent is God's gift to you. What you do with it is
> your gift back to God.
> ----------------------------------------------------------------------
> ---------

https://www.facebook.com/pages/David-Bowie-is-GOD/133491090062327

--
Ruud


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/



2013-05-17T14:03:23Z
Re: What does $$ mean ? by Dr.Ruud

From: Dr.Ruud On 17/05/2013 14:39, *Shaji Kalidasan* wrote:

> [CODE1]
> keys %{$$disk_type_ref{$pool}};
> [/CODE1]
>
> Moreover, what does $$ mean here

%{$$disk_type_ref{$pool}};

can also be written as

%{ $disk_type_ref->{ $pool } };

See further perldsc.

> -------------------------------------------------------------------------------
> Your talent is God's gift to you. What you do with it is your gift back
> to God.
> -------------------------------------------------------------------------------

https://www.facebook.com/pages/David-Bowie-is-GOD/133491090062327

--
Ruud

2013-05-17T12:47:31Z
What does $$ mean ? by *Shaji Kalidasan*

From: *Shaji Kalidasan* Greetings,

What does this mean

[CODE1]

keys %{$$disk_type_ref{$pool}};
[/CODE1]


Moreover, what does $$ mean here

[CODE2]

@{$$disk_type_ref{$pool}{$med_value}}
[/CODE2]


What data structures does the above things denote? Any pointers will be of great help.

Thanking you in advance.

best,

Shaji
-------------------------------------------------------------------------------
Your talent is God's gift to you. What you do with it is your gift back to God.
-------------------------------------------------------------------------------

2013-05-17T12:39:27Z
Re: map problems by Natxo Asenjo

From: Natxo Asenjo On Thu, May 16, 2013 at 11:14 PM, Jim Gibson <jimsgibson@gmail.com> wrote:

> The * in (.*) is "greedy", meaning the Perl regular expression engine will
> try to match as much as possible in each string after it finds the
> substring 'cn='. To make it "non-greedy", put a question mark after the
> quantifier: s/^cn=(.*?),/$1/
>
>
yes, I had forgotten that. Thanks for your kind explanation.

--
groet,
natxo

2013-05-16T21:32:13Z
Re: map problems by Peter Gordon

From: Peter Gordon <HTML><HEAD>
<BASEFONT FACE="Arial" SIZE="3" COLOR="#000000">
</HEAD>
<BODY>
<div>On Thu, 16 May 2013 21:57:55 +0200, Natxo Asenjo wrote:<br></div>
<div>&gt;in a ldap script where I get a list of values of a multivalued &gt;attribute like this:<br></div>
<div>&nbsp;</div>
<div>&gt;@memberof = qw( cn=group1,cn=xxx,dc=domain,dc=tld &gt;cn=group2,cn=xxx,d=domain,dc=tld etc etc) ;<br></div>
<div>&nbsp;</div>
<div>&gt;I would like to use map to convert the list of elements to<br></div>
<div>&gt;@memberof = qw( group1 group2 group3 etc etc )<br></div>
<div><br>
I'm not clear on what you are trying to achieve.&nbsp; Your problem is probably in the RE.&nbsp; The comma in your RE is greedy. <br></div>
<div>A &quot;?&quot; within the brackets makes it non greedy.&nbsp; Read<br></div>
<div><a href="http://www.itworld.com/nl/perl/01112001">http://www.itworld.com/nl/perl/01112001</a><br></div>
<div>for a good explanation of this subject.<br></div>
<div>The code below illustrates the difference.<br></div>
<div>&nbsp;</div>
<div>#!/usr/bin/perl -w<br></div>
<div>use 5.14.0;<br></div>
<div>my $str = &quot;cn=group1,cn=xxx,dc=domain,dc=tld cn=group2,cn=xxx,d=domain,dc=tld&quot;;<br></div>
<div>$str =~ /^cn=(.*),.*/;<br></div>
<div>say $1;<br></div>
<div>$str =~ /^cn=(.*?),.*/;<br></div>
<div>say $1;<br></div>
<div>__END__<br></div>
<div>*** Output ***<br></div>
<div>group1,cn=xxx,dc=domain,dc=tld cn=group2,cn=xxx,d=domain<br></div>
<div>group1<br>
<br>
<br></div>
<div>-- <br></div>
<div>Peter Gordon, petergo@netspace.net.au on 05/17/2013<br></div>
</body></html>


2013-05-16T21:28:18Z
Re: map problems by timothy adigun

From: timothy adigun Hi Natxo,
Please see my comment below:

On Thu, May 16, 2013 at 8:57 PM, Natxo Asenjo <natxo.asenjo@gmail.com>wrote:

> hi,
>
> in a ldap script where I get a list of values of a multivalued attribute
> like this:
>
> @memberof = qw( cn=group1,cn=xxx,dc=domain,dc=tld
> cn=group2,cn=xxx,d=domain,dc=tld etc etc) ;
>

Since you use "qw", there is no need to still separate the element of
your array with comma.

>
> I would like to use map to convert the list of elements to
> @memberof = qw( group1 group2 group3 etc etc )
>

Does etc etc here mean words like group...?


>
> This is the code I have tried to capture the first string after the first
> '=' in the $1 variable
>
> @memberof = map { s/^cn=(.*),.*$/$1/g; $_ } @memberof;
> for ( @memberof ) {
> print "[$_]" . " " ;
> }
>
> but this snippet strangely cuts the start and the end of every array
> element beginning and end so I get this:
>
> [group1,cn=xxx,dc=domain] [group2,cn=xxxx,dc=domain]
>
> so it is obviously not working. Is there a way to do this with map or do I
> just have to process the array in a for loop and fill a new array with the
> values? Just curious
>


Understanding for/foreach loop could help in a way to understand and
use map function.

Please see below one of the way of doing what you intended:

[CODE]

use warnings;
use strict;

my @memberof =
qw( cn=group1 cn=xxx dc=domain dc=tld cn=group2 cn=xxx d=domain dc=tld
etc etc);

## using for loop

for my $grp (@memberof) {
if ( $grp =~ m/(?<=\=)(.+)/ ) {
my $matched = $1;
print $matched, $/ if $matched =~ /group/;
}
}

## use map function

@memberof = map {
if (/(?<=\=)(.+)/) {
my $matched = $1;
$matched, $/ if $matched =~ /group/;
}
} @memberof;

print @memberof;

[/CODE]

Hope this helps.

>
> TIA,
> --
> Groeten,
> natxo
>



--
Tim

2013-05-16T21:27:21Z
Re: map problems by Jim Gibson

From: Jim Gibson
On May 16, 2013, at 12:57 PM, Natxo Asenjo wrote:

> hi,
>
> in a ldap script where I get a list of values of a multivalued attribute like this:
>
> @memberof = qw( cn=group1,cn=xxx,dc=domain,dc=tld cn=group2,cn=xxx,d=domain,dc=tld etc etc) ;
>
> I would like to use map to convert the list of elements to
> @memberof = qw( group1 group2 group3 etc etc )
>
> This is the code I have tried to capture the first string after the first '=' in the $1 variable
>
> @memberof = map { s/^cn=(.*),.*$/$1/g; $_ } @memberof;
> for ( @memberof ) {
> print "[$_]" . " " ;
> }
>
> but this snippet strangely cuts the start and the end of every array element beginning and end so I get this:
>
> [group1,cn=xxx,dc=domain] [group2,cn=xxxx,dc=domain]
>
> so it is obviously not working. Is there a way to do this with map or do I just have to process the array in a for loop and fill a new array with the values? Just curious

The * in (.*) is "greedy", meaning the Perl regular expression engine will try to match as much as possible in each string after it finds the substring 'cn='. To make it "non-greedy", put a question mark after the quantifier: s/^cn=(.*?),/$1/

Note that the '.*$' characters ending your pattern are completely superfluous and will not affect the match or substitution in any way.

Another way to achieve the same results is to match all non-comma characters up to the first comma: s/^cn=([^,]*),/$1/

Also note that since $_ inside the map block is an alias to the array members, you are modifying the array members in place, and you do not need to assign the result to the original array. Since using map in void context can be confusing, many Perl programmers would write it this way:

s/^cn=([^,]*),/$1/ for @memberof;

Since I wouldn't normally want to modify the original array, I might do it this way, taking advantage of the fact that the match operator (m//) in list context returns a list of the captured matches, so no substitution is required:

my @newmemberof = map { m/^cn=([^,]*),/g } @memberof;

2013-05-16T21:14:47Z
map problems by Natxo Asenjo

From: Natxo Asenjo hi,

in a ldap script where I get a list of values of a multivalued attribute
like this:

@memberof = qw( cn=group1,cn=xxx,dc=domain,dc=tld
cn=group2,cn=xxx,d=domain,dc=tld etc etc) ;

I would like to use map to convert the list of elements to
@memberof = qw( group1 group2 group3 etc etc )

This is the code I have tried to capture the first string after the first
'=' in the $1 variable

@memberof = map { s/^cn=(.*),.*$/$1/g; $_ } @memberof;
for ( @memberof ) {
print "[$_]" . " " ;
}

but this snippet strangely cuts the start and the end of every array
element beginning and end so I get this:

[group1,cn=xxx,dc=domain] [group2,cn=xxxx,dc=domain]

so it is obviously not working. Is there a way to do this with map or do I
just have to process the array in a for loop and fill a new array with the
values? Just curious

TIA,
--
Groeten,
natxo

2013-05-16T19:58:11Z
Re: what's the problem with a system call by Manuel Reimer

From: Manuel Reimer Shlomi Fish wrote:
> What system() does (at least on UNIX-like OSes) is fork a child, call exec()
> with a new process and wait for the new child to terminate (plus some other
> stuff to get rid of misbehaviours).

... and if you call "system" with just one long string, then Perl opens the
system default shell between your script and the external application, you
wanted to start.

So wherever possible you should prefer to use:

system('somecommand', '--param1=somevalue', '--anotherparam');

and not:

system('somecommand --param1=somevalue --anotherparam');

The first one opens *two* processes (the shell and "somecommand") while the
second only opens one process and passes the arguments directly without any
shell in between.

Yours

Manuel

2013-05-16T15:50:18Z
Re: Spreadsheet::WriteExcel - multi-coloured text in cells by Dr.Ruud

From: Dr.Ruud On 15/05/2013 21:35, David Precious wrote:
> On Wed, 15 May 2013 10:34:02 +0100
> Gary Stainburn <gary.stainburn@ringways.co.uk> wrote:

>> Is it possible to write text cells where part of the string is
>> highlighted in red? If so, how can I do it?
>
> I'm fairly sure the format of a cell applies to the whole content of
> that cell - can you do what you're asking for in Excel or similar
> yourself? If not, then I very much doubt you can do it via
> Spreadsheet::WriteExcel.

There is cell formatting and there is text formatting.
Each character can basically have its own background-color,
foreground-color, font, font-weight, etc.

And beyond that, each cell can contain an object, like a Word-document.
But you don't need to go there to achieve what you want.

First find out how you would do it in its internal language (VB?),
and then port that.

--
Ruud

2013-05-16T11:27:33Z
Re: module versions by shawn wilson

From: shawn wilson On Wed, May 15, 2013 at 4:13 PM, Ron Bergin <rkb@i.frys.com> wrote:
> shawn wilson wrote:
>> I asked this in #perl-help and was told that by the time perl checked
>> the version, the module was already loaded - is there a way to check
>> the version without completely loading the module so that when one
>> failed, I could move on to another module of the same name whose
>> version might succeed?
>>
>
> Why not specify the minimum version number that your script requires in
> the use statement? If that version is not available, then what's the
> point of going forward?
>

See my test case - I do have a minimum version. The point in going
forward is that the minimum version IS met further along the path.

> If you don't want to do that, then you could use Module::Load::Conditional
> to test if the desired version is loadable.
>
> http://search.cpan.org/~bingos/Module-Load-Conditional-0.54/lib/Module/Load/Conditional.pm
>

That module might work if I manually cycle through single paths in
@INC and test. Though I'm not sure about the side effects of doing
this might be?

2013-05-15T20:47:50Z
Re: module versions by Ron Bergin

From: Ron Bergin shawn wilson wrote:
> I asked this in #perl-help and was told that by the time perl checked
> the version, the module was already loaded - is there a way to check
> the version without completely loading the module so that when one
> failed, I could move on to another module of the same name whose
> version might succeed?
>

Why not specify the minimum version number that your script requires in
the use statement? If that version is not available, then what's the
point of going forward?

If you don't want to do that, then you could use Module::Load::Conditional
to test if the desired version is loadable.

http://search.cpan.org/~bingos/Module-Load-Conditional-0.54/lib/Module/Load/Conditional.pm

--
Ron Bergin



2013-05-15T20:13:54Z
Re: module versions by Peter Eztta

From: Peter Eztta How about using ExtUtils::MakeMaker or Module::Build and checking for the required version at build time?

I suppose this doesn't address the desire to use a different version if the one you're looking for isn't present though...

Regards,

Peter H. Ezetta

On Wed, May 15, 2013 at 12:55:25PM -0700, shawn wilson wrote:
> On Wed, May 15, 2013 at 3:28 PM, Octavian Rasnita <orasnita@gmail.com> wrote:
> > From: "shawn wilson" <ag4ve.us@gmail.com>
> >
> >
> >
> >> I asked this in #perl-help and was told that by the time perl checked
> >> the version, the module was already loaded - is there a way to check
> >> the version without completely loading the module so that when one
> >> failed, I could move on to another module of the same name whose
> >> version might succeed?
> >>
> >> I attached a tar file with a test, let me know if nothing is seen.
> >>
> >
>
> >
> > This check is usually done at development time.
> > Is there a reason you can't check which version of the modules you need are
> > working with your code when you create the app?
> >
>
> No, I suppose i can just do perl -Ilib for development and the like.
> However, not checking that there is a satisfactory module version
> anywhere along the namespace seems to make things more brittle than
> they nead to be (and it's annoying me :) ).
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>

Confidentiality Notice: This e-mail may contain proprietary information some of which may be legally privileged. It is for the intended recipient(s) only. If you believe that it has been sent to you in error, please notify the sender by reply e-mail and delete the message. Any disclosure, copying, distribution or use of this information by someone other than the intended recipient(s) is prohibited and may be unlawful.

2013-05-15T20:00:44Z
Re: module versions by shawn wilson

From: shawn wilson On Wed, May 15, 2013 at 3:28 PM, Octavian Rasnita <orasnita@gmail.com> wrote:
> From: "shawn wilson" <ag4ve.us@gmail.com>
>
>
>
>> I asked this in #perl-help and was told that by the time perl checked
>> the version, the module was already loaded - is there a way to check
>> the version without completely loading the module so that when one
>> failed, I could move on to another module of the same name whose
>> version might succeed?
>>
>> I attached a tar file with a test, let me know if nothing is seen.
>>
>

>
> This check is usually done at development time.
> Is there a reason you can't check which version of the modules you need are
> working with your code when you create the app?
>

No, I suppose i can just do perl -Ilib for development and the like.
However, not checking that there is a satisfactory module version
anywhere along the namespace seems to make things more brittle than
they nead to be (and it's annoying me :) ).

2013-05-15T19:55:59Z
Re: Spreadsheet::WriteExcel - multi-coloured text in cells by David Precious

From: David Precious On Wed, 15 May 2013 10:34:02 +0100
Gary Stainburn <gary.stainburn@ringways.co.uk> wrote:

> Is it possible to write text cells where part of the string is
> highlighted in red? If so, how can I do it?

I'm fairly sure the format of a cell applies to the whole content of
that cell - can you do what you're asking for in Excel or similar
yourself? If not, then I very much doubt you can do it via
Spreadsheet::WriteExcel.



--
David Precious ("bigpresh") <davidp@preshweb.co.uk>
http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan www.preshweb.co.uk/github


2013-05-15T19:35:33Z
Re: module versions by Octavian Rasnita

From: Octavian Rasnita From: "shawn wilson" <ag4ve.us@gmail.com>


>I asked this in #perl-help and was told that by the time perl checked
> the version, the module was already loaded - is there a way to check
> the version without completely loading the module so that when one
> failed, I could move on to another module of the same name whose
> version might succeed?
>
> I attached a tar file with a test, let me know if nothing is seen.
>


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


> --



This check is usually done at development time.
Is there a reason you can't check which version of the modules you need are
working with your code when you create the app?

Octavian

2013-05-15T19:29:12Z
module versions by shawn wilson

From: shawn wilson I asked this in #perl-help and was told that by the time perl checked
the version, the module was already loaded - is there a way to check
the version without completely loading the module so that when one
failed, I could move on to another module of the same name whose
version might succeed?

I attached a tar file with a test, let me know if nothing is seen.

2013-05-15T15:57:30Z
Spreadsheet::WriteExcel - multi-coloured text in cells by Gary Stainburn

From: Gary Stainburn Hi folks

Is it possible to write text cells where part of the string is highlighted in
red? If so, how can I do it?

Gary

2013-05-15T09:34:24Z
Re: How do I update CPAN? by Peter Eztta

From: Peter Eztta From within the CPAN shell (i.e. issue the cpan command from the commandline) issue the two commands listed below:

install CPAN

Once that's done

reload CPAN

The rest should happen automagically for you.

Thanks,

Peter H. Ezetta

On Tue, May 14, 2013 at 03:05:59PM -0700, Sherman Willden wrote:
> I received the below message. Now what? I am not familiar with install.
>
> Thank you;
>
> Sherman
>
> Fetching with HTTP::Tiny:
> http://httpupdate35.cpanel.net/CPAN/modules/02packages.details.txt.gz
> Reading '/home/sherman/.cpan/sources/modules/02packages.details.txt.gz'
> Database was generated on Tue, 14 May 2013 21:41:05 GMT
> HTTP::Date not available
> ..............
> New CPAN.pm version (v2.00) available.
> [Currently running version is v1.9800]
> You might want to try
> install CPAN
> reload cpan
> to both upgrade CPAN.pm and run the new version without leaving
> the current session.

Confidentiality Notice: This e-mail may contain proprietary information some of which may be legally privileged. It is for the intended recipient(s) only. If you believe that it has been sent to you in error, please notify the sender by reply e-mail and delete the message. Any disclosure, copying, distribution or use of this information by someone other than the intended recipient(s) is prohibited and may be unlawful.

2013-05-14T22:13:31Z
How do I update CPAN? by Sherman Willden

From: Sherman Willden I received the below message. Now what? I am not familiar with install.

Thank you;

Sherman

Fetching with HTTP::Tiny:
http://httpupdate35.cpanel.net/CPAN/modules/02packages.details.txt.gz
Reading '/home/sherman/.cpan/sources/modules/02packages.details.txt.gz'
Database was generated on Tue, 14 May 2013 21:41:05 GMT
HTTP::Date not available
..............
New CPAN.pm version (v2.00) available.
[Currently running version is v1.9800]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.

2013-05-14T22:06:11Z
Re: what's the problem with a system call by Shlomi Fish <p>From: Shlomi Fish Hi xiaolan,<br/><br/>On Tue, 14 May 2013 18:51:51 +0800<br/>xiaolan &lt;practicalperl@gmail.com&gt; wrote:<br/><br/>&gt; Thanks all the answers.<br/>&gt; Shlomi long time no see :)<br/><br/>Yes. :-) I am available on IM:<br/><br/>http://www.shlomifish.org/me/contact-me/<br/><br/>&gt; <br/>&gt; Have another question that, what&#39;s the difference between the system call<br/>&gt; child process and the native forked child process?<br/>&gt; Does the child process of system call have the problems of receiving<br/>&gt; signals from the parent?<br/><br/>What system() does (at least on UNIX-like OSes) is fork a child, call exec()<br/>with a new process and wait for the new child to terminate (plus some other<br/>stuff to get rid of misbehaviours). A child process can still get a signal from<br/>every process of that user or that belongs to the user root (including the<br/>parent process, but not exclusively).<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; On Tue, May 14, 2013 at 5:16 PM, Shlomi Fish &lt;shlomif@shlomifish.org&gt; wrote:<br/>&gt; <br/>&gt; &gt; Hi Brian,<br/>&gt; &gt;<br/>&gt; &gt; thanks for replying well to xiaolan&rsquo;s question.<br/>&gt; &gt;<br/>&gt; &gt; Regards,<br/>&gt; &gt;<br/>&gt; &gt; Shlomi Fish<br/>&gt; &gt;<br/>&gt; &gt; --<br/>&gt; &gt; -----------------------------------------------------------------<br/>&gt; &gt; Shlomi Fish http://www.shlomifish.org/<br/>&gt; &gt; My Public Domain Photos - http://www.flickr.com/photos/shlomif/<br/>&gt; &gt;<br/>&gt; &gt; 95% of Programmers consider 95% of the code they did not write, in the<br/>&gt; &gt; bottom<br/>&gt; &gt; 5%.<br/>&gt; &gt;<br/>&gt; &gt; Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/>&gt; &gt;<br/>&gt; &gt; --<br/>&gt; &gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; &gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; &gt; http://learn.perl.org/<br/>&gt; &gt;<br/>&gt; &gt;<br/>&gt; &gt;<br/><br/><br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>Interview with Ben Collins-Sussman - http://shlom.in/sussman<br/><br/>Where they have burned books, they will end in burning human beings.<br/> &mdash; http://en.wikiquote.org/wiki/Heinrich_Heine<br/><br/>Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/></p> 2013-05-14T13:27:46Z Re: what's the problem with a system call by xiaolan <p>From: xiaolan Thanks all the answers.<br/>Shlomi long time no see :)<br/><br/>Have another question that, what&#39;s the difference between the system call<br/>child process and the native forked child process?<br/>Does the child process of system call have the problems of receiving<br/>signals from the parent?<br/><br/><br/><br/><br/>On Tue, May 14, 2013 at 5:16 PM, Shlomi Fish &lt;shlomif@shlomifish.org&gt; wrote:<br/><br/>&gt; Hi Brian,<br/>&gt;<br/>&gt; thanks for replying well to xiaolan&rsquo;s question.<br/>&gt;<br/>&gt; Regards,<br/>&gt;<br/>&gt; Shlomi Fish<br/>&gt;<br/>&gt; --<br/>&gt; -----------------------------------------------------------------<br/>&gt; Shlomi Fish http://www.shlomifish.org/<br/>&gt; My Public Domain Photos - http://www.flickr.com/photos/shlomif/<br/>&gt;<br/>&gt; 95% of Programmers consider 95% of the code they did not write, in the<br/>&gt; bottom<br/>&gt; 5%.<br/>&gt;<br/>&gt; Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/><br/></p> 2013-05-14T10:52:03Z Re: what's the problem with a system call by Shlomi Fish <p>From: Shlomi Fish Hi Brian,<br/><br/>thanks for replying well to xiaolan&rsquo;s question.<br/><br/>Regards,<br/><br/> Shlomi Fish<br/><br/>-- <br/>-----------------------------------------------------------------<br/>Shlomi Fish http://www.shlomifish.org/<br/>My Public Domain Photos - http://www.flickr.com/photos/shlomif/<br/><br/>95% of Programmers consider 95% of the code they did not write, in the bottom<br/>5%.<br/><br/>Please reply to list if it&#39;s a mailing list post - http://shlom.in/reply .<br/></p> 2013-05-14T09:16:49Z Re: what's the problem with a system call by Brian Fraser

From: Brian Fraser On Tue, May 14, 2013 at 12:35 AM, xiaolan <practicalperl@gmail.com> wrote:

> Hello,
>
> what's the disadvantage when calling a system command from Perl?
> i.e, system call to "rsync" rather than using the File::Rsync module.
> is it hard to control the signals between the caller process and the
> called system command?
>

The only real disadvantage is portability, perhaps speed (e.g. PerlIO::gzip
is faster than calling gzip itself, and if you're shelling out multiple
times, it'll generally be slower than simply using a module).
Additionally, if you're passing user-provided arguments to the outside
command and aren't doing things "properly", that is, you aren't using
IPC::Cmd, IPC::Run, or multi-arg open, you have a potential security hole
in your program.

But if what you're doing doesn't gain any advantages from increased
portability or security, there's nothing wrong with calling a system
command.

2013-05-14T07:00:10Z
Re: what's the problem with a system call by Luca Ferrari

From: Luca Ferrari On Tue, May 14, 2013 at 5:35 AM, xiaolan <practicalperl@gmail.com> wrote:
> Hello,
>
> what's the disadvantage when calling a system command from Perl?
> i.e, system call to "rsync" rather than using the File::Rsync module.
> is it hard to control the signals between the caller process and the called
> system command?


Well, usually using a module you have access to several things in a
Perl way, like for instance to the arguments to pass to the command as
an hash or an array. instead of a string. Moreover, the perl module
could have some workarounds to provide you better portability.

Luca

2013-05-14T06:15:17Z
what's the problem with a system call by xiaolan

From: xiaolan Hello,

what's the disadvantage when calling a system command from Perl?
i.e, system call to "rsync" rather than using the File::Rsync module.
is it hard to control the signals between the caller process and the called
system command?

Thanks.

2013-05-14T03:35:57Z
Re: script dies when Net::DNS resolve fails by Dr.Ruud

From: Dr.Ruud On 13/05/2013 18:08, David Precious wrote:

> The usual way to catch exceptions is with an eval block or Try::Tiny
> etc.
>
> Basic example:
>
> my $source_address = eval { $res->query(....); };
>
> if ($@) {
> # an error occurred - $@ will contain the message
> # do something appropriate here
> }

Testing $@ is basically always wrong, because it is a global variable
that can have changed value.

A rewrite:

my $source_address;
eval {
$source_address = $res->query(....);
1; # success
}
or do {
my $eval_error = $@ || 'Zombie Error';
...;
};

--
Ruud

2013-05-13T19:02:32Z
Re: script dies when Net::DNS resolve fails by David Precious

From: David Precious On Mon, 13 May 2013 08:53:13 -0700
Noah <noah-list@enabled.com> wrote:

> Hi list,
>
>
> When Net::DNS resolved name is not found my script dies. How can I
> allow for my script to continue on even if there is a failed DNS
> query?

The usual way to catch exceptions is with an eval block or Try::Tiny
etc.

Basic example:

my $source_address = eval { $res->query(....); };

if ($@) {
# an error occurred - $@ will contain the message
# do something appropriate here
}

However, $resolver->query() should, according to the docs, just return
undef if no answers are found, and your example output suggests that
execution gets to your "query failed:" warning in the else block, so
something else is happening after that - something which we have no
idea, since we're not seeing the whole code.


--
David Precious ("bigpresh") <davidp@preshweb.co.uk>
http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan www.preshweb.co.uk/github


2013-05-13T16:08:39Z
Re: script dies when Net::DNS resolve fails by Lawrence Statton

From: Lawrence Statton On 05/13/2013 10:53 AM, Noah wrote:
> When Net::DNS resolved name is not found my script dies. How can I
> allow for my script to continue on even if there is a failed DNS query?

Impossible to say -- you do not show enough to know what is happening
AFTER the block shown.

2013-05-13T16:00:31Z
script dies when Net::DNS resolve fails by Noah

From: Noah Hi list,


When Net::DNS resolved name is not found my script dies. How can I
allow for my script to continue on even if there is a failed DNS query?

Just cutting and pasting the relevant lines


use Net::DNS;
my $res = Net::DNS::Resolver->new;

my $v6_source_hostname = "<<<hostname_removed>>>";
my $source_ipaddress;
$source_ipaddress = $res->query("$v6_source_hostname", "AAAA");
if ($source_ipaddress) {
foreach my $rr (grep { $_->type eq 'AAAA' }
$source_ipaddress->answer) {
print $rr->address, "\n";
}
} else {
warn "query failed: ", $res->errorstring, "\n";
}




------ output -----

query failed: NXDOMAIN
lookup for <<<hostname_removed>>> failed:
<<script stops here>>>

Cheers

2013-05-13T15:53:31Z
Re: curiosity about the usage of my by Octavian Rasnita

From: Octavian Rasnita From: "Luca Ferrari" <fluca1978@infinito.it>


> On Thu, May 9, 2013 at 6:22 PM, Brandon McCaig <bamccaig@gmail.com> wrote:
>> It's a good trait for programmers to avoid waste, but not if it
>> comes at the expense of reliability, security, or robustness.
>> Using my() and our() takes very little effort and is well worth
>> the investment.
>
>
> Thanks for the explanation, but just for the sake of calrity, I was
> not asking this because of laziness, but because I believe that it is
> more error prone to rely on developers to use the right scoping (my,
> our, local) instead of automatically-proposing the "most-used" one.
>
> Luca
>


In that case it is not problem at all. Always use "my".

"our", "local" and "state" are much less used and if you need them, you also
know when you should use them.

Octavian

2013-05-12T05:13:28Z
Re: curiosity about the usage of my by Luca Ferrari

From: Luca Ferrari On Thu, May 9, 2013 at 6:22 PM, Brandon McCaig <bamccaig@gmail.com> wrote:
> It's a good trait for programmers to avoid waste, but not if it
> comes at the expense of reliability, security, or robustness.
> Using my() and our() takes very little effort and is well worth
> the investment.


Thanks for the explanation, but just for the sake of calrity, I was
not asking this because of laziness, but because I believe that it is
more error prone to rely on developers to use the right scoping (my,
our, local) instead of automatically-proposing the "most-used" one.

Luca

2013-05-11T18:22:37Z
Re: Lines written to a file are not contiguous by Sherman Willden

From: Sherman Willden Thank you all. I am not sure what $write and $read are for since I am just
now getting back to this. They may have been something I used then
discarded. I am surprised that I didn't get a notice that they are only
used once.

Sherman


On Fri, May 10, 2013 at 8:20 AM, Dr.Ruud <rvtol+usenet@isolution.nl> wrote:

> On 07/05/2013 20:00, Sherman Willden wrote:
>
> foreach my $file ( @docfiles ) {
>> my ( $write, $read );
>>
>
> What were they meant for?
>
> --
> Ruud
>
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>

2013-05-10T14:40:49Z
Re: Lines written to a file are not contiguous by Dr.Ruud

From: Dr.Ruud On 07/05/2013 20:00, Sherman Willden wrote:

> foreach my $file ( @docfiles ) {
> my ( $write, $read );

What were they meant for?

--
Ruud


2013-05-10T14:20:35Z
Re: Lines written to a file are not contiguous by David Christensen

From: David Christensen On 05/09/13 07:56, Sherman Willden wrote:
> Thank you, David. I thought about doing cat but I thought it would have to
> be a system call.

YW. TIMTOWTDI -- system calls or otherwise. More importantly, there is
more than one style of Perl programming. I find Perl especially useful
for "quick and dirty" shell scripts (e.g. instant gratification). And,
I keep the more useful ones around and improve them over time (e.g.
upgradability).


David

2013-05-10T04:27:25Z
Re: Lines written to a file are not contiguous by David Christensen

From: David Christensen Shlomi Fish wrote:
>>> Furthermore, many non-UNIX-like systems don't contain a cat command.

I wrote:
>> Thank God for electronics recycling. ;-)

On 05/08/13 23:50, Shlomi Fish wrote:
> What do you mean?

I meant that systems that are non-UNIX-like (or cannot be made Unix-like
with Linux, *BSD, etc.) should be decommissioned and recycled. Please
note the wink smiley.


David

2013-05-10T04:11:30Z