Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Mad-Libs/AWK/mad-libs.awk
Normal file
34
Task/Mad-Libs/AWK/mad-libs.awk
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# syntax: GAWK -f MAD_LIBS.AWK
|
||||
BEGIN {
|
||||
print("enter story:")
|
||||
}
|
||||
{ story_arr[++nr] = $0
|
||||
if ($0 ~ /^ *$/) {
|
||||
exit
|
||||
}
|
||||
while ($0 ~ /[<>]/) {
|
||||
L = index($0,"<")
|
||||
R = index($0,">")
|
||||
changes_arr[substr($0,L,R-L+1)] = ""
|
||||
sub(/</,"",$0)
|
||||
sub(/>/,"",$0)
|
||||
}
|
||||
}
|
||||
END {
|
||||
PROCINFO["sorted_in"] = "@ind_str_asc"
|
||||
print("enter values for:")
|
||||
for (i in changes_arr) { # prompt for replacement values
|
||||
printf("%s ",i)
|
||||
getline rec
|
||||
sub(/ +$/,"",rec)
|
||||
changes_arr[i] = rec
|
||||
}
|
||||
printf("\nrevised story:\n")
|
||||
for (i=1; i<=nr; i++) { # print the story
|
||||
for (j in changes_arr) {
|
||||
gsub(j,changes_arr[j],story_arr[i])
|
||||
}
|
||||
printf("%s\n",story_arr[i])
|
||||
}
|
||||
exit(0)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue