guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to read from a file


From: Cecil Westerhof
Subject: How to read from a file
Date: Fri, 18 Jun 2010 16:31:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

When looking at:
    http://www.gnu.org/software/guile/docs/faq/OLD-guile-faq.html

The following code should work:
    #!/usr/bin/guile \
    -e main -s
    !#
    (use-modules (ice-9 readline))
    (activate-readline)

    (define (main args)
      (let ((input-file  (cadr args))
            (output-file (caddr args)))
        (with-input-from-file input-file
          (lambda ()
            (while (not (eof-object? (peek-char)))
                   (display (read-line))
                   (newline))))))

But when executing it, I get:
    ERROR: Unbound variable: read-line

What am I doing wrong?

Also, it says:
    guile's IO performance is not very fast at the moment, so if you
    have to process large files, you may want to use a different model

What would be a more efficient way to process a file?

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof



reply via email to

[Prev in Thread] Current Thread [Next in Thread]