Once more proving that perl has at least as many ways as there are permutations of people trying to skin the cat to skin a cat...
[EMAIL PROTECTED] wrote on 04/11/2006 10:49:31 PM: > 2. Regexp question (Steve Baldwin) > ---------------------------------------------------------------------- > ------------------------------ > > Message: 2 > Date: Wed, 12 Apr 2006 08:48:11 +1000 > From: "Steve Baldwin" <[EMAIL PROTECTED]> > Subject: Regexp question > To: <[email protected]> > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="us-ascii" > > Hi, > > > > I was trying to build a regexp that removed all vowels from a word except > the first character. So > > > > hello -> hll > > Apple -> Appl > > > > Can someone help ? > > > > Thanks, > > > > Steve not optimal, but undeniably working.... [code] #! /usr/bin/perl use strict; my $string; while ($_ = shift(@ARGV)){ my $res; chomp($_); if($_ =~ s/(^.)//){ $res=$1; } $_ =~ s/[aeiou]//gi; $res.=$_; print "$res\n"; } [/code] [test] Z:\manufaturing-tool>perl vrt.pl would you choose this over the others? 1234 wld y chs ths ovr th othrs? 1234 Z:\manufaturing-tool> [/test] obviously it's possible to make it less typing via removal of some explicit things done showing the use of built-ins. HTH -josh ----------------------------------------- PLEASE NOTE: SeaChange International headquarters in Maynard, MA is moving! Effective March 1, 2006, our new headquarters address will be: SeaChange International 50 Nagog Park Acton, MA 01720 USA All telephone numbers remain the same: Main Corporate Telephone: 978-897-0100 Customer Service Telephone: 978-897-7300 _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
