Paul Harwood wrote: > Thanks. > > Can I substitute /pattern/ with a scalar though?
Yes. grep $_ eq 'string', @list > > -----Original Message----- > From: Bob Showalter [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 05, 2003 5:24 AM > To: Paul Harwood; Beginner Perl > Subject: RE: Regex search using scalar > > Paul Harwood wrote: > > I would like to enumerate a list and search through each element > > like so: > > > > > > > > If (/$logs[i]/) > > > > > > > > { # code} > > > > > > > > > > > > I know the syntax is wrong so I was hoping someone could explain > > how to do this. > > If I understand correctly, you want to use grep(): > > for (grep /pattern/, @list) { > ... do something with $_ ... > } > > perldoc -f grep -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]