Help me understand the Perl script..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help me understand the Perl script..
# 1  
Old 11-22-2011
Help me understand the Perl script..

Code:
#!/usr/bin/perl
use strict;
use warnings;
print "Demo of array slicing \n";
my @abc="a b c d e f g h i j k l m n o p q r s t u v w x y z";
my @a=@abc[1..$#abc];
my @random=@abc[2,3,4,5];
my @comp=@abc[2,4,6,8,10,12,14,16,18,20,22,24];
my @comp1=(@abc[1,3,5],"Hello",@abc[7,9,11]);
print "abc is @abc \n";
print "a is @a \n";
print "random is @random \n";
print "comp is @comp \n";
print "comp1 is @comp1 \n";

can you please help me find the error in the above perl script.

Thank you.


Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 11-22-2011 at 04:03 AM.. Reason: Code tags
# 2  
Old 11-22-2011
Quote:
Originally Posted by dnam9917
#!/usr/bin/perl
use strict;
use warnings;
print "Demo of array slicing \n";
my @abc="a b c d e f g h i j k l m n o p q r s t u v w x y z";
my @a=@abc[1..$#abc];
my @random=@abc[2,3,4,5];
my @comp=@abc[2,4,6,8,10,12,14,16,18,20,22,24];
my @comp1=(@abc[1,3,5],"Hello",@abc[7,9,11]);
print "abc is @abc \n";
print "a is @a \n";
print "random is @random \n";
print "comp is @comp \n";
print "comp1 is @comp1 \n";
can you please help me find the error in the above perl script.
...
Simply feed this program to the perl interpreter and it will find out all the errors for you.

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to understand how the line in perl program works as shell commend

I have a file with two line, one is header, the other actual value: TYPCD|ETID2|ETID|LEG ID|PTYP|PTYP SUB|TRD STATUS|CXL REASON|CACT|CACTNM|ENCD|ENC D NM|TRDR|ASDT|TRDT|MTDT|STDT|LS|SECID|SECID TYP|SECNM|PAR|STCC|MARKET PRICE|DIS MARKET PRICE|MARKET PRICE CURRENCY|SRC OF SETTLEMENT... (2 Replies)
Discussion started by: digioleg54
2 Replies

2. Shell Programming and Scripting

Trying to understand perl error

I am trying to begin to troubleshoot this perl error that I keep getting, yet I get output is produced. The error is Use of uninitialized value in join or string line 175, <MANNO> line 7138 and below is line 175: I am not too sure what the error is but since not every line has an error on it, I... (1 Reply)
Discussion started by: cmccabe
1 Replies

3. Programming

Please help me understand errors in perl program

co #! /usr/bin/perl use strict; use warnings; use diagnostics; my $amount=""; my $bain; ; my $code=""; my $date;my $day;my $line; my $mo; my $LNUM = 0; my $xyz=""; my $yr; $yr = 2015; my $F; my @F; while (<>) { chop; ++$LNUM; @F = split(';'); if ( $F eq "Date" )... (1 Reply)
Discussion started by: hpk
1 Replies

4. Shell Programming and Scripting

Help to understand a script

Hello world! Can someone please explain me how this code works? I'ts supposed to find words in a dictionary and show the anagrams of the words. { part = word2key($1) data = $1 } function word2key(word, a, i, x, result) { x = split(word, a, "") asort(a) ... (1 Reply)
Discussion started by: jose2802
1 Replies

5. Shell Programming and Scripting

Perl syntax that I don't understand.

I'm just trying to confirm that I understand someone's code correctly. If someone has code that says: $foo ||= mysub(); I'm assuming that it means if $foo is nothing or undef, then assign it some value via mysub(). If I'm wrong on this, please let me know. Also, what's the difference... (4 Replies)
Discussion started by: mrwatkin
4 Replies

6. Shell Programming and Scripting

Help to understand the script

Hi All; Is there anybody can explain this script please? trap 'C_logmsg "F" "CNTL/c OS signal trapped, Script ${G_SCRIPTNAME] terminated"; exit 1' 2 trap 'C_logmsg "F" "Kill Job Event sent from the Console, Script ${G_SCRIPTNAME] terminated"; exit 1' 15 (3 Replies)
Discussion started by: thankbe
3 Replies

7. Shell Programming and Scripting

Script to capture date/time in seconds in PERL... Cant understand errors

I'm Using this script to find the time of a file. I'm very much new to PERL and found this script posted by some one on this forum. It runs perfectly fine, just that it gives me following errors with the accurate output as well. I jus want the output to be stored in another file so that i can... (0 Replies)
Discussion started by: bankimmehta
0 Replies

8. Shell Programming and Scripting

perl - understand process status and continue the code execution

Hello, I need advice on how to check if started processes are finished in perl, here's explanation : OS is RHEL 4, perl -v = "This is perl, v5.8.0 built for i386-linux-thread-multi" The logic of the script : #!/usr/bin/perl use warnings; $param1 = $ARGV; $param2 = $ARGV; $param3 =... (2 Replies)
Discussion started by: sysgate
2 Replies

9. Shell Programming and Scripting

perl regexp error , I cant understand what is wrong

perl regexp error , I cant understand what is wrong Hello all I have simple perl regexp that is searching for pattern in string and replace it with the same string + addition string here is what I have : my $rec = q| new Array("Attributes Management" ... (4 Replies)
Discussion started by: umen
4 Replies
Login or Register to Ask a Question