Dear experts, I am beginner in perl. I want a series of files in which I am changing the coordinates of atoms. The file looks like:

$contrl scftyp=rhf RUNTYP=energy coord=unique MULT=1 icharg=0 $end $system memory=8000000 $end $SYSTEM TIMLIM=600 MEMORY=200000 $END $BASIS EXTFIL=.T. GBASIS=full $END $Data H4 Linear RHF/aug-ccpvtz C1 H 1 0.00 0.0 0.00 H 1 0.00 0.0 2.88 H 1 0.00 0.0 5.76 H 1 0.00 0.0 8.64 $END

Mean I want the symbol $ as part of my files. I have written the following perl script:

#/usr/bin/perl use strict; my $head1="$contrl scftyp=rhf RUNTYP=energy coord=unique MULT=1 icharg +=0 $end $system memory=8000000 $end $SYSTEM TIMLIM=600 MEMORY=200000 $END $BASIS EXTFIL=.T. GBASIS=full $END $DATA H4 Linear RHF/aug-ccpvtz C1 H 1 0.00 0.00 0.00"; my $head2="H 1 0.00 0.00 "; my $head3="H 1 0.00 0.00 "; my $head4="H 1 0.00 0.00 "; my $foot="$END"; for(my $R=0.05;$R<=10.50;$R=$R+0.05){ my $filename=sprintf("H4_Linear_RHF_%05.2f",$R); print "Writing bond length $R to file $filename\n"; open(F,">$filename.inp"); my $Rstring=sprintf("%.2f",$R); my $R1string=sprintf("%.2f",$R*2); my $R2string=sprintf("%.2f",$R*3); my $s= "$head1\n $head2 $Rstring\n $head3 $R1string\n $head4 $R2st +ring\n$foot"; print F "$s"; close (F); }

But when I run this script, I am getting the following errors:

Global symbol "$contrl" requires explicit package name at write_H4_RHF +_aug-cc-pvtz.prl line 4. Global symbol "$end" requires explicit package name at write_H4_RHF_au +g-cc-pvtz.prl line 4. Global symbol "$system" requires explicit package name at write_H4_RHF +_aug-cc-pvtz.prl line 4. Global symbol "$end" requires explicit package name at write_H4_RHF_au +g-cc-pvtz.prl line 4. Global symbol "$SYSTEM" requires explicit package name at write_H4_RHF +_aug-cc-pvtz.prl line 4. Global symbol "$END" requires explicit package name at write_H4_RHF_au +g-cc-pvtz.prl line 4. Global symbol "$BASIS" requires explicit package name at write_H4_RHF_ +aug-cc-pvtz.prl line 4. Global symbol "$END" requires explicit package name at write_H4_RHF_au +g-cc-pvtz.prl line 4. Global symbol "$DATA" requires explicit package name at write_H4_RHF_a +ug-cc-pvtz.prl line 4. Global symbol "$END" requires explicit package name at write_H4_RHF_au +g-cc-pvtz.prl line 15. Execution of write_H4_RHF_aug-cc-pvtz.prl aborted due to compilation e +rrors.

Please suggest me any solution that how to make $ symbol as the part of my files generated using this script without errors. I shall be thankful.


In reply to Help in putting "$" as part of output by arshadmehmood118

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.