SPUG: Re: Where is grep's return value?
John Subaykan
cansubaykan at hotmail.com
Tue Sep 10 17:57:27 CDT 2002
why not something this:
if 'EXISTING' refers to the contents of a file, then put the lines into an
array and loop over them
open EX, "$filename";
while (<EX>) {
print if /$key/; # this will print the whole line if the line contains
$key
}
close EX;
----- Original Message -----
From: "Orr, Chuck (NOC)" <chuck.orr at attws.com>
To: <spug-list at pm.org>
Sent: Tuesday, September 10, 2002 3:27 PM
Subject: SPUG: Where is grep's return value?
> Hello,
>
> I have something that looks like this:
>
> if (grep("$KEY",EXISTING)){
>
> In the event that this is true, I want to print the data that makes it
true.
> In other words, I want to print the line from EXISTING that contains the
> pattern from the variable $KEY. The problem I am having is figuring out
> where that line is. Is it stored in a variable I don't know about? If
not,
> how can I obtain this data? I realize this is a pretty basic question,
but
> I am having a tough time finding the answer and I need to get this done.
> Any suggestions/help would be greatly appreciated.
>
> Thanks,
> Chuck Orr
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
> Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
> For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
> Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list