Anisha Parveen wrote: > > I am a newbie to Perl scripting. I have a script file, with a statement as > below, which i find takes 1sec to execute. As this is called several times > in the script program, this is resulting in a significant delay in the > program. > > As i am new to the scripting language , i am unable to figure out why does > this statement exection takes so much time. > > my $Tmpstr = `$path $HOME/bin/crypt -e -f $_keyfile<<EOF > $str > EOF`; > > I have given a print statement above this line in the script file and when > i give another print statement inside the main of 'crypt' i see it takes one > second, just to enter into the main of that application. > > Can someone provide some pointers into what exactly is done by this portion > of the above statement, > > <<EOF > $str > EOF`;
I am sorry - I failed to answer the specific question that you asked. Perl processes everything between the backticks by first replacing all the variable names with the values of those variables, and then passing the entire string to the command shell to execute it. The sequence starting with <<EOF is a 'here document'. Perl has them too, but in this case it is a Unix here-document which is process by the command shell. Before the command is actioned the sequence is replaced by the text between <<EOF and EOF. Unix is not my primary platform, but I would have thought the code you show was equivalent to my $Tmpstr = `$path $HOME/bin/crypt -e -f $_keyfile$str\n`; I am sure others will correct me if I am wrong. It may help you to add the line print "$path $HOME/bin/crypt -e -f $_keyfile<<EOF $str EOF"; to your program at this point so that you can see the command line that the shell is seeing. HTH, Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/