Questions tagged [perlvar]

10 questions
7
votes
3 answers

What is the difference betweeen %INC and @INC?

What is the difference between %INC and @INC in Perl?
joe
  • 34,529
  • 29
  • 100
  • 137
6
votes
2 answers

Are keys and values of %INC platform-dependent or not?

I'd like to get the full filename of an included module. Consider this code: package MyTest; my $path = join '/', split /::/, __PACKAGE__; $path .= ".pm"; print "$INC{$path}\n"; 1; $ perl -Ipath/to/module -MMyTest…
codeholic
  • 5,680
  • 3
  • 23
  • 43
4
votes
2 answers

Current filename for find/xargs/perl -ne?

I'm working in the shell, trying to find NUL chars in a bunch of CSV files (that Python's CSV importer is whinging about, but that's for another time) using the so-proud-of-my-ever-clever-self: find ~/path/ -name "*.csv" -print0 | \ xargs -n 1 -0…
3
votes
5 answers

How is $_ different from named input or loop arguments?

As I use $_ a lot I want to understand its usage better. $_ is a global variable for implicit values as far as I understood and used it. As $_ seems to be set anyway, are there reasons to use named loop variables over $_ besides readability? In what…
matthias krull
  • 4,389
  • 3
  • 34
  • 54
2
votes
3 answers

Scope of the default variable $_ in Perl

I have the following method which accepts a variable and then displays info from a database: sub showResult { if (@_ == 2) { my @results = dbGetResults($_[0]); if (@results) { foreach (@results) { …
skeniver
  • 2,647
  • 6
  • 28
  • 34
2
votes
3 answers

Package Variable in Perl not in "scope"?

I was looking at this question, and while I was playing around, I came across this: #! /usr/bin/env perl # # use warnings; use strict; use feature qw(say); { our $foo = "bar"; say "Foo = $foo"; } say "Foo = $foo"; # This is line #12 Yes,…
David W.
  • 105,218
  • 39
  • 216
  • 337
2
votes
6 answers

Is it possible to trick Perl to use a variable %INC and still keep the global %INC untouched?

I have just found a script we are using which has a sub that says my %INC in it, where it stores some values about incentives, thus %INC. This never seemed to be a problem, or no-one ever noticed. For me it produced 20 screens of redefine warnings,…
simbabque
  • 53,749
  • 8
  • 73
  • 136
1
vote
3 answers

What does the special variable $@ mean in Perl?

I'm trying to understand the following piece of code: sub foo { ... if ( $@ ) { ... die $@; } }
Jin Kim
  • 16,562
  • 18
  • 60
  • 86
0
votes
2 answers

16-bit status word perlvar

I was reading up on perlvar when i came across this - The status returned by the last pipe close, backtick (`` ) command, successful call to wait() or waitpid(), or from the system() operator. This is just the 16-bit status word returned by the…
Quest Monger
  • 8,252
  • 11
  • 37
  • 43
-4
votes
1 answer

What Perl variables are used for the positions of the start and end of last successful regex match?

What Perl variables are used for the positions of the start and end of last successful regex match?
unixman83
  • 9,421
  • 10
  • 68
  • 102