Perl: grep in if clause

2009-03-18 Thread Feng Yue
Hi, I have a problem about grep in Perl. I'd like to use grep in a if clause like this if( *grep /^\$/, @array* ){ ... } This works well. However, when I add some more tests in this if, like this: if( *0 || grep /^\$/, @array || 0* ){ ... } this if will never be true even when there

Re: Perl: grep in if clause

2009-03-18 Thread John W. Krahn
Feng Yue wrote: Hi, Hello, I have a problem about grep in Perl. I'd like to use grep in a if clause like this if( *grep /^\$/, @array* ){ ... } This works well. However, when I add some more tests in this if, like this: if( *0 || grep /^\$/, @array || 0* ){ ... } this if will

RE: using Perl grep to populate a scalar

2006-05-10 Thread Smith, Derek
-Original Message- From: Smith, Derek Sent: Tuesday, May 09, 2006 5:22 PM To: Perl Beginners Subject: using Perl grep to populate a scalar All, I am trying to populate a scalar (ideally a hash) using a Perl grep but it is not working. I even tried to use an array and no data

Re: using Perl grep to populate a scalar

2006-05-10 Thread Tom Phoenix
On 5/9/06, Smith, Derek [EMAIL PROTECTED] wrote: if (/(?)vg00/) { That doesn't look right. Why is that question mark inside parentheses? If Perl doesn't complain about that pattern, maybe it should. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL

RE: using Perl grep to populate a scalar

2006-05-10 Thread Smith, Derek
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Phoenix Sent: Wednesday, May 10, 2006 6:35 PM To: Smith, Derek Cc: Perl Beginners Subject: Re: using Perl grep to populate a scalar On 5/9/06, Smith, Derek [EMAIL PROTECTED] wrote: if (/(?)vg00

Re: using Perl grep to populate a scalar

2006-05-10 Thread Tom Phoenix
On 5/9/06, Smith, Derek [EMAIL PROTECTED] wrote: my (@key2,$value2) = 0; This statement is odd. It's making a new array with a single element (which element is zero). I think you mean something like this: my(@key2); my $value2 = 0; $key2[$value2++] = (grep /mirror/gi,

using Perl grep to populate a scalar

2006-05-09 Thread Smith, Derek
All, I am trying to populate a scalar (ideally a hash) using a Perl grep but it is not working. I even tried to use an array and no data was pushed. use strict; use warnings; my @lvs; my @lvaray = qx(bdf); foreach (@lvaray) { if (/(?)vg00/) { push @lvs, (split)[0

perl grep vs unix grep

2005-02-14 Thread Vladimir Lemberg
; Is it possible to modify Perl grep that will work with the same speed as Unix egrep? I know that I can do like: #while (system(egrep,|$pattern,$_[1])){ #push(@list,$_)} but problem that log file has an empty line as record separator Thanks in advance, Vladimir

Re: perl grep vs unix grep

2005-02-14 Thread John W. Krahn
{/\|$pattern/} LOGFILE ; Is it possible to modify Perl grep that will work with the same speed as Unix egrep? AFAIK only perl and awk allow you to read paragraphs. But your real problem is that you are reading the entire file into a list in memory. If you only read one paragraph at a time then your

perl grep..

2004-01-16 Thread Lewick, Taylor
John thank you for the example, one question about the example code... It isn't printing anything to my out file, although it does create it. On the print $out line, I don't need print $out $_\n; do I? Or, the expression /STUFF:STUFF/ What if my line looks like this.. 1 17 7 PM

Re: perl grep..

2004-01-16 Thread John W. Krahn
Taylor Lewick wrote: John thank you for the example, one question about the example code... It isn't printing anything to my out file, although it does create it. On the print $out line, I don't need print $out $_\n; do I? I didn't remove the \n character from the input line so it

Re: Perl grep clone

2003-02-26 Thread lobach
This is what I love about Linux, Perl, and other open source/open help projects... This is exactly what I needed.. Thanks, Steve. John W. Krahn [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: OK, I am not having any luck figuring out the regex stuff.. Can

Perl grep clone

2003-02-25 Thread lobach
another Perl grep(1). =head1 SEE ALSO Lperl(1), Lperlre, Lgrep(1). =head1 AUTHOR Alex Davies [EMAIL PROTECTED] =head1 COPYRIGHT Copyright (c) 1999 Alex Davies. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself

Re: Perl grep clone

2003-02-25 Thread John W. Krahn
[EMAIL PROTECTED] wrote: OK, I am not having any luck figuring out the regex stuff.. Can somebody share with me a perl version of grep that works or tell me the Perl Expression for this. http://www.perl.com/language/ppt/src/grep/index.html