Sponsored Content
Top Forums Programming Please help me understand errors in perl program Post 302931390 by hpk on Monday 12th of January 2015 07:12:48 PM
Old 01-12-2015
Please help me understand errors in perl program

co
Code:
#! /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[0] eq "Date" ) { next; }
    elsif ( $xyz eq "" ) { next; }
    else { 
    foreach (@F) {
        $date   = $F[0];
        $code   = $F[1];
    } 
    } elsif ($LNUM==3) {  #ERROR 1
        $line ="EA:\n";
    $line+="bain+\t"+$bain+"\t";
    print $line."\n";
    } elsif ( $yr != 0 ) { #ERROR 2
    printf( "%02d %02d %2s\n", $mo,$day,$code )."\n";
    print $line."\n";
    }  else { #ERROR 3
    print $line."\n";
  }
}

de

---------- Post updated at 05:12 PM ---------- Previous update was at 05:04 PM ----------

Code:
perl -c traccTest.pl infile outfile produced:
syntax error at line 34 near "} else if"
syntax error at line 38 near "} else if"
syntax error at line 41 near "}"

I cannot find any obvious pair of braces that seems wrong.
Any help would be appreciated
hpk

Last edited by Don Cragun; 01-12-2015 at 09:33 PM.. Reason: Add CODE tags.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. AIX

How to read or understand errors in errpt

Hello, after upgrading the memory to 96GB & 6 Dual Processor for P 550 ( and still not applied the parameters which some experienced posters said in post https://www.unix.com/aix/141835-oracle-database-running-slow-aix-nmon-topas-6.html ) I am getting system dumps. How to understand and... (1 Reply)
Discussion started by: filosophizer
1 Replies

4. 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

5. Shell Programming and Scripting

Help me understand the Perl script..

#!/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; my @random=@abc; my @comp=@abc; my @comp1=(@abc,"Hello",@abc); print "abc is @abc \n"; print "a is @a \n"; print "random is @random \n";... (1 Reply)
Discussion started by: dnam9917
1 Replies

6. Homework & Coursework Questions

program to find and print a Fibonacci sequence of numbers. --Errors

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to convert a C language program over to Sparc Assembley and I am getting Undefined first referenced... (4 Replies)
Discussion started by: kenjiro310
4 Replies

7. Programming

Cannot understand the C errors

I have this peice of code I was hoping someone could look at. I use valgrind ./a.out to test it and it comes up with errors but none that I can understand. Maybe someone here could help me. The code is here: Neo - Pastbin Link Removed - Do Not Use Pastebin in these Forums (12 Replies)
Discussion started by: Errigour
12 Replies

8. Programming

Need program to continue even when encountering errors

I am writing a program, and want to have the option for the program to continue execution even should things go wrong. I use an option --ignore-errors. The problem is what I do when an error occurs, set the values to zero, or fill them up with some values, for example taken from a simple unit... (3 Replies)
Discussion started by: kristinu
3 Replies

9. 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

10. 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
Perl::Critic::Policy::ControlStructures::ProhibitCascadiUserEContributed PerlPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse(3pm)

NAME
Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse - Don't write long "if-elsif-elsif-elsif-elsif...else" chains. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Long "if-elsif" chains are hard to digest, especially if they are longer than a single page or screen. If testing for equality, use a hash lookup instead. If you're using perl 5.10 or later, use "given"/"when". if ($condition1) { #ok $foo = 1; } elsif ($condition2) { #ok $foo = 2; } elsif ($condition3) { #ok $foo = 3; } elsif ($condition4) { #too many! $foo = 4; } else { #ok $foo = $default; } CONFIGURATION
This policy can be configured with a maximum number of "elsif" alternatives to allow. The default is 2. This can be specified via a "max_elsif" item in the .perlcriticrc file: [ControlStructures::ProhibitCascadingIfElse] max_elsif = 3 AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.14.2 2012-06-0Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse(3pm)
All times are GMT -4. The time now is 08:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy