help-guix
[Top][All Lists]
Advanced

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

Help needed with substitute* command


From: Mortimer Cladwell
Subject: Help needed with substitute* command
Date: Thu, 6 Jan 2022 07:53:17 -0500

Hi,
I do not understand the second substitute* example in the Guix Manual.
I have the executable mysubs.scm:

--mysubs.scm---------------------------------------------------------
(add-to-load-path
"/gnu/store/rjzj1z89jqcb60nhg5gknkibcl84b3jb-guix-29745d23b-modules/share/guile/site/3.0")
(add-to-load-path ".")

(use-modules
    (guix build utils)
    (ice-9 rdelim)
    (ice-9 popen)
    (ice-9 regex) ;;list-matches
    (ice-9 pretty-print))

(define (main args)
  (begin
    (substitute* "./input.txt"
(("hello")
 "good morning\n")
(("foo([a-z]+)bar(.*)$" all letters end)
 (string-append "baz" letters end))))
  (pretty-print "done"))

  ---------end------------------------------------------------------------

  I run this on 2 different inputs representing the two examples in the
manual:


  ---input.txt(1)------
  hello

  ---------------------

  result: good morning


  ---input.txt(2)-------
  foo(abc)bar(def)

  -------------------

  result:  foo(abc)bar(def)

  Why no substitution with the second example?
  Is the letters/letter in the manual a typo?  If I use letter I get
"...unbound variable..."

  Thanks
  Mortimer


reply via email to

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