Path: utzoo!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!bjorn From: bjorn@mips.com (Bjorn Satdeva - /sys/admin Inc) Newsgroups: comp.lang.perl Subject: Repeated patterns Message-ID: <1103@spim.mips.COM> Date: 18 Mar 91 19:55:05 GMT Sender: news@mips.COM Organization: MIPS Computer Systems, Sunnyvale, California Lines: 18 Nntp-Posting-Host: rapid_1.mips.com Originator: bjorn@rapid.mips.com I have a humble hunch, that the following can be done more simple: if ( $Bar =~ /some pattern/ ) { ($Foo = $Bar ) =~ s/some pattern//; $FooBar{$Foo}++; next ; } I have a program which does the above for a number of patterns, and I wonder if there is a way to _not_ write each pattern twice (the code inside the if statment varies enhough that a subroutine is not atractive, even if it looks like from the example). Any ideas? Bjorn Satdeva