Re: Perl Critic and subroutine signatures

2017-03-29 Thread SSC_perl
> On Mar 29, 2017, at 3:47 PM, Kevin Phair wrote: > > Something like > > [-Subroutines::ProhibitSubroutinePrototypes] Thanks. I ran across that myself on perlmaven.com right before I went to lunch. I was hoping to find a page on CPAN or even the Perl Critic

Re: Perl Critic and subroutine signatures

2017-03-29 Thread Kevin Phair
t;p...@surfshopcart.com> wrote: > Does anyone know how to keep Perl Critic from complaining about subroutine > signatures? I’m getting a massive amount of these types of warnings: > > Subroutine prototypes used at line... > > It also thinks that postfix dereferencing is a magic vari

Re: Perl Critic and subroutine signatures

2017-03-29 Thread Uri Guttman
On 03/29/2017 01:32 PM, SSC_perl wrote: On Mar 29, 2017, at 10:19 AM, Uri Guttman <u...@stemsystems.com <mailto:u...@stemsystems.com>> wrote: i would ask why are you using prototypes? I’m not using prototypes. I’m using subroutine signatures. Perl Critic only thinks they ar

Re: Perl Critic and subroutine signatures

2017-03-29 Thread SSC_perl
> On Mar 29, 2017, at 10:19 AM, Uri Guttman <u...@stemsystems.com> wrote: > > i would ask why are you using prototypes? I’m not using prototypes. I’m using subroutine signatures. Perl Critic only thinks they are prototypes.

Re: Perl Critic and subroutine signatures

2017-03-29 Thread Uri Guttman
On 03/29/2017 01:16 PM, SSC_perl wrote: Does anyone know how to keep Perl Critic from complaining about subroutine signatures? I’m getting a massive amount of these types of warnings: Subroutine prototypes used at line... i would ask why are you using prototypes? they are rarely useful

Perl Critic and subroutine signatures

