arshadmehmood118 has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help in putting "$" as part of output
by hexcoder (Curate) on Mar 11, 2016 at 08:59 UTC | |
|
Re: Help in putting "$" as part of output
by Discipulus (Canon) on Mar 11, 2016 at 08:23 UTC | |
|
Re: Help in putting "$" as part of output
by Marshall (Canon) on Mar 11, 2016 at 09:16 UTC | |
|
Re: Help in putting "$" as part of output
by Marshall (Canon) on Mar 13, 2016 at 04:48 UTC | |
|
Re: Help in putting "$" as part of output
by perlfan (Parson) on Mar 12, 2016 at 00:38 UTC | |
by Anonymous Monk on Mar 12, 2016 at 01:15 UTC | |
by perlfan (Parson) on Mar 15, 2016 at 14:24 UTC |