Re: Run a shell command in Perl

2014-04-18 Thread Billy O'Connor
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


Run a shell command in Perl

2014-04-17 Thread Richard Stallman
[[[ 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?

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use Ekiga or an ordinary phone call.


___
gnu-misc-discuss mailing list
gnu-misc-discuss@gnu.org
https://lists.gnu.org/mailman/listinfo/gnu-misc-discuss