Reputation: 1075
I have a string that repeats from 0 to 31 repeatedly called $GRIBWORKLIST2[$i]
throughout the entire sequence of $i
which goes all the way to 8,000 (@GRIBWORKLIST == 8000
).
Whenever the value of $GRIBWORKLIST2[$i+1]
is going to be 0 that means the values of $GRIBWORKLIST2[$i]
completes a cycle and return to 0 again. For the output whenever this happens I want it to display
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Below is my attempt to do this.
Any ideas how to tweak this so it will give me the desired result?
for ( my $i = 0; $i < @GRIBWORKLIST; $i++ ) {
if ( $i == ( @GRIBWORKLIST - 1 ) ) {
print "----> ---> --> -> "
. $GRIBWORKLIST[$i] . " | "
. $GRIBWORKLIST2[$i] . " || "
. $GRIBWORKLIST2[ $i - 1 ] . "\n";
}
else {
print "----> ---> --> -> "
. $GRIBWORKLIST[$i] . " | "
. $GRIBWORKLIST2[$i] . " || "
. $GRIBWORKLIST2[ $i - 1 ]
. " ||| "
. $GRIBWORKLIST2[ $i + 1 ] . "\n";
my %q = $GRIBWORKLIST2[ $i + 1 ];
print STDOUT "$q\n";
if ( $q == 0 ) {
print STDOUT "$$$$$$$$$$$$$$$$$$$$$$\n";
}
}
}
This gives me the output:
Can't use string ("32289") as a SCALAR ref while "strict refs" in use at ...
Upvotes: 1
Views: 54