in reply to An Elegance Question
Another interesting way. This will take anything in [],
and prompt for a word of that type. This eliminates the
need to hard-code adjectives, adverbs, nouns, etc.
Your file can look like
This allows you more flexibility in what you want them to inputThe [noun] [past-tense verb] over to [proper noun] and soon [future-tense verb] to the [place].
!/usr/bin/perl -w use strict; my $story; { local $/ = undef; #Get everything $story = <>; } while($story =~ /\[(.*?)\]/g) { #Find anything in [] print "Give me a $1: "; my $val = <STDIN>; #Get a value for it chomp $val; $story =~ s/\[$1\]/$val/; #And sub it in } print $story;
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: Re: An Elegance Question
by Simplicus (Monk) on Apr 13, 2000 at 23:07 UTC | |
RE: Re: An Elegance Question
by Simplicus (Monk) on Apr 13, 2000 at 23:34 UTC |
In Section
Seekers of Perl Wisdom