2

I am pretty layman to Perl, never used it ...but now I want to use it.

Here is what I did:

http://www.activestate.com/activeperl/downloads

I installed universal version - 5.12.4.1205

To test my program is working, I used the following small program :

dnacon.plx

#i/Perl64/bin/perl -w 
#Example 1-1 Concatenating DNA 

$DNA1 = 'ATTTGGTAAAATGTATA'
$DNA2 = 'TTTTGGGTTTGAAAT'

print "Here are two DNA fragments: \n\n"
print $DNA1,  "\n\n"
print $DNA2,  "\n\n"

$DNA3 = "$DNA1$$DNA2"
print "$DNA3\n\n

When I try to execute it the following is command prompt with errors.

enter image description here

Sorry for too basic question...

EDTIS:

When I just type dnacon.plx, it is seems that it is working, but with error !!! 

c:\myperllessions>dnacon.plx

Scalar found where operator expected at C:\myperllessions\dnacon.plx line 5, nea
r "$DNA2"
        (Missing semicolon on previous line?)
syntax error at C:\myperllessions\dnacon.plx line 5, near "$DNA2 "
Execution of C:\myperllessions\dnacon.plx aborted due to compilation errors.

Am I good to go ??? What could be the error ...compilation errors ????

Edits:

I am using the following now : is this correct ?

#i/Perl64/bin -w 

Edits:

I changed my script to following:

#i/Perl64/bin -w 
#Example 1-1 Concatenating DNA 
use strict; 
use warnings;
$DNA1 = 'ATTTGGTAAAATGTATA';
$DNA2 = 'TTTTGGGTTTGAAAT';

print "Here are two DNA fragments: \n\n";
print $DNA1,  "\n\n"; 
print $DNA2,  "\n\n"; 

$DNA3 = "$DNA1$$DNA2"; 
print "$DNA3\n\n";

I got the following error:

c:\myperllessions>dnacon.plx

Global symbol "$DNA1" requires explicit package name at C:\myperllessions\dnacon
.plx line 5.
Global symbol "$DNA2" requires explicit package name at C:\myperllessions\dnacon
.plx line 6.
Global symbol "$DNA1" requires explicit package name at C:\myperllessions\dnacon
.plx line 9.
Global symbol "$DNA2" requires explicit package name at C:\myperllessions\dnacon
.plx line 10.
Global symbol "$DNA3" requires explicit package name at C:\myperllessions\dnacon
.plx line 12.
Global symbol "$DNA1" requires explicit package name at C:\myperllessions\dnacon
.plx line 12.
Global symbol "$DNA2" requires explicit package name at C:\myperllessions\dnacon
.plx line 12.
Global symbol "$DNA3" requires explicit package name at C:\myperllessions\dnacon
.plx line 13.
Execution of C:\myperllessions\dnacon.plx aborted due to compilation errors.

Is my problem now with programming knowledge or something to do with installation ?????

10
  • Does using the full path to perl work? C:\Perl64\bin\perl?
    – Ry-
    Commented Feb 26, 2012 at 15:13
  • C:\Perl64\bin is where the perl.exe is located at
    – jon
    Commented Feb 26, 2012 at 15:19
  • Yes. Does using that instead of just typing perl work?
    – Ry-
    Commented Feb 26, 2012 at 15:19
  • I tried both C:\Perl64\bin\ and C:\Perl64\bin same error message
    – jon
    Commented Feb 26, 2012 at 15:25
  • 1
    @JohnC Well, you do need semi-colons to end the statements in your code... And you might want to use strict; use warnings;. In your concatenation, you refer to $$DNA2, which of course is incorrect, as it will try to dereference TTTTGGGTTTGAAAT into a scalar variable. Nonetheless, it should recognize perl as a command.
    – TLP
    Commented Feb 26, 2012 at 15:45

3 Answers 3

3

To get perl to be recognized, you must add C:\Perl64\bin to the PATH environment variable. Go to Control Panel > System > Advanced System Settings > Environment Variables. Edit the line containing PATH in the top box marked User variables for <user>, and add ;C:\Perl64\bin (note the semicolon) to the end. Be sure not to corrupt anything that's already there.

The problems you are left with in your latest edit - Global symbol requires explicit package name - are because you have added use strict (a very good thing to do) and you haven't declared your variables. Also the line #i/Perl64/bin -w won't do anything and may as well be removed. Write this instead

use strict; 
use warnings;

my $DNA1 = 'ATTTGGTAAAATGTATA';
my $DNA2 = 'TTTTGGGTTTGAAAT';

print "Here are two DNA fragments: \n\n";
print $DNA1,  "\n\n"; 
print $DNA2,  "\n\n"; 

my $DNA3 = "$DNA1$$DNA2"; 
print "$DNA3\n\n";
4
  • nice ...my first lession is helping me to create curiousity for the language...I did not get results in last command - my $DNA3 = "$DNA1$$DNA2"; print "$DNA3\n\n"; there is an error " Can't use string ("TTTTGGGTTTGAAAT") as a SCALAR ref while "strict refs" in use at C:\myperllessions\dnacon1.plx line 11."
    – jon
    Commented Feb 26, 2012 at 16:29
  • That line should be updated, either with my $DNA3 = "$DNA1\$$DNA2"; or with my $DNA3 = "$DNA1$"."$DNA2" (would prefer the first one). The reason why it gives an error is because parser tries to interpolate the longest string available - effectively ${$DNA2}, the symbolic reference, which is effectively disabled earlier (by use strict).
    – raina77ow
    Commented Feb 26, 2012 at 16:41
  • I suppose it was just a typo, though, as you'd probably intend to just concatenate both strings. Then, again, you may write as my $DNA3 = "$DNA1$DNA2"; or, a bit more readable, my $DNA3 = $DNA1 . $DNA2;
    – raina77ow
    Commented Feb 26, 2012 at 16:46
  • And, by the way, you probably want to write #! instead of #i. The first is so-called hash-bang, used to indicate what program should be used to process the file; afaik, it's of little use at Win platform, though.
    – raina77ow
    Commented Feb 26, 2012 at 16:49
2

Did you try out Strawberry perl? It takes care of setting up the environment vars for you.

1

An environment variable may not be set up yet. Since I no longer use Windows, I cannot give you the exact step by step instructions, but I can tell you, that somewhere in System Properties, you'll find a place to edit the environment variables. Edit the path variable and append 'C:\Perl64\bin\' to it.

P.S.:This is assuming that when you cd to the said path, you are able to run the perl program. If not, something is wrong with the installation. Try re-installing Perl.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.