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
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
-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
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
-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
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,
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
;
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
{/\|$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
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
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
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
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
[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
14 matches
Mail list logo