OK took your code at face value and made some fundamental changes:
and when I ran it got:#!/usr/bin/perl use strict; while ($lines = <DATA>){ $word = split "", $lines; print $word."\n"; } print "\n\n"; exit 0; __END__ tutor teacher tinker sailor
which is not too surprising. So the next set of changes:$ ./fix.pl Global symbol "$lines" requires explicit package name at ./fix.pl line + 5. Global symbol "$word" requires explicit package name at ./fix.pl line +6. Global symbol "$lines" requires explicit package name at ./fix.pl line + 6. Global symbol "$word" requires explicit package name at ./fix.pl line +8. Execution of ./fix.pl aborted due to compilation errors.
and now when we run it we get:#!/usr/bin/perl use strict; while (my $lines = <DATA>){ my $word = split "", $lines; print $word."\n"; } print "\n\n"; exit 0; __END__ tutor teacher tinker sailor
pretty much as you describe. So let's make another change:$ ./fix.pl 6 8 7 8
which gives us:#!/usr/bin/perl use strict; while (my $lines = <DATA>){ my ($word) = split "", $lines; print $word."\n"; } print "\n\n"; exit 0; __END__ tutor teacher tinker sailor
At this point I have a couple of comments to make:$ ./fix.pl t t t s
Hope this helps you on your way....
In reply to Re: while loop returning numbers not strings
by blue_cowdawg
in thread while loop returning numbers not strings
by jaffinito34
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |