ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
Lorem Ipsum is simply dummy text of the printing and typesetting indus +try. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled + it to make a type specimen book. It has survived not only five centuries, but also the l +eap into electronic typesetting, remaining essentially unchanged. It was popularised in th +e 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more r +ecently with desktop publishing software like Aldus PageMaker including versions of Lorem I +psum.
sub cleanup_start_words { my $text = $_[0]; my @split = split //, $text; my @keywords = split //, $_[1]; return $text; # see if we have any charachters we wanna skip in the first 10 cha +rachters my $remove_at; my $do_remove = 0; for (my $x = 0; $x < 40; $x++) { if ($split[$x] =~ /[\.\!\?,\)\:\:]/) { $do_remove = 1; $remove_at = $x; } } if ($do_remove) { my $i = 0; foreach (@split) { $i++; if ($i > $remove_at) { last; } if (m/[\.\!\?,]\)\:/) { # print "skipping [last] $_ \n"; last; } else { # print "skipping $_ \n"; } } # didn't seem to work right when doing it in the foreach above, s +o get rid of the # charachters we dont want here for (my $ii = 0; $ii < $i; $ii++) { shift @split; } my $tmp = join("",@split); $tmp =~ s/^[\.\!\?,\)\:]//; $tmp =~ s/^\s+//; return $tmp; } else { return $text; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Way to "trim" part of a phrase?
by BioLion (Curate) on Aug 14, 2009 at 08:25 UTC | |
by ultranerds (Hermit) on Aug 14, 2009 at 08:36 UTC | |
by ultranerds (Hermit) on Aug 14, 2009 at 08:45 UTC | |
by BioLion (Curate) on Aug 14, 2009 at 15:02 UTC | |
|
Re: Way to "trim" part of a phrase?
by graff (Chancellor) on Aug 15, 2009 at 02:05 UTC |