develooper Front page | perl.beginners | Postings from March 2002

RE: reading one character at a time

Thread Previous | Thread Next
From:
Jason Larson
Date:
March 4, 2002 13:22
Subject:
RE: reading one character at a time
Message ID:
9F560B2FB311D6119A7D00204840E2059F20FE@swbtexch2.swbanktx.com
> -----Original Message-----
> From: Timothy Johnson [mailto:tjohnson@sandisk.com]
> Subject: RE: reading one character at a time
> 
> I can't check this right now, but I believe you can do it like this:
> 
> $Line = "some string";
> @array = split //,$Line;  #split on null
> foreach(@array){
>    $char = read_char($_);
> }

Actually, this will generate an error on the read_char because perl will see
that as a subroutine.  This is almost the same, but will do what you want
without giving errors:

use strict;
my $Line = "some string";
my @array = split (//,$Line);  #split on null
foreach my $char (@array){
  print "$char\n";
}

would return:
s
o
m
e

s
t
r
i
n
g


Hope this helps...
Jason


CONFIDENTIALITY NOTICE:

************************************************************************

The information contained in this ELECTRONIC MAIL transmission
is confidential.  It may also be privileged work product or proprietary
information. This information is intended for the exclusive use of the
addressee(s).  If you are not the intended recipient, you are hereby
notified that any use, disclosure, dissemination, distribution [other
than to the addressee(s)], copying or taking of any action because
of this information is strictly prohibited.

************************************************************************

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About