Richard Stallman r...@gnu.org writes:
[[[ To any NSA and FBI agents reading my email: please consider]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
In Perl, how could I write a variable's value into a file,
then run a program and get the output from it into a variable?
I'm printing 3 vars here and reading them back.
--8---cut here---start-8---
#!/usr/bin/perl -w
use strict;
# declare your variables
my ($var1, $var2, $var3);
# Write the variables
open(my $varFile, '', 'variables.txt') or die;
print $varFile 11|222|333;
close $varFile;
# open the file
my $inFile = variables.txt;
open DATA, $inFile or die Can't open file: $!;
while (DATA) {
# chomp the line
chomp;
# split the line into values and assign them to your variables
($var1,$var2,$var3) = split /\|/;
print $var1, $var2, $var3
}
close DATA;
--8---cut here---end---8---
___
gnu-misc-discuss mailing list
gnu-misc-discuss@gnu.org
https://lists.gnu.org/mailman/listinfo/gnu-misc-discuss