Syntax "||" before sub

2018-11-22 Thread James Kerwin
Hi All, I'm looking through some Perl files for software we use and I noticed this in one of the config files: $c->{guess_doc_type} ||= sub { All other similar config files show a similar structure, but without the "||" before the equals sign: $c->{validate_document} = sub { My question is, wh

Re: Syntax "||" before sub

2018-11-22 Thread James Kerwin
Ahhh sorrry to reply to my own post but I found this: https://stackoverflow.com/questions/29302181/what-is-in-perl-for I assume then that if " guess_doc_type" evaluates to false it moves on to the defined subroutine. My problem is that I can't find where " guess_doc_type" is defined... which is n

Re: Syntax "||" before sub

2018-11-22 Thread James Kerwin
Hi Sebastian, Thanks for that info! It's much more thorough than what I discovered about this. I'll keep it in mind as I delve deeper... Thanks, James On Thu, Nov 22, 2018 at 1:58 PM James Kerwin wrote: > Ahhh sorrry to reply to my own post but I found this: > > https://stackoverflow.com/quest

Re: Syntax "||" before sub

2018-11-22 Thread David Precious
On Thu, 22 Nov 2018 13:48:18 + James Kerwin wrote: > Hi All, > > I'm looking through some Perl files for software we use and I noticed > this in one of the config files: > > $c->{guess_doc_type} ||= sub { > > All other similar config files show a similar structure, but without > the "||" b

Re: Syntax "||" before sub

2018-11-22 Thread John W. Krahn
On 2018-11-22 8:08 a.m., David Precious wrote: You'll often see these operators used to provide default values. e.g. sub hello { my $name = shift; $name ||= 'Anonymous Person'; Which is usually written as: sub hello { my $name = shift || 'Anonymous Person'; I

Re: Syntax "||" before sub

2018-11-22 Thread Paul Johnson
On Thu, Nov 22, 2018 at 12:33:25PM -0800, John W. Krahn wrote: > On 2018-11-22 8:08 a.m., David Precious wrote: > > > > You'll often see these operators used to provide default values. > > > > e.g. > > > >sub hello { > >my $name = shift; > >$name ||= 'Anonymous Person'; > >

Re: Syntax "||" before sub

2018-11-24 Thread David Precious
On Thu, 22 Nov 2018 12:33:25 -0800 "John W. Krahn" wrote: > On 2018-11-22 8:08 a.m., David Precious wrote: > > > > > > You'll often see these operators used to provide default values. > > > > e.g. > > > >sub hello { > >my $name = shift; > >$name ||= 'Anonymous Person'; >

Re: Syntax "||" before sub

2018-11-24 Thread Jim Gibson
> On Nov 24, 2018, at 12:49 PM, David Precious wrote: > > I went to perldoc perlop expecting to be able to find a > section to point the OP at as a "here's the documentation for it", and > couldn't find anything particularly useful. I was able to find this in “perldoc perlop”: Assignment O