Re: .sub confusion

2018-05-01 Thread JJ Merelo
Can you please take this very interesting question (and the rest the answers) to StackOverflow? Cheers JJ

Re: .sub confusion

2018-05-01 Thread Brandon Allbery
On Tue, May 1, 2018 at 4:49 AM, ToddAndMargo wrote: > .sub is a method call and I can't write them. They come with Perl. > You can write them. But they are 'method', not 'sub', and must be defined within a class. If you put 'is export' on a method so defined, it can become a sub at the same ti

Re: .sub confusion

2018-05-01 Thread ToddAndMargo
On 04/30/2018 06:20 AM, Elizabeth Mattijsen wrote: On 30 Apr 2018, at 15:04, ToddAndMargo wrote: Hi All, I am confused. With this sub: sub odd( $Num ) { return $Num % 2; } Why does this work: if odd $LineNum { $PartsStr ~= ''; } # Green else { $PartsStr ~=

Re: .sub confusion

2018-05-01 Thread ToddAndMargo
On 04/30/2018 07:15 AM, Bruce Gray wrote: On Apr 30, 2018, at 8:04 AM, ToddAndMargo wrote: Hi All, I am confused. With this sub: sub odd( $Num ) { return $Num % 2; } Why does this work: if odd $LineNum { $PartsStr ~= ''; } # Green else { $PartsStr ~= '';

Re: .sub confusion

2018-04-30 Thread Bruce Gray
> On Apr 30, 2018, at 8:04 AM, ToddAndMargo wrote: > > Hi All, > > I am confused. > > With this sub: > >sub odd( $Num ) { return $Num % 2; } > > > Why does this work: > > if odd $LineNum > { $PartsStr ~= ''; } # Green >else { $PartsStr ~= ''; } # Purple > >

Re: .sub confusion

2018-04-30 Thread Elizabeth Mattijsen
> On 30 Apr 2018, at 15:04, ToddAndMargo wrote: > > Hi All, > > I am confused. > > With this sub: > >sub odd( $Num ) { return $Num % 2; } > > > Why does this work: > > if odd $LineNum > { $PartsStr ~= ''; } # Green >else { $PartsStr ~= ''; } # Purple > > And

.sub confusion

2018-04-30 Thread ToddAndMargo
Hi All, I am confused. With this sub: sub odd( $Num ) { return $Num % 2; } Why does this work: if odd $LineNum { $PartsStr ~= ''; } # Green else { $PartsStr ~= ''; } # Purple And this one throw an error: if $LineNum.odd { $PartsStr ~= ''