2017-03-29 Thread SSC_perl
Does anyone know how to keep Perl Critic from complaining about subroutine signatures? I’m getting a massive amount of these types of warnings: Subroutine prototypes used at line... It also thinks that postfix dereferencing is a magic variable. Is this because PC hasn’t been

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-02-25 Thread khalil zakaria Zemmoura
Naming multiple variables with the same name like you did ($args, %args) is a bad idea. because when you want to access the value of the hash %args ($args{FN}) you are accessing in reality what was shifted in the scalar $args and not the hash %args because perl use simbolic reference. here is a

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-02-25 Thread ZEMMOURA Khalil Zakaria
On Sun, Jan 15, 2017 at 12:45:41PM -0800, al...@myfastmail.com wrote: > Hi > > On Sun, Jan 15, 2017, at 12:23 PM, Илья Рассадин wrote: > > I think, you can use this aproach > > If I use either of those > > > sub modrec { > - my %args = %{ shift @_ }; > +

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread Chas. Owens
On Sun, Jan 15, 2017, 16:19 wrote: Hi, On Sun, Jan 15, 2017, at 01:01 PM, Shawn H Corey wrote: > > Is there a different, recommended way? > > Nothing's wrong. perlcritic does not this valid method, that's all. > > TIMTOWTDI (There Is More Than One Way To Do It.) Hm, ok.

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread Rob Dixon
Hi Alan You are unpacking `@_` in a way, but perlcritic doesn't recognise doing it this way. I think you'd be better off without dereferencing the hash, and using a slice to assign your local variables. I would write your subroutine like this sub modrec { my ($args

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread alanj
Hi, On Sun, Jan 15, 2017, at 01:01 PM, Shawn H Corey wrote: > > Is there a different, recommended way? > > Nothing's wrong. perlcritic does not this valid method, that's all. > > TIMTOWTDI (There Is More Than One Way To Do It.) Hm, ok. As long as it's not wrong/broken in some weird way. I

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread Shawn H Corey
On Sun, 15 Jan 2017 12:09:53 -0800 al...@myfastmail.com wrote: > What's wrong with the way I'm unpacking the arguments passed to the > subroutine, > > my %args = %{ shift @_ }; > > Is there a different, recommended way? Nothing's wrong. perlcritic does not this valid

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread Илья Рассадин
Hi! You forgot arrow operator $args->{'FN'}, not $args{'FN'} 15.01.17 23:45, al...@myfastmail.com пишет: Hi On Sun, Jan 15, 2017, at 12:23 PM, Илья Рассадин wrote: I think, you can use this aproach If I use either of those sub modrec { - my %args = %{ shift

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread alanj
Hi On Sun, Jan 15, 2017, at 12:23 PM, Илья Рассадин wrote: > I think, you can use this aproach If I use either of those sub modrec { - my %args = %{ shift @_ }; + my ($args) = @_; 30 my $fn = $args{FN};

Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread Илья Рассадин
Hi! I think, you can use this aproach sub modrec { my ($args) = @_; # or my $args = shift @_; use what you like more my $fn = $args->{'FN'}; } 15.01.17 23:09, al...@myfastmail.com пишет: Hi, I have a simple script with a subroutine that I pass scalar & array ar

script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread alanj
Hi, I have a simple script with a subroutine that I pass scalar & array arguments to, #!/usr/bin/perl use 5.01201; use strict; use warnings; my $this_fn = "input.txt"; my @this_dr = qw( /path/1 /path/2

close dbh in the subroutine

2014-05-08 Thread Jeff Pang
Hi, I created a $dbh object in the main body, and pass it to a subroutine, then close the $dbh in the subroutine, does it  influence the $dbh in the main? $dbh = DBI-connect($data_source, $username, $auth, \%attr); my_func($dbh); $dbh-do(something); # will this broke? sub my_func { my

Re: close dbh in the subroutine

2014-05-08 Thread David Precious
On Thu, 08 May 2014 16:54:32 +0400 Jeff Pang jeffp...@mail.ru wrote: Hi, I created a $dbh object in the main body, and pass it to a subroutine, then close the $dbh in the subroutine, does it  influence the $dbh in the main? Yes. It's a reference to the same DBI object

How do I pass arrays into a subroutine

2013-09-07 Thread eventual
Hi,   In the example below, how do I pass @pets and @numbers into the subroutine so that @animals = @pets  and @digits = @numbers. Thanks   my @pets = ('dogs' , 'cats' , 'horses'); my @numbers = (1..10);   study (@pets , @numbers);   sub study {   my (@animals, @digits) = (@_[0] , @_[1

Re: How do I pass arrays into a subroutine

2013-09-07 Thread Shlomi Fish
Hi Eventual, On Sat, 7 Sep 2013 04:11:06 -0700 (PDT) eventual eventualde...@yahoo.com wrote: Hi,   In the example below, how do I pass @pets and @numbers into the subroutine so that @animals = @pets  and @digits = @numbers. Please look into references and pass the arrays as references

Re: How do I pass arrays into a subroutine

2013-09-07 Thread *Shaji Kalidasan*
4:41 PM Subject: How do I pass arrays into a subroutine Hi,   In the example below, how do I pass @pets and @numbers into the subroutine so that @animals = @pets  and @digits = @numbers. Thanks   my @pets = ('dogs' , 'cats' , 'horses'); my @numbers = (1..10);   study (@pets , @numbers);   sub

Re: How do I pass arrays into a subroutine

2013-09-07 Thread Karol Bujaček
On 09/07/2013 01:11 PM, eventual wrote: Hi, In the example below, how do I pass @pets and @numbers into the subroutine so that @animals = @pets and @digits = @numbers. Thanks my @pets = ('dogs' , 'cats' , 'horses'); my @numbers = (1..10); study (@pets , @numbers); sub study { my (@animals

Re: How do I pass arrays into a subroutine

2013-09-07 Thread Dr.Ruud
On 07/09/2013 13:43, Karol Bujaček wrote: print Dumper(@_);# just look how the @_ looks like Consider: print Dumper( \@_ ); my($animals, $digits) = @_; my @animals = @$animals; # dereference my @digits = @$digits; # dereference The comment is inaccurate. Why would

Re: How do I pass arrays into a subroutine

2013-09-07 Thread Shawn H Corey
On Sat, 07 Sep 2013 14:15:39 +0200 Dr.Ruud rvtol+use...@isolution.nl wrote: On 07/09/2013 13:43, Karol Bujaček wrote: print Dumper(@_);# just look how the @_ looks like Consider: print Dumper( \@_ ); my($animals, $digits) = @_; my @animals = @$animals; #

Re: How do I pass arrays into a subroutine

2013-09-07 Thread Karol Bujaček
; # dereference my @digits = @$digits; # dereference The comment is inaccurate. Why would you want to copy the arrays? Because I don't want to change an array by my subroutine, as Shawn H Corey answered already. Well, this may or may not be eventual's intention, apt remark. Best

subroutine

2012-08-17 Thread Chris Stinemetz
Hello List, Can this subroutine be better written? I am getting the following erros: Use of uninitialized value $y in subtraction (-) at form.pl line 52. Use of uninitialized value $y in addition (+) at form.pl line 52. sub avg_az { my($x, $y) = shift(@_); return abs($x-$y)180 ? ($x+$y)/2

Re: subroutine

2012-08-17 Thread Alan Haggai Alavi
Hello Chris, Can this subroutine be better written? I am getting the following erros: Use of uninitialized value $y in subtraction (-) at form.pl line 52. Use of uninitialized value $y in addition (+) at form.pl line 52. sub avg_az { my($x, $y) = shift(@_); In the above line, `shift

Re: subroutine

2012-08-17 Thread Chris Stinemetz
In the above line, `shift` will return just the first element from the @_ array. $y will therefore be undefined. The line should be rewritten as: my ( $x, $y ) = @_; Thank you. I should have caught that. Chris

Re: subroutine in seperate file, question

2012-08-11 Thread shawn wilson
On Aug 10, 2012 11:41 PM, pa...@riseup.net wrote: I mean to ask, wether they will clash with the same loaded modules loaded in calling script? No. they are loaded only once. Well, they will both be in ISA to look up separately but there is no conflict.

Re: subroutine in seperate file, question

2012-08-11 Thread Shawn H Corey
On Sat, 11 Aug 2012 02:49:56 -0400 shawn wilson ag4ve...@gmail.com wrote: On Aug 10, 2012 11:41 PM, pa...@riseup.net wrote: I mean to ask, wether they will clash with the same loaded modules loaded in calling script? No. they are loaded only once. Well, they will both be in

Re: subroutine in seperate file, question

2012-08-11 Thread Rajeev Prasad
Thank you. I am confused about how to send variables to this ext.pl and get values (scalars) back into main.pl another confusion is from web the cgi will run, i want to check cookies in external subroutine file and redirect to some website based on some condition, or gives some values back

Re: subroutine in seperate file, question

2012-08-11 Thread Rob Dixon
On 11/08/2012 12:43, Shawn H Corey wrote: No, @ISA is used only by Exporter.pm Exporter makes no use of @ISA at all. This array is a per-package variable used by Perl internally to implement object-oriented inheritance. It is very often used to make a package a subclass of Exporter, but that

subroutine in seperate file, question

2012-08-10 Thread Rajeev Prasad
i want to keep a peice of code which uses CGI and DBIx module in a seperate file, and want to include it in all my scripts as follows:   require /path/to/script/file;   I am not sure if the calling program is also using same modules CGI and DBIx what kind of unknown errors i might get? anyone

Re: subroutine in seperate file, question

2012-08-10 Thread pangj
Yes, the modules in required file will be loaded. $ cat ext.pl use CGI; use DBI; 1; $ cat main.pl require 'ext.pl'; use Data::Dumper; print Dumper \%INC; Thus run perl main.pl to see what prints. i want to keep a peice of code which uses CGI and DBIx module in a seperate file, and want to

Re: subroutine in seperate file, question

2012-08-10 Thread Rajeev Prasad
: subroutine in seperate file, question Yes, the modules in required file will be loaded. $ cat ext.pl use CGI; use DBI; 1; $ cat main.pl require 'ext.pl'; use Data::Dumper; print Dumper \%INC; Thus run perl main.pl to see what prints. i want to keep a peice of code which uses CGI and DBIx module

Re: subroutine in seperate file, question

2012-08-10 Thread pangj
I mean to ask, wether they will clash with the same loaded modules loaded in calling script? No. they are loaded only once. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: array ref as subroutine parameter

2012-07-13 Thread timothy adigun
Hi Chris, On Fri, Jul 13, 2012 at 3:28 AM, Shawn H Corey shawnhco...@gmail.comwrote: On 12-07-12 10:25 PM, Chris Stinemetz wrote: I have an anonymous array below and would like to know how to pass the first element to a subroutine as a parameter. push @data, [$srt,$srfc,$cfc,$cfcq,$cell

array ref as subroutine parameter

2012-07-12 Thread Chris Stinemetz
I have an anonymous array below and would like to know how to pass the first element to a subroutine as a parameter. push @data, [$srt,$srfc,$cfc,$cfcq,$cell,$icell,$isector,$sector]; call to subroutine: session_attempts($srt); Thank you in advance, Chris

Re: array ref as subroutine parameter

2012-07-12 Thread Shawn H Corey
On 12-07-12 10:25 PM, Chris Stinemetz wrote: I have an anonymous array below and would like to know how to pass the first element to a subroutine as a parameter. push @data, [$srt,$srfc,$cfc,$cfcq,$cell,$icell,$isector,$sector]; call to subroutine: session_attempts($srt); Thank you

Re: subroutine returning data

2012-06-10 Thread Shlomi Fish
Hi all, On Tue, 05 Jun 2012 10:15:36 -0700 John W. Krahn jwkr...@shaw.ca wrote: [ Please do not top-post your replies. Please remove non-relevant text from your reply before posting. TIA ] don't insult and dismiss out of hand the findings of those who take the time to help you. If I

Re: Unfamiliar calling of a subroutine

2012-06-08 Thread sono-io
On Jun 7, 2012, at 10:19 PM, Brock wrote: Finally to your last question, how is this different than just calling the package::sub directly? With a method call the instance variable, in this case $catalog, always gets passed as the first parameter to the method. Usually people name it

Unfamiliar calling of a subroutine

2012-06-07 Thread sono-io
Would someone be so kind as to explain the following, or at least point me to further reading? $item = $main::global-{open}-{catalog}-SurfDB::split_line($main::global-{form}-{'itemid'}); The part I'm having trouble understanding is $main::global-{open}-{catalog}-. What does

Re: Unfamiliar calling of a subroutine

2012-06-07 Thread pangj
Would someone be so kind as to explain the following, or at least point me to further reading? $item = $main::global-{open}-{catalog}-SurfDB::split_line($main::global-{form}-{'itemid'}); That's Perl OO programming. You may want to read this book:

Re: Unfamiliar calling of a subroutine

2012-06-07 Thread Brock
On 2012.06.07.20.21, sono...@fannullone.us wrote: Would someone be so kind as to explain the following, or at least point me to further reading? $item = $main::global-{open}-{catalog}-SurfDB::split_line($main::global-{form}-{'itemid'}); The part I'm having trouble

Re: subroutine returning data

2012-06-05 Thread Shlomi Fish
Hello John, On Mon, 04 Jun 2012 14:19:27 -0700 John W. Krahn jwkr...@shaw.ca wrote: Chris Stinemetz wrote: I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. One way to do it: sub site_offAir { return

Re: subroutine returning data

2012-06-05 Thread John W. Krahn
Shlomi Fish wrote: On Mon, 04 Jun 2012 14:19:27 -0700 John W. Krahnjwkr...@shaw.ca wrote: Chris Stinemetz wrote: I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. One way to do it: sub site_offAir

RE: subroutine returning data

2012-06-05 Thread Jack Maney
ProTip: If you're going to ask for help, don't insult and dismiss out of hand the findings of those who take the time to help you. -Original Message- From: John W. Krahn [mailto:jwkr...@shaw.ca] Sent: Tuesday, June 05, 2012 2:18 AM To: Perl Beginners Subject: Re: subroutine returning

List behavior pro tips (was: Re: subroutine returning data)

2012-06-05 Thread John SJ Anderson
for help, don't insult and dismiss out of hand the findings of those who take the time to help you. -Original Message- From: John W. Krahn [mailto:jwkr...@shaw.ca] Sent: Tuesday, June 05, 2012 2:18 AM To: Perl Beginners Subject: Re: subroutine returning data Shlomi Fish wrote

Re: subroutine returning data

2012-06-05 Thread John W. Krahn
[ Please do not top-post your replies. Please remove non-relevant text from your reply before posting. TIA ] Jack Maney wrote: ProTip: The top two results from Google state: PROTIP | Know Your Meme About PROTIP is a term often used in forums and comments to preface snarky, obvious,

subroutine returning data

2012-06-04 Thread Chris Stinemetz
I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. Any suggestions is greatly appreciated. Thank you, Chris sub site_offAir { for (values %{$href-{$_[0]}}) { return 1 if $_ eq 'ND'; #need to test all values

Re: subroutine returning data

2012-06-04 Thread Paul Johnson
On Mon, Jun 04, 2012 at 11:30:30AM -0500, Chris Stinemetz wrote: I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. Any suggestions is greatly appreciated. Thank you, Chris sub site_offAir { for (values

Re: subroutine returning data

2012-06-04 Thread Bill Stephenson
On Jun 4, 2012, at 11:30 AM, Chris Stinemetz wrote: I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. Any suggestions is greatly appreciated. Chris, I don't know how to read your hash directly (hash of hashes

Re: subroutine returning data

2012-06-04 Thread Shawn H Corey
On 12-06-04 12:30 PM, Chris Stinemetz wrote: I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. Any suggestions is greatly appreciated. Thank you, Chris sub site_offAir { for (values %{$href-{$_[0

Re: subroutine returning data

2012-06-04 Thread Bill Stephenson
: I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. Any suggestions is greatly appreciated. Thank you, Chris sub site_offAir { for (values %{$href-{$_[0]}}) { return 1 if $_ eq 'ND'; #need to test all

Re: subroutine returning data

2012-06-04 Thread Shawn H Corey
On 12-06-04 02:01 PM, Bill Stephenson wrote: The values %{$href-{$_[0]}} code is pretty ugly but I get it now. And it make sense to break out of the loop as soon as you don't pass the test. sub site_offAir { my $site_id = shift @_; for my $activity_code ( values %{

Re: subroutine returning data

2012-06-04 Thread Chris Stinemetz
Thank you everyone. Your help has been very helpful.. Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: subroutine returning data

2012-06-04 Thread John W. Krahn
Chris Stinemetz wrote: I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. One way to do it: sub site_offAir { return values %{ $href-{ $_[ 0 ] } } == grep( $_ eq 'ND', values %{ $href-{ $_[ 0 ] } } ) ? 1

Re: and subroutine

2012-04-19 Thread Paul.G
Thanks for everyone's assistance, I think I have my answer. I will be looking closer at the comments. cheers From: Michael Rasmussen mich...@jamhome.us To: beginners@perl.org Sent: Tuesday, 17 April 2012 11:01 PM Subject: Re: and subroutine And for what

Re: and subroutine

2012-04-17 Thread 'lesleyb'
On Mon, Apr 16, 2012 at 04:20:35PM +0200, Paul Johnson wrote: On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: Hi All Have a question, is it good coding practice to use a when calling a subroutine, or it is not required, or it doesn't matter? It's good practice not to use

Re: and subroutine

2012-04-17 Thread Gary Stainburn
On Monday 16 April 2012 15:20:35 Paul Johnson wrote: On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: Hi All Have a question, is it good coding practice to use a when calling a subroutine, or it is not required, or it doesn't matter? It's good practice not to use it unless you

Re: and subroutine

2012-04-17 Thread Manfred Lotz
On Tue, 17 Apr 2012 12:27:32 +0100 Gary Stainburn gary.stainb...@ringways.co.uk wrote: On Monday 16 April 2012 15:20:35 Paul Johnson wrote: On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: Hi All Have a question, is it good coding practice to use a when calling a subroutine

Re: and subroutine

2012-04-17 Thread Shawn H Corey
, is it good coding practice to use a when calling a subroutine, or it is not required, or it doesn't matter? It's good practice not to use it unless you understand exactly why you would need to use it. Could someone please expand on this as I seem to always have to do this. If I

Re: and subroutine

2012-04-17 Thread Michael Rasmussen
On Tue, Apr 17, 2012 at 02:30:59PM +0200, Manfred Lotz wrote: Could someone please expand on this as I seem to always have to do this. If I 'use strict' and 'use warnings' I get errors if I don't. One example is this: #! /usr/bin/perl use strict; use warnings; mysub; sub

Re: and subroutine

2012-04-17 Thread Michael Rasmussen
And for what it's worth. 113. Call subroutines with parentheses but without a leading That's from Damian Conway's Perl Best Practices A quick reference to the 256 guidelines is found at http://refcards.com/docs/vromansj/perl-best-practices/refguide.pdf And a bit of luck, the entire chapter on

Re: and subroutine

2012-04-17 Thread Gary Stainburn
of ./testsub.pl aborted due to compilation errors. Perl tells you that it has no idea what you mean when you use the bareword mysub. Now you have two options to solve it. 1. mysub; Using the sigil you tell Perl that mysub is a subroutine. 2. mysub(); Usind () after mysub you also tell

Re: and subroutine

2012-04-17 Thread Manfred Lotz
. mysub; Using the sigil you tell Perl that mysub is a subroutine. 2. mysub(); Usind () after mysub you also tell Perl that mysub is a subroutine. 3. mysub(); Combining 1. and 2. works also but is not recommended. Hmm, at least I do no recommend it. Use 2. and you'll

Re: and subroutine

2012-04-17 Thread Gary Stainburn
On Tuesday 17 April 2012 15:13:40 Manfred Lotz wrote: You have sub mysub() { instead of sub mysub { which is the correct way. Thank you. I can't believe how many years I've been getting that one wrong. Gary -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: and subroutine

2012-04-17 Thread Ken Slater
tell Perl that mysub is a subroutine. 2. mysub(); Usind () after mysub you also tell Perl that mysub is a subroutine. 3. mysub(); Combining 1. and 2. works also but is not recommended. Hmm, at least I do no recommend it. Use 2. and you'll be happy. There are surely some other situations

Re: and subroutine

2012-04-17 Thread Uri Guttman
On 04/17/2012 07:03 AM, 'lesleyb' wrote: On Mon, Apr 16, 2012 at 04:20:35PM +0200, Paul Johnson wrote: On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: Hi All Have a question, is it good coding practice to use a when calling a subroutine, or it is not required, or it doesn't matter

Re: and subroutine

2012-04-17 Thread Uri Guttman
to use a when calling a subroutine, or it is not required, or it doesn't matter? It's good practice not to use it unless you understand exactly why you would need to use it. Could someone please expand on this as I seem to always have to do this. If I 'use strict' and 'use warnings' I get

and subroutine

2012-04-16 Thread Paul.G
Hi All Have a question, is it good coding practice to use a when calling a subroutine, or it is not required, or it doesn't matter? eg: sub name { some code here, returning a single value return 0; } name(); cheers

Re: and subroutine

2012-04-16 Thread Paul Johnson
On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote: Hi All Have a question, is it good coding practice to use a when calling a subroutine, or it is not required, or it doesn't matter? It's good practice not to use it unless you understand exactly why you would need to use it. -- Paul

Re: Undefined subroutine main::subs

2012-03-08 Thread Shawn H Corey
On 12-03-07 11:49 PM, lina wrote: I only read till 15 pages, progressed so slow, and sometimes choked by understanding the pack. really hard for me to understand it, so I just skip. meanwhile I also did some search. pack() is difficult to understand, and most of the time, unneeded. I suggest

Re: Undefined subroutine main::subs

2012-03-08 Thread lina
On Thu, Mar 8, 2012 at 10:07 PM, Shawn H Corey shawnhco...@gmail.com wrote: On 12-03-07 11:49 PM, lina wrote: I only read till 15 pages, progressed so slow, and sometimes choked by understanding the pack. really hard for me to understand it, so I just skip.  meanwhile I also did some search.

Re: Undefined subroutine main::subs

2012-03-08 Thread lina
On Thu, Mar 8, 2012 at 10:14 PM, lina lina.lastn...@gmail.com wrote: On Thu, Mar 8, 2012 at 10:07 PM, Shawn H Corey shawnhco...@gmail.com wrote: On 12-03-07 11:49 PM, lina wrote: I only read till 15 pages, progressed so slow, and sometimes choked by understanding the pack. really hard for me

Re: Undefined subroutine main::subs

2012-03-08 Thread Shawn H Corey
On 12-03-08 09:19 AM, lina wrote: a quick question, is padre very popular, do you use it often, seems a bit heavy. I use GViM since it allows me to place to files (or the same one) side-by-side on the screen. Padre doesn't do this yet. But learning to use GViM is difficult since its commands

Undefined subroutine main::subs

2012-03-07 Thread lina
Hi, $ ./substr_accessing_examples.pl Undefined subroutine main::subst called at ./substr_accessing_examples.pl line 15. #!/usr/bin/env perl use strict; use warnings; # # get a 5-byte string, skip 3 bytes, # then grab two 8-byte strings, then the rest; # # (my $leading, my $s1, my $s2, my

Re: Undefined subroutine main::subs

2012-03-07 Thread Jim Gibson
At 12:41 AM +0800 3/8/12, lina wrote: Hi, $ ./substr_accessing_examples.pl Undefined subroutine main::subst called at ./substr_accessing_examples.pl line 15. #!/usr/bin/env perl use strict; use warnings; # # get a 5-byte string, skip 3 bytes, # then grab two 8-byte strings, then the rest

Re: Undefined subroutine main::subs

2012-03-07 Thread Brock
Greetings! I think you mean 'substr' instead of 'subst'. --Brock On 2012.03.08.00.41, lina wrote: Hi, $ ./substr_accessing_examples.pl Undefined subroutine main::subst called at ./substr_accessing_examples.pl line 15. #!/usr/bin/env perl use strict; use warnings; # # get a 5

Re: Undefined subroutine main::subs

2012-03-07 Thread 'lesleyb'
On Thu, Mar 08, 2012 at 12:41:01AM +0800, lina wrote: Hi, $ ./substr_accessing_examples.pl Undefined subroutine main::subst called at ./substr_accessing_examples.pl line 15. #!/usr/bin/env perl use strict; use warnings; # # get a 5-byte string, skip 3 bytes, # then grab two 8

Re: Undefined subroutine main::subs

2012-03-07 Thread lina
snip Thanks for all, I was so inexperience, thought might some module missing and a bit carelessly. Best regards, -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Undefined subroutine main::subs

2012-03-07 Thread David Christensen
the time... A drawback with online documentation is that you need to know the right question and how/ where to ask it. The Search box of the Perl Programming Documentation web site was able to find the substr function given the subroutine name from the above error message (the part that follows main

Re: Undefined subroutine main::subs

2012-03-07 Thread lina
function given the subroutine name from the above error message (the part that follows main::):    http://perldoc.perl.org/search.html?q=subst An advantage of good, printed books is that they have a Table of Contents and an Index.  Do you have the three books I suggested? Thanks David, I

Re: Undefined subroutine main::subs

2012-03-07 Thread David Christensen
On 03/07/2012 08:49 PM, lina wrote: Thanks David, YW. :-) I started from the second book, perl cookbook. 2nd edition. I only read till 15 pages, progressed so slow, and sometimes choked by understanding the pack. really hard for me to understand it, so I just skip. meanwhile I also did

Re: subroutine call

2011-12-05 Thread Shlomi Fish
Hello, John. On Sun, 04 Dec 2011 12:46:40 -0800 John W. Krahn jwkr...@shaw.ca wrote: You should assign $marketInfo{$mkt} to a variable, or alternatively do: my ($start, $end) = @{$marketInfo{$mkt}}{qw(start end)}; my $end = $marketInfo{$mkt}-{end}; if( $cell=

Re: subroutine call

2011-12-05 Thread Shlomi Fish
Hi Ganesh, On Mon, 5 Dec 2011 14:16:29 +0530 ganesh vignesh vigneshganes...@gmail.com wrote: stop mail to me The instructions at the bottom of every E-mail read: [QUOTE] To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org

subroutine call

2011-12-04 Thread Chris Stinemetz
I have a program that I am working on improveing. The fist step I have taken is converting it in using the strict pragma. Now when this subroutine call is made I get the following compilation error: Global symbol $cell requires explicit package name at ./evdo.pl line 279. Global symbol $cell

Re: subroutine call

2011-12-04 Thread Uri Guttman
On 12/04/2011 08:40 AM, Chris Stinemetz wrote: I have a program that I am working on improveing. The fist step I have taken is converting it in using the strict pragma. Now when this subroutine call is made I get the following compilation error: Global symbol $cell requires explicit package

Re: subroutine call

2011-12-04 Thread Shlomi Fish
. Now when this subroutine call is made I get the following compilation error: Global symbol $cell requires explicit package name at ./evdo.pl line 279. Global symbol $cell requires explicit package name at ./evdo.pl line 279. I understand lexical scope, but am having a hard time figuring

Re: subroutine call

2011-12-04 Thread Dr.Ruud
On 2011-12-04 18:12, Shlomi Fish wrote: Chris wrote: my $cell = substr($market,0,index($market,_)); print $_ , substr( $_, 0, index $_, _ ), \n for qw/ foo1 foo2_bar foo3_bar_baz /; foo1 foo foo2_bar foo2 foo3_bar_baz foo3 This can be more idiomatically (and more briefly) done

Re: subroutine call

2011-12-04 Thread John W. Krahn
the strict pragma. Now when this subroutine call is made I get the following compilation error: Global symbol $cell requires explicit package name at ./evdo.pl line 279. Global symbol $cell requires explicit package name at ./evdo.pl line 279. I understand lexical scope, but am having a hard time figuring

Re: timings of perl subroutine with a program

2011-11-07 Thread a b
Thanks a ton!! Hats off to you for encouragement On Fri, Nov 4, 2011 at 5:05 PM, Shlomi Fish shlo...@shlomifish.org wrote: Hi a b, On Fri, 4 Nov 2011 15:18:00 +0530 a b testa...@gmail.com wrote: apologize!! Can you help me to understand how async I/O can help me What's wrong with

Re: timings of perl subroutine with a program

2011-11-04 Thread a b
apologize!! Can you help me to understand how async I/O can help me Regards a b On Thu, Nov 3, 2011 at 9:06 PM, Shlomi Fish shlo...@shlomifish.org wrote: Hello a b, please reply to the list as I specifically request in my signature. (Wretched gmail.com.) I'm CCing the list. On Thu, 3

Re: timings of perl subroutine with a program

2011-11-04 Thread Shlomi Fish
Hi a b, On Fri, 4 Nov 2011 15:18:00 +0530 a b testa...@gmail.com wrote: apologize!! Can you help me to understand how async I/O can help me What's wrong with the resources in the URL I pointed you to? There's also http://en.wikipedia.org/wiki/Asynchronous_I/O which may be of interest. The

Re: timings of perl subroutine with a program

2011-11-03 Thread Shlomi Fish
On Thu, 3 Nov 2011 06:49:36 +0100 timothy adigun 2teezp...@gmail.com wrote: Hi a b, a b testa...@gmail.com wrote: Hi all, i need to track down how much time each function is taking and anlyze if threads can help do we have any such function?? **You can use ** use Benchmark

Re: timings of perl subroutine with a program

2011-11-03 Thread Shlomi Fish
Hello a b, please reply to the list as I specifically request in my signature. (Wretched gmail.com.) I'm CCing the list. On Thu, 3 Nov 2011 16:15:11 +0530 a b testa...@gmail.com wrote: Thanks Shlomi!! I am not sure about async I/O? any pointers about this one. It is new to me so far

timings of perl subroutine with a program

2011-11-02 Thread a b
Hi all, i need to track down how much time each function is taking and anlyze if threads can help do we have any such function??

Re: timings of perl subroutine with a program

2011-11-02 Thread timothy adigun
Hi a b, a b testa...@gmail.com wrote: Hi all, i need to track down how much time each function is taking and anlyze if threads can help do we have any such function?? **You can use ** use Benchmark qw(:all) **. From your CLI you can do: perldoc benchmark, or if you not like reading from

Re: Exit subroutine on filehandle error

2011-07-29 Thread Dr.Ruud
On 2011-07-28 00:45, C.DeRykus wrote: open( ... ) or warn ... and return; Here you are assuming that warn always returns true. It actually does, even if the device that it write to is full, but I don't think that is documented ... -- Ruud -- To unsubscribe, e-mail:

Re: Exit subroutine on filehandle error

2011-07-29 Thread Paul Johnson
On Fri, Jul 29, 2011 at 04:05:26PM +0200, Dr.Ruud wrote: On 2011-07-28 00:45, C.DeRykus wrote: open( ... ) or warn ... and return; Here you are assuming that warn always returns true. It actually does, even if the device that it write to is full, but I don't think that is

  1   2   3   4   5   6   7   8   9   10   >