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 method, that's all.

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 arguments

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 ); my