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.
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…
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…
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…
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…
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…
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 .…
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…
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…
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…
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…
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…
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…
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++.…