A bareword is an unquoted string appearing in Perl source. Depending on context 
it is treated as a sub call or a string (or a filehandle and a few other things 
I'd imagine).

Barewords that are not sub calls are generally not permitted under "use strict" 
(specifically "use strict 'subs'"), with exceptions such as inside a hash key 
or immediately preceding a fat comma '=>'.

In your case, you appear to have omitted the sigil $ before 'attrs' in your 
call to 'new'.

See 'perldoc perldata' for more info on barewords and 'perldoc strict' for more 
info on what "use strict 'subs' forbids and allows.

Cheers,
Michael

Michael Brader
Senior Software Engineer - Billing
Techops - Softdev
Internode http://www.internode.on.net/

________________________________________
From: Mark Haney [ma...@abemblem.com]
Sent: Friday, 1 June 2012 7:58 AM
To: beginners@perl.org
Subject: Bareword and strict subs

I'm getting this error in one of my packages (built by a previous coder):

> Bareword "%s" not allowed while "strict subs" in use

In this case the "%s" is attrs.  Here's the bit of code it's choking on:


sub insert_shift {
       my $self = shift;
       my $attrs = @_;

       my $m = $self->schema->resultset('Shifts')->new(attrs);
       $m->insert;
}

I've googled this error, but what I've found is not very informative.  I
have no idea what a Bareword is in the Perl context.  Can someone
explain what's going on?

--

Mark Haney
Software Developer/Consultant
AB Emblem
ma...@abemblem.com
Linux marius.homelinux 3.3.7-1.fc16.x86_64 GNU/Linux

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to