princepawn has asked for the wisdom of the Perl Monks concerning the following question:
Could someone please help me with this? Thanks!
my @question; sub make_question { my ($question,@answer) = @_; [ $question, \@answer ]; } push @question, make_question 'What is an example of autovivification in Perl?', '***my %x; $x{y}->[2]->{jum} ;', 'sub y { my ($self,$x) = @_ }', 'my $end = ($end > rand) ? $end : rand;'; ; for (@question) { printf "Question %d: %s\n", ++$count, shift @$_; my $HAIR = '^([*]){3}'; my $count; for my $answer (@{$_->[0]}) { if ($mode eq 'key') { if ($answer =~ /$HAIR/) { $answer = $1; } else { $answer = ''; } } else { $answer = s/$HAIR//; } printf "\t%d. %s\n", ++$count, $answer; } print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex to substitute 3 stars at beginnning of string with none?
by Sprad (Hermit) on Apr 23, 2001 at 21:40 UTC | |
by suaveant (Parson) on Apr 23, 2001 at 21:44 UTC | |
by princepawn (Parson) on Apr 23, 2001 at 21:42 UTC | |
|
Re: regex to substitute 3 stars at beginnning of string with none?
by suaveant (Parson) on Apr 23, 2001 at 21:32 UTC | |
by buckaduck (Chaplain) on Apr 24, 2001 at 00:55 UTC | |
by merlyn (Sage) on Apr 24, 2001 at 00:58 UTC | |
|
Re: regex to substitute 3 stars at beginnning of string with none?
by Corion (Patriarch) on Apr 23, 2001 at 21:36 UTC | |
|
Re: regex to substitute 3 stars at beginnning of string with none?
by princepawn (Parson) on Apr 23, 2001 at 21:38 UTC |