Skip to content

Instantly share code, notes, and snippets.

Last active December 16, 2015 16:49
What would you like to do?
Rebol [
comment: "My fledgling Rebol port of this Perl code"
requires: "Rebol/View - for https:// port"
github-support: "Thank you Austin@Github for (initiating) the fix for Rebol syntax highlighting"
split-string: func [text delim /local s coll] [
coll: copy []
parse/all text [
some [copy s [to delim | to end] (append coll s) delim]
pick-random: func [from-series] [
random/seed now ; only needs to be done once per script but here so not forgotten!
pick from-series random length? from-series
spam-text: read
samples: split-string spam-text "|^/"
template: pick-random samples
; below replaces {placeholders} within the input stream (template)
parse/all template [
any [
thru "{" begin: copy s to "}" ending:
begin: back begin ; move back to include {
ending: next ending ; move forward to include }
text: split-string s "|"
move-mark: change/part begin pick-random text ending
:move-mark ; moved the mark to end of change
print template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment