Perl System command calls to variable

I am new to scripting in Perl so I have a dumb question.
I know I can call system commands using

system("date");

But I am not able to:

  1. set its output to a variable
  2. run in quiet mode(no output to the screen)

The examples i have

#!/usr/bin/perl
print `date +\%y\%m\%d.\%H\%M`;   # OK
x=`date +\%y\%m\%d.\%H\%M`;     #ERROR
print x;

I get something like
Can't modify constant item in scalar assignment

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.

To capture output:

$output = `program args`;   # collect output into one multiline string
@output = `program args`;   # collect output into array, one line per element

But since you just want a date, it would be more efficient to have Perl do it than to fork off a new process.

$ cat ./date_test.pl
#!/usr/bin/perl

use strict;
use warnings;
use POSIX qw(strftime);

my $x;

$x = strftime("%y%m%d.%H%M", localtime());

print "x = $x\n";

exit 0;

$ ./date_test.pl
x = 081110.1019

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`;
}

Try it this way:

`tar zcf "/home/backup/$filename" /scripts 2>/dev/null || exit 0`;

yes! thanks so much