In the terminal, I can access variable $LINES:
$ echo $LINES
39
Running Perl script like so:
#!/usr/bin/env perl
use strict; use warnings;
my $cmd = q|echo $LINES|;
my $lines = `$cmd`;
print "lines: $lines\n";
gives output: lines:. I tried also accessing %ENV, but it does not contain this particular key.
How could I access shell variable $LINES from a Perl script?
export $LINES?LINES=20 my_script.pland it worksLINES=20 my_script.plis equivalent to(export LINES=20; my_script.pl). You can't see non-exported variables.