Questions tagged [bareword]

Bareword is intended for questions related to parsing behavior which involves words which are neither language keywords, delimited by quotes, nor prefixed by tokens reserved for variables.

References

20 questions
26
votes
1 answer

Bare words / new keywords in Python

I wanted to see if it was possible to define new keywords or, as they're called in Destroy All Software's "WAT" talk when discussing Ruby, bare words, in Python. I came up with an answer that I couldn't find elsewhere, so I decided to share it Q&A…
ArtOfWarfare
  • 20,617
  • 19
  • 137
  • 193
12
votes
2 answers

Why do some users quote classnames in Perl?

Looking at Type::Tiny, I see that the class name in the call to Type::Tiny->new is quoted in the official docs, my $NUM = "Type::Tiny"->new( name => "Number", constraint => sub { looks_like_number($_) }, message => sub { "$_ ain't…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
9
votes
2 answers

Why does Perl open() documentation use two different FILEHANDLE styles?

The documentation for the open function shows the syntax of open() as: open FILEHANDLE,EXPR open FILEHANDLE,MODE,EXPR open FILEHANDLE,MODE,EXPR,LIST open FILEHANDLE,MODE,REFERENCE open FILEHANDLE Down in the examples they have places where a…
Scooter
  • 6,802
  • 8
  • 41
  • 64
8
votes
3 answers

perl s/this/that/r ==> "Bareword found where operator expected"

Perl docs recommend this: $foo = $bar =~ s/this/that/r; However, I get this error: Bareword found where operator expected near "s/this/that/r" (#1) This is specific to the r modifier, without it the code works. However, I do not want to modify…
sds
  • 58,617
  • 29
  • 161
  • 278
5
votes
2 answers

Why are leading-hyphen options permitted on `use` lines without fat comma and with strict?

Why is the following use line legal Perl syntax? (Adapted from the POD for parent; tested on Perl 5.26.2 x64 on Cygwin.) package MyHash; use strict; use Tie::Hash; use parent -norequire, "Tie::StdHash"; # ^^^^^^^^^^ A bareword with nothing…
cxw
  • 16,685
  • 2
  • 45
  • 81
4
votes
1 answer

Why is a bareword following the concatenation operator a string in Perl?

Why does Perl (5.30.3 but also no feature ':all') assume a bareword following the concatenation operator . to be a string? For example: use v5.30; # or: no feature ':all'; use strict; use warnings; my $k1 = 'a'; my $k2 = 'b'; print STDOUT $k1 .…
n.r.
  • 1,900
  • 15
  • 20
3
votes
3 answers

Why does Perl complain about barewords in my Win32::OLE script?

#___ FIND LAST ROW/COLUMN WITH DATA my $row = $Sheet1 -> UsedRange -> Find( { What => "*", SearchDirection => xlPrevious, SearchOrder => xlByRows })-> {Row}; Error: Bareword "xlByRows" not allowed while…
Pankaj
  • 61
  • 4
3
votes
1 answer

Why does this error about strict subs only trigger under autodie?

Given code like this, I get no warning whatsoever. use strict; use warnings; open STDERR, '>&', STDOUT; Given this code, I get a fatal error. use strict; use warnings; use autodie; open STDERR, '>&', STDOUT; Bareword "STDOUT" not allowed while…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
3
votes
2 answers

Perl Search and Replace Command Not Working When Called from Inside another Perl Script

I am a beginner with Perl. I am using the Below Perl Command To Search and Replace "/$" Sequence in my tcl Script. This works well When used on the linux Command Line directly. perl -p -i -e 's/\/\$/\/\\\$/g' sed_list.tcl I am calling to Call the…
Sridhar
  • 31
  • 1
  • 1
  • 4
3
votes
5 answers

Why does defined sdf return true in this Perl example?

I tried this example in Perl. Can someone explain why is it true? if (defined sdf) { print "true"; } It prints true. sdf could be any name. In addition, if there is sdf function defined and it returns 0, then it does not print anything. print…
Aftershock
  • 5,205
  • 4
  • 51
  • 64
3
votes
3 answers

PHP - use of bareword in interface function declarations

Looking at PHP's documentation about interfaces, specifically here: PHP: Object Interfaces - Manual. The following code is given as a working example. Could someone explain what the bareword 'Baz' being declared as part of the function signature is…
dewd
  • 4,380
  • 3
  • 29
  • 43
2
votes
1 answer

Problems with eval and use

I wrote this code and it works when POE module is installed in the system. #!/usr/bin/perl use strict; use warnings; use POE; ... But I want to determine if this module exist: #!/usr/bin/perl use strict; use warnings; eval("use POE; 1") or die…
ciembor
  • 7,189
  • 13
  • 59
  • 100
2
votes
2 answers

exempting a piece of perl code from strict pragma

I have a legacy piece of perl code that uses perl DBI with constructs like $db->bind_param(1, $some_blob, {TYPE => SQL_BLOB}); where SQL_BLOB is a bareword. I would like to use strict pragma in the same file, but it then complains about the…
celaeno
  • 682
  • 1
  • 5
  • 13
2
votes
4 answers

using a windows batch file/command line that runs a perl s/("|')// command, how to do prevent a bareword found where operator expected error?

I've read the other posts and somehow the solutions don't work. perl -p0777e "s/('|"")/^&/g" "E:\output.csv" > "E:\output2.csv" I've tried perl -p0777e "s/('|^")/^&/g" "E:\output.csv" > "E:\output2.csv" perl -p0777e "s/('|\")/^&/g" "E:\output.csv"…
noobuserpm
  • 21
  • 4
2
votes
2 answers

What are the pitfalls in using bare words in Perl?

I understand that bare words can be used as strings in quoting operators (q//, qq//), hash keys, etc. I'm personally not too thrilled about this because I can't get over the mental expectation that a literal string should be quoted, as in C, C++.…
Ltf4an
  • 787
  • 5
  • 18
1
2