Brian Poellnitz wrote: > OK here goes... > > The sample data below is read into a list, @dir_files. What I'd like > to do is grep() the list so that I'm left with only files that end in > ".wav" and contain certain string. The "certain string" is where I > run into problems. Something like > > grep(/.*\.wav/) > > works fine for getting the items with .wav extensions. What I'd like > to do is also filter for the existence of a string held in the > variable $feed_date (In my test case, $feed_date = "9mar"). I've > tried something like > > grep(/.*($feed_date).*\.wav/) > > but with no luck. My resultant list is empty. Can someone nudge > (shove?) me in the right direction? > > > ------SAMPLE DATA in @dir_files----- > > tns_16Mar_IrishAncestral.mp2 > tns_16Mar_IrishAncestral.wav > tns_16Mar_short.mp2 > tns_16Mar_short.wav > tns_23Feb_MusicalMeltdown.mp2 > tns_23Feb_MusicalMeltdown.wav > tns_23Feb_short.mp2 > tns_23Feb_short.wav > tns_2Mar_NorlandWind.mp2 > tns_2Mar_NorlandWind.wav > tns_2Mar_short.mp2 > tns_2Mar_short.wav > tns_9Mar_SillyWizard.mp2 > tns_9Mar_SillyWizard.wav > tns_9Mar_short.mp2 > tns_9Mar_short.wav > > ---END SAMPLE DATA--- > > I want to end up with : > > tns_9Mar_SillyWizard.wav > tns_9Mar_short.wav > here is a small script which makes assumptions, but give you the selected output as you desire: #!perl
use strict; use warnings; my @dir_files = (); while (<DATA> ) { push( @dir_files, $_); } my $feed_date = q[9Mar]; my @SelectedData = grep(/.*($feed_date).*\.wav/, @dir_files ); foreach ( @SelectedData ) { print $_; } __DATA__ tns_16Mar_IrishAncestral.mp2 tns_16Mar_IrishAncestral.wav tns_16Mar_short.mp2 tns_16Mar_short.wav tns_23Feb_MusicalMeltdown.mp2 tns_23Feb_MusicalMeltdown.wav tns_23Feb_short.mp2 tns_23Feb_short.wav tns_2Mar_NorlandWind.mp2 tns_2Mar_NorlandWind.wav tns_2Mar_short.mp2 tns_2Mar_short.wav tns_9Mar_SillyWizard.mp2 tns_9Mar_SillyWizard.wav tns_9Mar_short.mp2 tns_9Mar_short.wav Output: tns_9Mar_SillyWizard.wav tns_9Mar_short.wav Wags ;) > > > > ===================================== > Brian Poellnitz > -Production Coordinator: Alabama Public Radio > -On Air Host: A Case Of The Blues > > 205-348-8026 (my desk) > 205-348-6644 (APR main number) > [EMAIL PROTECTED] > > Alabama Public Radio > Box 870370 > University of Alabama > Tuscaloosa, AL 35487 > ============================================ > > Tact is the unspoken part of what you're really thinking. > > ============================================ ******************************************************* This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. ******************************************************* -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>