in reply to Re: system call with variable interpolation
in thread system call with variable interpolation

ok... but how do i make it do what i want!!!!
  • Comment on Re^2: system call with variable interpolation

Replies are listed 'Best First'.
Re^3: system call with variable interpolation
by JavaFan (Canon) on Jul 15, 2011 at 11:31 UTC
    Some options:
    • Remove the newline.
    • Escape anything special to the shell.
    • Don't use the shell to do something Perl can do trivially.
    • Do it all in the shell. (date >> log.txt)

      i had been doing this. but the $eng_dat and $hindi_dat never get printed. how do i solve this issue.

      #!/bin/env perl open(HANDLE,"<labels");@lines=<HANDLE>;close HANDLE; for($i=0;$i<=$#lines;$i++) { ($english_index,$hindi_index,$nua)=split(/\|/,$lines[$i]); @english=split(/:/,$english_index); @hindi=split(/:/,$hindi_index); print @english,"\n",@hindi,"\n"; for($j=0;$j<=$#english;$j++) { $eng_dat=`grep --regexp '$english[$j]' /home/vikash/pro_1/ +en_1000`; print $eng_dat; } for($j=0;$j<=$#hindi;$j++) { $hindi_dat=`grep --regexp '$hindi[$j]' /home/vikash/pro +_1/HI_1000`; print $hindi_dat; } print "*********************************************************** +******\n"; }
Re^3: system call with variable interpolation
by WValenti (Initiate) on Jul 15, 2011 at 11:31 UTC
    Try:
    system("echo \'$abc\' >> log.txt");
      Why the backslashes?
        Habit. Silly precaution. You're right, they aren't needed in this particular situation.