Allison Ogle wrote:
>
> Maybe it is because I am assigning my array to a line from another document
> and not assigning letters dirtectly to the array because it still doesn't
> work. It could be there is something wrong with my code too.
>
> $word=<DATA>; #where <DATA> is the filehandle and therefore $word gets the
> string from the inputfile. Something like ABCD for example
> chomp $word;
> @code = split //,$word; #this assigns thestring to the array @code. The
> values stored in @code are now A B C D
> $y=0;
> if($code[$y] ne "F"){
> print "$code[$y]\n";
> $code[$y]=$code[$y]+1;
> print "$code[$y]\n";}
>
> This prints A and then 1. I can't figure out why. Is there something wrong
> with my coding? Thanks for the help so far.
If you are trying to determine if 'F' is included in $word:
chomp( my $word = <DATA> );
if ( $word =~ tr/F// ) {
# $word has the letter 'F' in it
}
If you want to increment the characters of $word:
chomp( my $word = <DATA> );
$word =~ s/(.)/++($a=$1)/eg;
If you want to increment the characters of $word only if they are not
equal to "F"
chomp( my $word = <DATA> );
$word =~ s/(.)/($a=$1)eq"F"?$1:++$a/eg;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]