> -----Original Message----- > From: Shaun Bramley [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 25, 2002 4:24 PM > To: [EMAIL PROTECTED] > Subject: Help with regular expression > > > Hi all, > > I'm just looking for some confirmation on my regx. > > I have a list ('1992', '1993 (summer)', '1995 fall') and what > I want to do > is keep only the first four characters. Will the regx work for me? > > @list =~ s/\s*//; > > Again will that turn the list into (1992, 1993, 1995)?
No. 1. You can't have a list on the left side of =~. To apply the substitution over the list, use: s/\s*// for @list; 2. That regex will strip leading whitespace from the string, if any. To grab just the first 4 chars, you don't even need a regex: $_ = substr($_, 0, 4) for $list; HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]