Re: printing grep results in Perl

2010-08-02 Thread John W. Krahn
Erik Witkop wrote: There is one more task that I am unable to solve. If $_ was something like FYUY or fO76, I would like to remove the first ^[Ff].But keep the last 3 character. Find and Replace does not work obviously as I would lose those last 3 characters that I want. I researched the map f

Re: printing grep results in Perl

2010-08-02 Thread Brian Fraser
If you don't mind a newbie trying to help... Since you want to replace something, using bare //'s won't do, since that's an alias for m//; m, as in match. You want a substitution, s///. The regex you are looking for should look something like this (Untested code): > s/ > \b #Word boundary

Re: printing grep results in Perl

2010-08-02 Thread Erik Witkop
On Jul 27, 11:34 pm, u...@stemsystems.com ("Uri Guttman") wrote: > > "EW" == Erik Witkop writes: > >   EW> I have spent half the day looking at map and I still don't get it. > > it is easier than you think. > >   EW> I don't get the EXPR versus BLOCK and how I can treat them differently. > > t

Re: printing grep results in Perl

2010-07-27 Thread Uri Guttman
> "EW" == Erik Witkop writes: EW> I have spent half the day looking at map and I still don't get it. it is easier than you think. EW> I don't get the EXPR versus BLOCK and how I can treat them differently. that is mostly a syntax difference. you can have a single expression, then a com

Re: printing grep results in Perl

2010-07-27 Thread Erik Witkop
Hi Uri, I have spent half the day looking at map and I still don't get it. I don't get the EXPR versus BLOCK and how I can treat them differently. I think I am close but my regex is not hitting. /@final_results = map { m/^[a-zA-Z0-9]{3,4}?$/$1/ } @just_cust_codes; foreach (@final_results){ pr

Re: printing grep results in Perl

2010-07-27 Thread Erik Witkop
Thanks Uri. It is time that I learned map. I typically lean on grep and =~ for matching patterns. But map sounds like a great solution. Thanks again. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: printing grep results in Perl

2010-07-27 Thread Uri Guttman
> "EW" == Erik Witkop writes: EW> Thanks Uri. EW> It is time that I learned map. I typically lean on grep and =~ for EW> matching patterns. But map sounds like a great solution. grep is NOT a regex function or has anything to do with regexes. get that false association out of your head

Re: printing grep results in Perl

2010-07-27 Thread Uri Guttman
> "EW" == Erik Witkop writes: EW> So I have an array full of elements in the following format: EW> 32F--sometext--x EW> F32-sometext12-xxx EW> I am only interested in the first portion before the first hyphen. EW> I am able to grep to get that portion. grep doesn't give back

Re: printing grep results in Perl

2010-07-27 Thread John W. Krahn
Erik Witkop wrote: So I have an array full of elements in the following format: 32F--sometext--x F32-sometext12-xxx I am only interested in the first portion before the first hyphen. I am able to grep to get that portion. @grep_results1 = grep(/[a-zA-Z0-9]{2,4}-/, @sho_port_small_array);

Re: printing grep results in Perl

2010-07-27 Thread Jim Gibson
On 7/27/10 Tue Jul 27, 2010 8:21 AM, "Erik Witkop" scribbled: > So I have an array full of elements in the following format: > > > 32F--sometext--x > F32-sometext12-xxx > > I am only interested in the first portion before the first hyphen. > > I am able to grep to get that portion. > >

printing grep results in Perl

2010-07-27 Thread Erik Witkop
So I have an array full of elements in the following format: 32F--sometext--x F32-sometext12-xxx I am only interested in the first portion before the first hyphen. I am able to grep to get that portion. @grep_results1 = grep(/[a-zA-Z0-9]{2,4}-/, @sho_port_small_array); Now I want to print