Thank you Chris. Using strict and warnings should have been the first thing that I did. Thank you also for the code correction.
-----Original Message----- From: Chris Charley [mailto:char...@pulsenet.com] Sent: Friday, December 28, 2012 5:52 PM To: beginners@perl.org Subject: Re: Pattern matching to hash Chris Charley"" wrote in message news >Tim wrote in message news:1356726727.215915...@webmail.reagan.com... >>I hope this is a simple fix. I want to check the beginning characters >>of items in a hash, and compare that to a scalar variable. >>I do not need for the entire value to match; just the first couple of >>characters. >>Tim [snip] >Hello Tim, [snip] >I might have approached it differently. >#!/usr/bin/perl >use strict; >use warnings; >my $prefix_search_list = '03S|04S'; >while (<DATA>) { > print if /^$prefix_search_list/; >} >__DATA__ >05S885858 >03S84844 >foo >bar >04Sbaz A correction to my answer: print if /^$prefix_search_list/; should be: print if /^(?:$prefix_search_list)/; Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/