On Mon, Aug 18, 2014 at 06:07:59AM -0700, John SJ Anderson wrote:
On Mon, Aug 18, 2014 at 1:38 AM, Paul Johnson wrote:
> On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote:
>> which one is the better way to return the list content? And if the
>> method is an instance method?
To expand
On Wed, Sep 10, 2014 at 4:18 AM, Rob Dixon wrote:
> On 09/09/2014 02:20, Ken Peng wrote:
>>
>>
>>> The second option creates the same array and populates it, but then
>>> copies it to another anonymous array, deletes the first array, and
>>> returns a reference to the copy.
>>
>>
>> Since this is
On 09/09/2014 02:20, Ken Peng wrote:
The second option creates the same array and populates it, but then
copies it to another anonymous array, deletes the first array, and
returns a reference to the copy.
Since this is a shadow copy, I don't think the first array will be
deleted completely. I
Since this is a shadow copy, I don't think the first array will be
deleted completely. Isn't it?
The second option creates the same array and populates it, but then
copies it to another anonymous array, deletes the first array, and
returns a reference to the copy.
--
To unsubscribe, e-mail:
On 18/08/2014 09:17, Ken Peng wrote:
sub myfunc {
my @x=(1,2,3);
return \@x;
}
# or,
sub myfunc {
my @x=(1,2,3);
return [@x];
}
which one is the better way to return the list content? And if the
method is an instance method?
The first version of the subroutine is the best choice
On Tue, 09 Sep 2014 00:13:13 +0200
lee wrote:
> Shawn H Corey writes:
>
> > On Mon, 18 Aug 2014 16:17:53 +0800
> > Ken Peng wrote:
> >
> >> sub myfunc {
> >> my @x=(1,2,3);
> >> return \@x;
> >> }
> >>
> >> # or,
> >>
> >> sub myfunc {
> >> my @x=(1,2,3);
> >> return [@x];
> >> }
> >
On Sep 8, 2014, at 3:13 PM, lee wrote:
> Shawn H Corey writes:
>
>> On Mon, 18 Aug 2014 16:17:53 +0800
>> Ken Peng wrote:
>>
>>> sub myfunc {
>>> my @x=(1,2,3);
>>> return \@x;
>>> }
>>>
>>> # or,
>>>
>>> sub myfunc {
>>> my @x=(1,2,3);
>>> return [@x];
>>> }
>>
>> # or
>>
>> sub myfu
Shawn H Corey writes:
> On Mon, 18 Aug 2014 16:17:53 +0800
> Ken Peng wrote:
>
>> sub myfunc {
>> my @x=(1,2,3);
>> return \@x;
>> }
>>
>> # or,
>>
>> sub myfunc {
>> my @x=(1,2,3);
>> return [@x];
>> }
>
> # or
>
> sub myfunc {
> return [ 1, 2, 3 ];
> }
Is there a difference to
su
On Mon, Aug 18, 2014 at 1:38 AM, Paul Johnson wrote:
> On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote:
>> which one is the better way to return the list content? And if the
>> method is an instance method?
>
> Functionally, the two are identical. The first is returning a reference
> to
On Mon, 18 Aug 2014 16:17:53 +0800
Ken Peng wrote:
> sub myfunc {
> my @x=(1,2,3);
> return \@x;
> }
>
> # or,
>
> sub myfunc {
> my @x=(1,2,3);
> return [@x];
> }
# or
sub myfunc {
return [ 1, 2, 3 ];
}
--
Don't stop where the ink does.
Shawn
--
To unsubscribe, e-mail:
On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote:
> Hello,
>
> sub myfunc {
> my @x=(1,2,3);
> return \@x;
> }
>
> # or,
>
> sub myfunc {
> my @x=(1,2,3);
> return [@x];
> }
>
> which one is the better way to return the list content? And if the
> method is an instance method?
F
Am 04.03.2014 00:35, schrieb shawn wilson:
So, when I do this:
my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0];
I get a full line and not just the capture:
# ARIN WHOIS data and services are subject to the Terms of Use
When I do this:
my $src = (grep {s/.*(ARIN|APNIC).*(\n)?/$1/} @r
On 2014-03-04 00:35, shawn wilson wrote:
So, when I do this:
my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0];
I get a full line and not just the capture:
# ARIN WHOIS data and services are subject to the Terms of Use
First understand what you coded:
grep() is a filter: it only passes
On 03/03/2014 23:35, shawn wilson wrote:
So, when I do this:
my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0];
I get a full line and not just the capture:
# ARIN WHOIS data and services are subject to the Terms of Use
When I do this:
my $src = (grep {s/.*(ARIN|APNIC).*(\n)?/$1/} @ret
On Mar 4, 2014 9:46 AM, "Shawn H Corey" wrote:
>
> On Tue, 4 Mar 2014 09:24:53 -0500
> shawn wilson wrote:
>
> > my $src = (map {s/.*(ARIN|APNIC).*(?:\n)?/$1/r} @ret)[0];
>
> You do realize this is process the whole array and then throwing out
> all but the first? And it has the side effect of mo
On Tue, 4 Mar 2014 09:24:53 -0500
shawn wilson wrote:
> my $src = (map {s/.*(ARIN|APNIC).*(?:\n)?/$1/r} @ret)[0];
You do realize this is process the whole array and then throwing out
all but the first? And it has the side effect of modifying the array?
--
Don't stop where the ink does.
It needs to be grep as a map would return the first line no matter
what - not what I want. Also, this doesn't work:
sub whois
{
my ($whois) = @_;
my $sock = IO::Socket::INET->new(
PeerAddr=>$whois,
PeerPort=>'43',
Timeout=>'60',
);
return undef unless (defined($sock));
$soc
On Mon, 3 Mar 2014 18:35:55 -0500
shawn wilson wrote:
> So, when I do this:
> my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0];
> I get a full line and not just the capture:
> # ARIN WHOIS data and services are subject to the Terms of Use
If you can't figure out what's wrong, neither wil
I think you want to use 'map' instead of grep.
HTH, Ken
On Mon, Mar 3, 2014 at 6:35 PM, shawn wilson wrote:
> So, when I do this:
> my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0];
> I get a full line and not just the capture:
> # ARIN WHOIS data and services are subject to the Terms o
On Fri, Mar 8, 2013 at 2:49 AM, Dr.Ruud wrote:
> On 2013-03-07 10:21, WFB wrote:
>
>> waitpid($pid, 0);
>> close($trexe);
>> my $tr_ret = ($?>>8);
>
>
> Never postpone the reading of a global variable,
> just snapshot it as early as possible.
>
> my $child = waitpid $pid, 0;
> my $child_error
On 8 March 2013 11:49, Dr.Ruud wrote:
> On 2013-03-07 10:21, WFB wrote:
>
> waitpid($pid, 0);
>> close($trexe);
>> my $tr_ret = ($?>>8);
>>
>
> Never postpone the reading of a global variable,
> just snapshot it as early as possible.
>
> my $child = waitpid $pid, 0;
> my $child_error = $?;
On 2013-03-07 10:21, WFB wrote:
waitpid($pid, 0);
close($trexe);
my $tr_ret = ($?>>8);
Never postpone the reading of a global variable,
just snapshot it as early as possible.
my $child = waitpid $pid, 0;
my $child_error = $?; # snapshot a global
$child == -1 and die "No child with pid
On Thu, Mar 07, 2013 at 02:24:58PM -0800, John W. Krahn wrote:
> Or, instead of the three argument open, use the list option and you
> won't need quotes:
>
> my $pid = open my $trexe, '-|', $tr, $tr_params
> or die "Could not start TestRunner. $!";
Good catch. :) I didn't think that o
Brandon McCaig wrote:
On Thu, Mar 07, 2013 at 10:21:40AM +0100, WFB wrote:
Hi, List,
Hello,
To test our software I use perl to start it several times. My
perl script gather some information and start then the program
with different parameters.
It works very well, but I have a problem with t
On 7 March 2013 16:05, Brandon McCaig wrote:
> On Thu, Mar 07, 2013 at 10:21:40AM +0100, WFB wrote:
> > Hi, List,
>
> Hello,
>
> > To test our software I use perl to start it several times. My
> > perl script gather some information and start then the program
> > with different parameters.
> >
>
On Thu, Mar 07, 2013 at 10:05:56AM -0500, Brandon McCaig wrote:
> Apparently Windows supports 32-bit integers... The Web suggests
> that if you want to get full 32-bit integers on Windows then you
> should use the Win32::Process module instead of open. It's not
> portable, but at least it will do w
On Thu, Mar 07, 2013 at 10:21:40AM +0100, WFB wrote:
> Hi, List,
Hello,
> To test our software I use perl to start it several times. My
> perl script gather some information and start then the program
> with different parameters.
>
> It works very well, but I have a problem with the return value
Hi shawn,
On Wed, Nov 21, 2012 at 11:48 PM, shawn wilson wrote:
> how do i return something when i've got a long regex and one of the
> captures is empty?
>
> $_ = '"435" "" "634";
> my ($one, $two, $three)= /^
>"(\d+)"\
>"(\d+)"\
>"(\d+)"
> /x;
>
You can do like so:
$_ = '"435
On Wed, 21 Nov 2012 17:48:00 -0500
shawn wilson wrote:
> how do i return something when i've got a long regex and one of the
> captures is empty?
>
> $_ = '"435" "" "634";
> my ($one, $two, $three)= /^
>"(\d+)"\
>"(\d+)"\
>"(\d+)"
> /x;
>
First, this contains a syntax error. Please
Instead of + use *. * means 0 or more while + means 1 or more
On Nov 21, 2012 4:51 PM, "shawn wilson" wrote:
> how do i return something when i've got a long regex and one of the
> captures is empty?
>
> $_ = '"435" "" "634";
> my ($one, $two, $three)= /^
>"(\d+)"\
>"(\d+)"\
>"(\d+)"
On Thu, Jun 07, 2012 at 16:59:58 -0400 , Shawn H Corey wrote:
> On 12-06-07 04:48 PM, Chris Stinemetz wrote:
> >sub getMarketCells {
> > my $val = shift;
> > foreach my $k ( keys %apcHash ) {
> > my($start, $end) = @{$apcHash{$k}}{qw/start end/};
> > return($start, $end) if $val eq $k;
On Thu, Jun 7, 2012 at 3:48 PM, Chris Stinemetz wrote:
> sub getMarketCells {
> my $val = shift;
> foreach my $k ( keys %apcHash ) {
>my($start, $end) = @{$apcHash{$k}}{qw/start end/};
>return($start, $end) if $val eq $k;
> }
> return "";
> }
>
Completely unrelated to your question...
> You may be returning two values, but you're only catching one.
>
> Try
>
> my( $start, $end ) = getMarketCells( $apc );
>
>
> chrs,
> john.
You are correct. Thank you very much!
Chris
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@per
On 12-06-07 04:48 PM, Chris Stinemetz wrote:
sub getMarketCells {
my $val = shift;
foreach my $k ( keys %apcHash ) {
my($start, $end) = @{$apcHash{$k}}{qw/start end/};
return($start, $end) if $val eq $k;
}
return "";
return;
}
A return with any argument will return
On Jun 7, 2012, at 1:48 PM, Chris Stinemetz wrote:
> Not sure what I am doing wrong but my subroutine is only returning the
> value on varible. I would like it to return both $end and $start for
> the correct parameter I am passing.
If you want to return two or more values from a subroutine, the
On Thursday, June 7, 2012 at 4:48 PM, Chris Stinemetz wrote:
> my $test = getMarketCells($apc);
>
You may be returning two values, but you're only catching one.
Try
my( $start, $end ) = getMarketCells( $apc );
chrs,
john.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For addi
> "BM" == Brandon McCaig writes:
BM> On Thu, Feb 10, 2011 at 10:20 PM, Uri Guttman
wrote:
>> this is all well documented. and i posted an explanation earlier in the
>> thread.
BM> I didn't realize this was an existing thread. In Google Mail it
BM> appeared as a new thread.
>>
On Thu, Feb 10, 2011 at 10:20 PM, Uri Guttman wrote:
> this is all well documented. and i posted an explanation earlier in the
> thread.
I didn't realize this was an existing thread. In Google Mail it
appeared as a new thread.
> BM> sub test3
> BM> {
> BM> my @empty_array = ();
>
> BM>
> "BM" == Brandon McCaig writes:
BM> I would have guessed an empty list, but the best way to find out is to
BM> check. :) According to my tests, it's returning according to context:
this is all well documented. and i posted an explanation earlier in the
thread.
BM> sub test1
BM> {
2011/2/10 terry peng :
> does "return ()" mean return an empty list, or just mean "return" since "()"
> is optional in Perl?
I would have guessed an empty list, but the best way to find out is to
check. :) According to my tests, it's returning according to context:
#!/usr/bin/env perl
use stric
At 02:34 -0500 13/01/2011, shawn wilson wrote:
I dig what you're saying about always using return. However I don't (have
never used / seen) a case where a sub returns last expression. An example
maybe?
#!/usr/local/bin/perl
use strict;
use feature qw(say);
say &SUB();
sub SUB {
my $word = "
On 2011-01-13 08:18, John W. Krahn wrote:
If you want to return a false value it is usually better to use return
with no value:
return;
I prefer subs to normally return a single scalar, which can be a direct
value like undef, or a reference to a more complex data structure, etc.
If you all
On 2011-01-12 22:23, Parag Kalra wrote:
On shell, successful command returns exit status of 0.
As a best practice what status value shall a Perl function return.
A function can return other kinds of values too.
Going by the fact that Perl function returns the value of last command
in it, I
> "sw" == shawn wilson 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() { 'foo' }
On Jan 13, 2011 2:24 AM, "Uri Guttman" wrote:
>
> > "sw" == shawn wilson 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 ( $
> "sw" == shawn wilson 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' an
Octavian Rasnita wrote:
From: "Parag Kalra"
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 su
> 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?
> "OR" == Octavian Rasnita 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 something.
From: "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
> "PK" == Parag Kalra 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 function return
On Wednesday 26 May 2010 18:16:18 Brandon McCaig wrote:
> On Wed, May 26, 2010 at 9:43 AM, Andros Zuna wrote:
> > But how could I test if the command executes if the return value changes?
> > ...is there a unix command or other way that generates random/different
> > return values??
>
> The follo
On Wed, May 26, 2010 at 9:43 AM, Andros Zuna wrote:
> But how could I test if the command executes if the return value changes?
> ...is there a unix command or other way that generates random/different
> return values??
>
The following C program will return a pseudo-random value every time it's r
On May 26, 2010, at 9:43 AM, Andros Zuna wrote:
> Ok, I see, so the code should look somehow like this:
>
> #!
> /usr/bin/perl
>
> use
> warnings;
> use
> strict;
>
>
> $command = "ls
> -l";
^^ Strongly suggest you use full paths here.
>
> while (system($command) != 0)
> {
>my
> $c++
>
Ok, I see, so the code should look somehow like this:
#!
/usr/bin/perl
use
warnings;
use
strict;
$command = "ls
-l";
while (system($command) != 0)
{
my
$c++
}
But how could I test if the command executes if the return value changes?
...is there a unix command or other way that generates
On May 26, 2010, at 9:03 AM, Andros Zuna wrote:
> Hi,
> I did some few changes:
>
> #!
> /usr/bin/perl
>
> # use
> warnings;
> # use
> strict;
>
>
> $command = `ls
> -l`;
>
Looks like you're using backticks. Backticks actually causes perl to execute
the command inside them and return the o
Hi,
I did some few changes:
#!
/usr/bin/perl
# use
warnings;
# use
strict;
$command = `ls
-l`;
if (system($command) == 0)
{
}
elsif(system($command) != 0)
{
print "Failed to execute:
$?\n";
my
$c++
}
But I'm still not getting it right, this is my error output:
root@/user$ ./script.
while (system($command) != 0) {
}
Bob McConnell
-Original Message-
From: Andros Zuna [mailto:andros.z...@gmail.com]
Sent: Wednesday, May 26, 2010 8:57 AM
To: Chaitanya Yanamadala
Cc: beginners@perl.org
Subject: Re: Return value = 0
Hi,
Thank you for the tip Chaitanya
On Wednesday 26 May 2010 15:49:37 Andros Zuna wrote:
> Hi!
> I am trying to write a perl code that will retry the same command over
> and over again until the return value is 0.
> This is what I got for now:
>
> #! /usr/bin/perl
> use warnings;
> use strict;
>
> $command = 'ls -l';
>
> if (syste
Hi,
Thank you for the tip Chaitanya, but I still don't thik my script is working
correct!?
2010/5/26 Chaitanya Yanamadala
> u should give it as
> $command=`ls -la`;
>
>
> use the key on the top of TAB button with shift..
> *
> Chaitanya
>
> "A man can get discouraged many times but he is not a
u should give it as
$command=`ls -la`;
use the key on the top of TAB button with shift..
*
Chaitanya
"A man can get discouraged many times but he is not a failure until he stops
trying..."
"The difference between 'involvement' and 'commitment' is like an
eggs-and-ham breakfast: the chicken was
2009/12/3 Peter Scott :
> On Mon, 30 Nov 2009 14:36:44 +, Dermot wrote:
Does it have a name?
>
> It's called the Orcish Maneuver ("or-cache"). See: "Effective Perl
> Programming", Hall with Schwartz.
Thank you.
Interesting there's a edition published in 1998 by Hall/Schwartz and
an edition
On Mon, 30 Nov 2009 14:36:44 +, Dermot wrote:
> sub get_cached_val_or_lookup {
> my $val = shift;
> return $cache{$val} ||= do {
Could be more effective in 5.10 with
return $cache{$val} //= do {
to avoid repeating the fetch for values that are false.
> One more question If I can.
> "Dermot" == Dermot writes:
Dermot> One more question If I can. Chas pointed me to
Dermot> http://perldesignpatterns.com/?PerlDesignPatterns some time ago. I
Dermot> suspect that the above is a form of design pattern. Does it have a
Dermot> name? Is there a reference to it at
Dermot> http:/
2009/11/24 Randal L. Schwartz :
>> "Dermot" == Dermot writes:
>
>
> ...
>
> Dermot> I guess the question is: Will the declaration of our %cache within a
> Dermot> function-orientated sub-routine render it always uninitialized?
>
> I believe what you are seeing is that %cache is per-child, so
> "Dermot" == Dermot writes:
Dermot> It' is perl, v5.6.2, on a modperl 1,
...
Dermot> I guess the question is: Will the declaration of our %cache within a
Dermot> function-orientated sub-routine render it always uninitialized?
I believe what you are seeing is that %cache is per-child, so
2009/11/18 Randal L. Schwartz :
>
> I prefer a pattern that looks more like this:
>
> sub expensive_to_calculate {
>
> my $self = shift;
> my $input = shift; # cache on this scalar
>
> our %cache_for_expensive_to_calculate;
> return $cache_for_expensive_to_calculate{$input} ||= do {
> expens
> "Steve" == Steve Bertrand writes:
Steve> Out of curiosity, if it's gone this far, is it fair for me to recommend
Steve> reading Mr. Dominus' Memoizing chapter in Higher-Order Perl
Steve> (http://hop.perl.plover.com/)?
Yes, and as a simple verison of that, see Memoize in the CPAN.
--
Rand
Randal L. Schwartz wrote:
> I prefer a pattern that looks more like this:
>
> sub expensive_to_calculate {
>
> my $self = shift;
> my $input = shift; # cache on this scalar
>
> our %cache_for_expensive_to_calculate;
> return $cache_for_expensive_to_calculate{$input} ||= do {
> expens
I prefer a pattern that looks more like this:
sub expensive_to_calculate {
my $self = shift;
my $input = shift; # cache on this scalar
our %cache_for_expensive_to_calculate;
return $cache_for_expensive_to_calculate{$input} ||= do {
expensive calculation here;
more things based o
Ming Qian wrote:
I encounter some code as follows, and can not understand. Would someone help
me?
use constant 'cache_result' => {};
sub abc {
...
return cache_result->{$self->name};
}
What does this mean?
perl -e'
use constant cache_result => {};
> "JP" == Jeff Pang writes:
JP> On Nov 15, 2009, Uri Guttman wrote:
> "PK" == Parag Kalra writes:
>> and yes, that is declaring a constant. you can tell it is a hash as it
>> is initialized to a hash reference. it makes little sense to me why you
>> would declare such a beast
On Nov 15, 2009, Uri Guttman wrote:
> "PK" == Parag Kalra writes:
>and yes, that is declaring a constant. you can tell it is a hash as it
>is initialized to a hash reference. it makes little sense to me why you
>would declare such a beast as the reference can have its contents
>altered a
Thanks Uri and Parag.
After reading your comments and taking a coffee, I understand it.
:)
Thanks,
Bruce.
On Sun, Nov 15, 2009 at 12:18 AM, Uri Guttman wrote:
> > "PK" == Parag Kalra writes:
>
> first off, as a newbie here, please learn to bottom post. reading is
> done top down so put
> "PK" == Parag Kalra writes:
first off, as a newbie here, please learn to bottom post. reading is
done top down so put your comments BELOW the quoted and edited post you
are commenting about.
PK> Even I am a beginer but let me throw some pointers. Experienced
PK> users kindly correct me
Hmmm.
Even I am a beginer but let me throw some pointers. Experienced users kindly
correct me if I am wrong
First line is declaring a constant. What I could not get is that what
constant are we trying to declare i.e a variable, hash or a reference.
Read more - perldoc constant
And then t
On Sat, Nov 29, 2008 at 11:32, John J. Foster
<[EMAIL PROTECTED]> wrote:
> Hi again,
>
> Is it possible to modify the following script to return a list of
> available fields? I'm trying to query my address at fastmail.fm and
> would like to display as much info as possible.
snip
Replace
i
OK - let's try the script this time!
http://bsdconsulting.no/tools/mutt-ldap.pl
On Sat, Nov 29, 2008 at 09:32:32AM -0700, John J. Foster wrote:
> Hi again,
>
> Is it possible to modify the following script to return a list of
> available fields? I'm trying to query my address at fastmail.fm and
Rob Dixon wrote:
>
> You can pass single hashes to and from subroutines as a simple list. So you
> successfully passed in %db_del, for instance, but if you need to keep two or
> more hashes separate you must pass them by reference.
I should also have mentioned that a hash won't stay sorted, so yo
Pedro Soto wrote:
> Hi,
> I am trying to write script to retrieve info from a file that looks like:
>
> col1 col2col3
> A5 10
> A5 10
> A5 11
> A6 8
> A7 9
> B5 8
> B6 9
> what
On Fri, Aug 29, 2008 at 5:10 PM, Pedro Soto <[EMAIL PROTECTED]> wrote:
> Hi,
> I am trying to write script to retrieve info from a file that looks like:
>
> col1 col2col3
> A5 10
> A5 10
> A5 11
> A6 8
> A7 9
>
El Friday 29 August 2008 13:40:04 Pedro Soto va escriure:
> Hi,
> I am trying to write script to retrieve info from a file that looks like:
>
> col1 col2col3
> A5 10
> A5 10
> A5 11
> A6 8
> A7 9
> B5
On Jan 24, 10:12 am, [EMAIL PROTECTED] (Tom Phoenix) wrote:
> On Jan 24, 2008 9:07 AM, <[EMAIL PROTECTED]> wrote:
>
> > I'd like to get the number of keys in hash of hashes. I know that I
> > can do something like $count = keys( %myHash ), but how would I go
> > about finding the number of keys i
On Jan 24, 2008 9:07 AM, <[EMAIL PROTECTED]> wrote:
> I'd like to get the number of keys in hash of hashes. I know that I
> can do something like $count = keys( %myHash ), but how would I go
> about finding the number of keys in a sub-hash?
my $count = keys %{ $sub_hash_reference };
You can
The hash was not suggested because of efficiency.
I suggested a hash because they require less coding and make your life
so much easier.
Less coding, less room for errors, nicer code, etc.
Not to mention that filling a hash from a textfile is trivial, so you
can move the associations into a file.
Johnson, Reginald (GTI) wrote:
I don't see what I'm doing wrong here. I just want to compare the value
of $_ and return the indicated string if there is a match.
#!/usr/bin/perl
use strict;
use warnings;
my $temp_proc;
my $mnt_proc = "AVI";
$temp_proc = convert_mnt_proc($mnt_proc);
#
EMAIL PROTECTED] On Behalf Of yitzle
Sent: Wednesday, April 18, 2007 10:24 AM
To: Johnson, Reginald (GTI)
Cc: beginners@perl.org
Subject: Re: Return value from subroutine
> return = "Audit Volume";
You have
return = "thingy";
You want
return &q
On 4/18/07, Johnson, Reginald (GTI) <[EMAIL PROTECTED]> wrote:
if ($_ eq /AVI/) {
return = "Audit Volume";
}
Perl's return operator isn't a variable you assign to. Maybe you want this?
return "Audit Volume"; #
2007/4/18, Johnson, Reginald (GTI) <[EMAIL PROTECTED]>:
if ($_ eq /AVI/) {
Above is not right.
Maybe '$_ =~ /AVI/' or ' $_ eq "AVI" '?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
return = "Audit Volume";
You have
return = "thingy";
You want
return "thingy";
if ($_ eq /AVI/) {
return = "Audit Volume";
}
elsif (/BKP/) {
Derek B. Smith wrote:
Why is return 1 coded at the end of many programs. For
example:
I know it means true but what does this do and why?
thank you
derek
#!/usr/bin/perl
#use strict;
my $user_name = qq(dsmithxx);
my $user_password = qq();
my $sql_server = qq(x);
my ($dbh,$drh,$stmt);
--- Jay Savage <[EMAIL PROTECTED]> wrote:
> On 12/8/06, Derek B. Smith
> <[EMAIL PROTECTED]> wrote:
> > Why is return 1 coded at the end of many programs.
> For
> > example:
> >
> > I know it means true but what does this do and
> why?
>
> Derek,
>
> For historical reasons, the final statement o
On 12/8/06, Derek B. Smith <[EMAIL PROTECTED]> wrote:
Why is return 1 coded at the end of many programs. For
example:
I know it means true but what does this do and why?
Derek,
For historical reasons, the final statement of any script that is
imported with use or require (and possibly do?) mu
>
>Why is return 1 coded at the end of many programs. For
>example:
>
>I know it means true but what does this do and why?
This is because it's mostly 'require' d by other scripts then you may need to
add '1' at the end.
If this script is required by other scripts,but its last statement doesn't
radhika wrote:
Hi,
I have a snippet of code as below.
Even when I return 0 or '', why does @blocks evaluate to true?
If rows returned are 0, then if(@blocks) should evaluate to false, correct?
...
sub do_something
{
my @row = @_;
return @row if(@row);
return '';
}
@blocks
On 1/25/06, radhika <[EMAIL PROTECTED]> wrote:
> Hi,
> I have a snippet of code as below.
> Even when I return 0 or '', why does @blocks evaluate to true?
> If rows returned are 0, then if(@blocks) should evaluate to false, correct?
> Thanks,
> Radhika
> ---
> use strict;
> use diagnostics;
> my @b
[EMAIL PROTECTED] wrote:
ok so $? states CHILD_ERROR or last status returned by the last ` `
command.
$! states yields the current value of errno
in shell if I say it will give me a true or false value.
cat /tmp/foo
if [ $? -eq 0 ]
then
echo yes command succeeded
else
echo no.
fi
In
ers
PMSubject
[EMAIL PROTECTED] wrote:
$exit_value = $? >> 8
$signal_num = $? & 127;
$dumped_core = $? & 128;
ok this helps, thanks! But, in my small block of code I am using $? >> 8
as so
system ("cat /tmp/used"); # /tmp/used does not exist so
this should return 0 for false in Perl and 1 fal
cc
02/28/2005 11:38 Perl Beginners
AM
1 - 100 of 197 matches
Mail list logo