in reply to Simple Perl If Else Statement

dude, this?
while (@a = split /\t|$/, <DATA>){ $a[0] =~ /\d/ ? print "K $a[0] : " : next; print "positive number\n" and next if $a[1] == $a[2]; print "negative number\n" and next if $a[1] == $a[3]; print "author didn't specify that option\n"; } __DATA__ K I B S 1 2 2 3 2 4 3 4 3 5 5 2 4 9 1 3

Replies are listed 'Best First'.
Re^2: Simple Perl If Else Statement
by Anonymous Monk on May 16, 2014 at 13:31 UTC
    Thank you Lennotoecom. I'm very new to Perl and still trying to get a handle on all of it. Instead of literally printing "positive number" or "negative number" how would you make the value reported from column K positive or negative depending on the values in I/B and I/S? Regardless this is a really good start and I can probably figure it out from here. Thanks!
      Ummmm, like this?
      while (@a = split /\t|$/, <DATA>){ next if $a[0] =~ /\D/; print "K: $a[0]\n" and next if $a[1] == $a[2]; print "K: -$a[0]\n" and next if $a[1] == $a[3]; print "author didn't specify that option\n"; } __DATA__ K I B S 1 2 2 3 2 4 3 4 3 5 5 2 4 9 1 3