#!/usr/bin/perl
use strict;
use warnings;
# Assumptions
my $dir = '/home';
print "\$dir = [$dir]\n";
my $file = 'test.dat';
print "\$file = [$file]\n";
# Proceed
my $regexpaaa=qq/-i -e \'\^AAA=\'/ -e \'\^XXXXX\ AAA=\'/;
print "\$regexpaaa = [$regexpaaa]\n";
my @command2 = ("ssh us@pp -o BatchMode=yes grep $regexpaaa $dir/$file");
print "\@command2:\n";
my $command2idx = 0;
foreach my $command2 (@command2) {
print " [$command2idx] = [$command2]\n";
$command2idx++;
}
exit;
####
S:\Steve\Dev\PerlMonks\P-2017-06-08@1920-ssh-grep>perl grep2.pl
syntax error at grep2.pl line 13, near "qq/-i -e \'\^AAA=\'/ -e "
Can't find string terminator "'" anywhere before EOF at grep2.pl line 13.
S:\Steve\Dev\PerlMonks\P-2017-06-08@1920-ssh-grep>
####
#!/usr/bin/perl
use strict;
use warnings;
# Assumptions
my $dir = '/home';
print "\$dir = [$dir]\n";
my $file = 'test.dat';
print "\$file = [$file]\n";
# Proceed
my $regexpaaa=qq/-i -e \'\^AAA=\'/;
print "\$regexpaaa = [$regexpaaa]\n";
my @command2 = ("ssh us\@ip -o BatchMode=yes grep $regexpaaa $dir/$file");
print "\@command2:\n";
my $command2idx = 0;
foreach my $command2 (@command2) {
print " [$command2idx] = [$command2]\n";
$command2idx++;
}
exit;
####
S:\Steve\Dev\PerlMonks\P-2017-06-08@1920-ssh-grep>perl grep1.pl
$dir = [/home]
$file = [test.dat]
$regexpaaa = [-i -e '^AAA=']
@command2:
[0] = [ssh us@ip -o BatchMode=yes grep -i -e '^AAA=' /home/test.dat]
S:\Steve\Dev\PerlMonks\P-2017-06-08@1920-ssh-grep>