Labelling Radio Group Values

2011-01-12 Thread Stephen Allen
I have sucessfully created as Radio-group along the lines of @TiesArray = SSDArray($uniqueorgref); if (@TiesArray[0] ne ) { @TiesDesc = SSDDescArray($uniqueorgref); %TiesHash = @TiesDesc; $q = new CGI; print $q-start_form(-method=POST, -action=http://../cgi-bin/ViewQuote.pl;), $q-p(The

Re: Map function, what does it do?

2011-01-12 Thread Dr.Ruud
On 2011-01-11 11:44, Uri Guttman wrote: these are equivilent: my @out = grep /foo/, @in ; my @out = map { /foo/ ? $_ : () } @in ; Indeed equivalent. There is a difference though in what comes out of map and grep: perl -wle' my @in = 1 .. 4; print @in; ++$_ for

Re: Labelling Radio Group Values

2011-01-12 Thread Shlomi Fish
Hi Stephen, a few comments on your code: On Tuesday 11 Jan 2011 17:44:32 Stephen Allen wrote: I have sucessfully created as Radio-group along the lines of @TiesArray = SSDArray($uniqueorgref); Add: {{{ use strict; use warnings; }}} to the start of your script. Then declare all variables

Re: Labelling Radio Group Values

2011-01-12 Thread John W. Krahn
Stephen Allen wrote: I have sucessfully created as Radio-group along the lines of @TiesArray = SSDArray($uniqueorgref); if (@TiesArray[0] ne ) { You are testing a list against a scalar value, but fortunately your list has only one element. If you had warnings enabled then perl would have

Moving through tree's using LWP

2011-01-12 Thread Sean Murphy
Hi all. I posted previously on how to move in a tree by a node at a time by using HTML:TreeBuilder which is used with LWP. I wish to move by a single node and get the following info: tag of the current HTML element. Text of the HTML element. Attributes of the current HTML element. Of course,

Re: Moving through tree's using LWP

2011-01-12 Thread Shlomi Fish
Hi Sean, On Wednesday 12 Jan 2011 12:43:24 Sean Murphy wrote: Hi all. I posted previously on how to move in a tree by a node at a time by using HTML:TreeBuilder which is used with LWP. I wish to move by a single node and get the following info: tag of the current HTML element. Did the

Re: Moving through tree's using LWP

2011-01-12 Thread John Delacour
At 12:52 +0200 12/01/2011, Shlomi Fish wrote: http://search.cpan.org/~jfearn/HTML- Tree-4.1/lib/HTML/Element.pm#$h-%3Etag%28%29_or_$h-%3Etag%28%27tagname%27%29 (sorry for the broken link). Links won't break in proper mailers if you enclose them in

Re: Moving through tree's using LWP

2011-01-12 Thread Sean Murphy
Hi All. I have read the page and the O'rielly book on PWL. I must be thick or something. but when I dump the content of the web page into the treeBuilder via a scaler. Then I try and print the tag. I get: HTML::Element=HASH(0x41b1074)-Tag ( ) Below is the code extract. I have included the

Re: Moving through tree's using LWP

2011-01-12 Thread Jim Gibson
At 11:05 PM +1100 1/12/11, Sean Murphy wrote: Hi All. I have read the page and the O'rielly book on PWL. I must be thick or something. but when I dump the content of the web page into the treeBuilder via a scaler. Then I try and print the tag. I get: HTML::Element=HASH(0x41b1074)-Tag ( )

Re: Map function, what does it do?

2011-01-12 Thread Uri Guttman
R == Ruud rvtol+use...@isolution.nl writes: R On 2011-01-11 11:44, Uri Guttman wrote: these are equivilent: my @out = grep /foo/, @in ; my @out = map { /foo/ ? $_ : () } @in ; R Indeed equivalent. There is a difference though R in what comes out of map and grep: R perl

OT: Map function, what does it do?

2011-01-12 Thread shawn wilson
On Jan 12, 2011 12:10 PM, Uri Guttman u...@stemsystems.com wrote: R == Ruud rvtol+use...@isolution.nlrvtol%2buse...@isolution.nl writes: R On 2011-01-11 11:44, Uri Guttman wrote: these are equivilent: my @out = grep /foo/, @in ; my @out = map { /foo/ ? $_ : () } @in ; R

Re: OT: Map function, what does it do?

2011-01-12 Thread Rob Dixon
On 12/01/2011 17:51, shawn wilson wrote: On Jan 12, 2011 12:10 PM, Uri Guttmanu...@stemsystems.com wrote: R == Ruudrvtol+use...@isolution.nlrvtol%2buse...@isolution.nl writes: R On 2011-01-11 11:44, Uri Guttman wrote: these are equivilent: my @out = grep /foo/, @in ; my

Re: Labelling Radio Group Values

2011-01-12 Thread Stephen Allen
Hi Shlomi Thanks for your comments. In fact, the problem was enirely my own fault and did not exihibit in the code I published. More specifically the hash I created in %TiesHash did not use the correct Key - hence it didn't work. Get that right and the rest falls into place nicely. Stephen

Re: Labelling Radio Group Values

2011-01-12 Thread Dr.Ruud
On 2011-01-12 10:44, Shlomi Fish wrote: Add: {{{ use strict; use warnings; }}} to the start of your script. That adds 3 ENTERs and LEAVEs for no good reason. The code is not in a tight loop, so that doesn't matter much, but there is more: perl -MData::Dumper -wle ' $x = 1; {{{

Re: Map function, what does it do?

2011-01-12 Thread Dr.Ruud
On 2011-01-12 18:08, Uri Guttman wrote: Ruud writes: On 2011-01-11 11:44, Uri Guttman wrote: these are equivilent: my @out = grep /foo/, @in ; my @out = map { /foo/ ? $_ : () } @in ; Indeed equivalent. There is a difference though in what comes out of map and grep: perl -wle'

Re: Moving through tree's using LWP

2011-01-12 Thread Rob Dixon
On 12/01/2011 16:03, Jim Gibson wrote: At 11:05 PM +1100 1/12/11, Sean Murphy wrote: Hi All. I have read the page and the O'rielly book on PWL. I must be thick or something. but when I dump the content of the web page into the treeBuilder via a scaler. Then I try and print the tag. I get:

Return value from function

2011-01-12 Thread Parag Kalra
Hi, On shell, successful command returns exit status of 0. As a best practice what status value shall a Perl function return. Going by the fact that Perl function returns the value of last command in it, I think function should return non-zero for a success. Cheers, Parag -- To unsubscribe,

Re: Map function, what does it do?

2011-01-12 Thread Uri Guttman
R == Ruud rvtol+use...@isolution.nl writes: R On 2011-01-12 18:08, Uri Guttman wrote: Ruud writes: On 2011-01-11 11:44, Uri Guttman wrote: these are equivilent: my @out = grep /foo/, @in ; my @out = map { /foo/ ? $_ : () } @in ; Indeed equivalent. There is a

Re: Labelling Radio Group Values

2011-01-12 Thread Uri Guttman
R == Ruud rvtol+use...@isolution.nl writes: R On 2011-01-12 10:44, Shlomi Fish wrote: Add: {{{ use strict; use warnings; }}} to the start of your script. R That adds 3 ENTERs and LEAVEs for no good reason. The code is not in a R tight loop, so that doesn't

Re: Return value from function

2011-01-12 Thread Uri Guttman
PK == Parag Kalra paragka...@gmail.com writes: PK Hi, PK On shell, successful command returns exit status of 0. PK As a best practice what status value shall a Perl function return. a shell command is NOT a function call. comparing them is useless. PK Going by the fact that Perl

doubt in substring

2011-01-12 Thread Sunita Rani Pradhan
Hi All I have a string as; $str = the cat sat on the mat . How the following command works substr($str , 4, -4) on the string ? What should be the output? Thanks Sunita

Re: doubt in substring

2011-01-12 Thread ashwin ts
the output will be cat sat on the all the characters in the string $str except four characters from the left and right will be displayed... Regards Ashwin Thayyullathil Surendran On Thu, Jan 13, 2011 at 9:57 AM, Sunita Rani Pradhan sunita.prad...@altair.com wrote: Hi All I

Re: Return value from function

2011-01-12 Thread Octavian Rasnita
From: Parag Kalra paragka...@gmail.com Hi, On shell, successful command returns exit status of 0. As a best practice what status value shall a Perl function return. Going by the fact that Perl function returns the value of last command in it, I think function should return non-zero for a

Re: Return value from function

2011-01-12 Thread Uri Guttman
OR == Octavian Rasnita orasn...@gmail.com writes: OR Perl doesn't use functions, but subroutines or methods, so they don't don't say that. subs and functions are just synonyms. it is how you use the sub that changes its meaning. OR need to return something if you don't want them to return

Re: Return value from function

2011-01-12 Thread shawn wilson
subs in perl ALWAYS return something, either the value from return or the last evaluated expression. What do you mean by this? sub nothing { my $something = 5; if ( $something == 5) {} } ... will return 'undef' and not 5 or anything else, right?

Re: Return value from function

2011-01-12 Thread John W. Krahn
Octavian Rasnita wrote: From: Parag Kalra paragka...@gmail.com On shell, successful command returns exit status of 0. As a best practice what status value shall a Perl function return. Going by the fact that Perl function returns the value of last command in it, I think function should

Re: doubt in substring

2011-01-12 Thread C.DeRykus
On Jan 12, 8:27 pm, sunita.prad...@altair.com (Sunita Rani Pradhan) wrote: Hi All             I have a string as; $str =  the cat sat on the mat . How the following command works substr($str , 4, -4)  on the string ? What should be the output? See: perldoc -f substr Check the docs first

Re: Return value from function

2011-01-12 Thread Uri Guttman
sw == shawn wilson ag4ve...@gmail.com writes: subs in perl ALWAYS return something, either the value from return or the last evaluated expression. sw What do you mean by this? sw sub nothing { sw my $something = 5; sw if ( $something == 5) {} sw } sw ... will return 'undef'

Re: Return value from function

2011-01-12 Thread shawn wilson
On Jan 13, 2011 2:24 AM, Uri Guttman u...@stemsystems.com wrote: sw == shawn wilson ag4ve...@gmail.com writes: subs in perl ALWAYS return something, either the value from return or the last evaluated expression. sw What do you mean by this? sw sub nothing { sw my $something = 5;

Re: Return value from function

2011-01-12 Thread Uri Guttman
sw == shawn wilson ag4ve...@gmail.com writes: sw I dig what you're saying about always using return. However I sw don't (have never used / seen) a case where a sub returns last sw expression. An example maybe? the classic case which is used in the constant pragma is: sub FOO() {