Well, you should specify that you want to print scalar, you're missing the " $ ", the following example works OK :
#!/usr/bin/perl
print `date +\%y\%m\%d.\%H\%M`;
print "\nthis is separator print statement\n";
$x = `date +\%y\%m\%d.\%H\%M`;
print "$x\n";
print "\nthis is the second separator print statement\n\n";
If you want to capture system command's output, you should not use system(), as it only returns the status of wait(). Use backticks instead as shown above.
thanks it worked.
Now i have little problem with output.
I performa backup but tar always give me a output:
"tar: Removing leading `/' from member names"
I tried using &>/dev/null || exit 0 but no help...
sub backup()
{
#Backup a folder and move it
my @f = (localtime)[3..5]; # grabs day/month/year values
my $datex = $f[1] +1 ."-". $f[0];
my $filename = "bkp-scripts_".$datex.".tgz";
#print "$filename\n";
# &> /dev/null" redirects both stdout and stderr to /dev/null. Dosent work!
`tar zcf "/home/backup/$filename" /scripts &>/dev/null || exit 0`;
}