Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Using +> for File Read/Write

by pg (Canon)
on Nov 01, 2005 at 21:24 UTC ( #504746=note: print w/replies, xml ) Need Help??


in reply to Using +> for File Read/Write

A quick demo:

use Fcntl 'SEEK_CUR'; use strict; use warnings; open FILE, ">chars"; for (0 .. 25) { print FILE chr(ord('a') + $_); } close FILE; system("type chars"); print "\n"; open(FILE,"+<chars"); while (1) { sysread(FILE, my $chr, 1); last if (!ord($chr)); sysseek(FILE, -1, SEEK_CUR); syswrite(FILE, chr(ord($chr) - ord('a') + ord('A'))); } close FILE; system("type chars");

This prints:

abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://504746]
help
Chatterbox?
[Discipulus]: when I was used to hand writing I reached a very good level, but chars were ~1mm
[LanX]: choroba: another way of gaining XP is up-voting my posts ... (works always!)
[moritz]: works always, one third of the time! :-)

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2017-09-26 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?