"/usr/local/widgets/data".open.each( s -> s.m!("bleu", s.println) ) Sys::stdall.lines(s -> #s.m!("\d", warn("No digit found.\n")) warn("No digit found.\n") if not s.m?("\d") print("Read: {s}") ) |
fd = open(filename, W) fd.print(s) filename.output(s) |
"~".expand_path # a la ruby |
# default is exception on error => good error messages # with open(f, Safe), no exception on file access |
f = tmpfile("foo") or tmpfile("/tmp/fooXXXXXX") # "foo" gives file $TMPDIR/fooXXXXXX f.output("bar") # output "bar" to a temporary file named f |
# use a string: DATA = q( # your data goes here ) |
l = file.open.lines.map(subst(, "DATE", localtime())) file.output(l) |
f = "numfile".open(R | W | Lock) # Now we have acquired the lock, it's safe for I/O num = f.whole.m("(\d+)") or 0 f.truncate!(0) # truncate! ensure the current seek is <= current size f.print("{num}\n") |
output_handle.autoflush!(True) |
l = [ fh1, fh2, fh3 ].select if fh1.mem?(l) then # do something with fh1 if fh2.mem?(l) then # do something with fh2 |
modem = "/dev/cua0".open(Non_block | W) |
# don't do it, use "whole" with Non_block |
# maybe introduce Out_files !< Out_file |
fh = fdopen(fdnum, R) # open file descriptor 3 for reading |
alias = original outcopy = Sys::stdout.clone incopy = Sys::stdin.clone |