Nicholas Clark is in town, this calls for an emergency social! Join us tomorrow at The Kernel Tap Room.
ilmari reshared this.
London Perl Mongers reshared this.
London Perl Mongers attends.
I was using my $tmp = glob("file20240101.*") to find the full filename regardless of the extension(I knew there was only one of each file), when I found glob was alternating between working and failing
Rendering it as my ($tmp) = glob("file20240101.*") fixed the problem, but I'm wondering why, If it was going to go wrong I'd have thought treating glob's list in a scalar context would return the number of elements in the list
#!/usr/bin/perl
use warnings;
use strict;
for (1..4) {
my $tmp = glob($0);
print "$_ $tmp\n";
}
print "###\n";
for (1..4) {
my ($tmp) = glob($0);
print "$_ $tmp\n";
}
Output:
1 glob.pl
Use of uninitialized value $tmp in concatenation (.) or string at glob.pl line 7.
2
3 glob.pl
Use of uninitialized value $tmp in concatenation (.) or string at glob.pl line 7.
4
###
1 glob.pl
2 glob.pl
3 glob.pl
4 glob.pl
submitted by /u/octobod
[link] [comments]
Hi,
I don't get why this produces a syntax error:
my %r = map { "a$_" => 1 } qw(q w);
yet this works:
my %r = map { "a" . $_ => 1 } qw(q w);
What is going on here?
submitted by /u/ghiste
[link] [comments]
Let me explain my goal.
Let's say I have a file with a set of paths to files:
/usr/lib32/libssl.so
/usr/lib32/libz.so
...
and so on.
What's an easy way in perl to turn that input into:
/usr/lib32/libssl.so /usr/lib32/libssl.so
/usr/lib32/libz.so /usr/lib32/libz.so
...
Basically duplicate every string to the same line, delimited by a space?
Thanks for any assistance. I use perl's regex regularly for substitutions and the like (instead of using sed) and I prefer PCRE to sed. That said, not familiar with a way to do this.
submitted by /u/ShiningRaion
[link] [comments]