[EMAIL PROTECTED] wrote:

> My goal is to take the first 50 characters of a 400 character
> document and write it to a new file.

=cut

############################
##
##  Read the first 50 bytes
##
############################

open D_IN,  "<MyFile.dat" or die "Not found";
open D_OUT, ">MyFile.dat u" or die "Cannot write";

$count = read  D_IN, $fifty, 50;
print D_OUT $fifty;

print "finished; bytes succesfully read: $count";


## - - - - - - - - - - - - - - - - - - - - - - -
=Instead of:

> print "Type in the text you want to break:";
> $string=<STDIN>;
> @fields= split (/ /, $string);
> foreach $field (@fields) {
> print("$field\n");
> }

you can do this:
=cut

#######################################
##
##  Break words by line feeds -- on line is enough:
##
#######################################

print "Type in the text you want to break:";
print join "\n", split (/ /, <>)





Reply via email to