Follow us on Twitter!
Become the change you seek in the world. - Gandhi
Friday, April 25, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 20
Guests Online: 19
Members Online: 1

Registered Members: 82908
Newest Member: krishna7799
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Grep and LWP


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-05-10 12:29
Hi,

I am working through Perl and LWP by O'Reilly and I am having troubles with this.

Code
% perl -MLWP::Simple -e "getprint('http://cpan.org/RECENT')||die" | grep Apache





I hadn't come across grep before so I did some research and the syntax for searching arrays but not web files. How do I do this?

EDIT: This is my code:

Code
#!/usr/bin/perl

use strict;
use warnings;
use LWP::Simple;

getprint('http://cpan.org/RECENT') || die;
grep(/Apache/);




Edited by on 21-05-10 12:35
Author

RE: Grep and LWP


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-05-10 12:58
What do you want to do?
Idk much about perl, but grep is a program (and as far as I know) not a command in perl.

| is a pipe, it puts output from 1 command and feeds it into another.
Code
perl -MLWP::Simple -e "getprint('http://cpan.org/RECENT')||die"



That -e runs the perl code in the "'s. The output is then piped into grep which is set to search for 'Apache'.




Author

RE: Grep and LWP


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-05-10 13:03
Thanks for your reply.

Well when I searched I found this:

Code
@LIST = grep(EXPRESSION, @ARRAY);

Example
@myNames = ('Jacob', 'Michael', 'Joshua', 'Matthew', 'Alexander', 'Andrew');
@grepNames = grep(/^A/, @myNames);


Author

RE: Grep and LWP


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-05-10 13:28
Code
#!/usr/bin/perl

use strict;
use warnings;
use LWP::Simple;

my $lol = getprint('http://cpan.org/RECENT') || die;
print grep(/Apache/,$lol);





Is this what you want?
I'm no perl programmer :/




Edited by on 21-05-10 13:28
Author

RE: Grep and LWP


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 21-05-10 13:47
That still displayed all the results and didn't filter them but it did work without errors however. I'll have a play around with it. Thanks Smile

Edited by on 21-05-10 13:57
Author

RE: Grep and LWP

spyware
Member



Posts: 4192
Location:
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 21-05-10 17:41
getprint outputs to STDOUT.



img507.imageshack.us/img507/3580/spynewsig3il1.png
"The chowner of property." - Zeph
[small]
Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.
- Carl Sagan
[center]�Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?� - Ebert[/ce
Author

RE: Grep and LWP

fashizzlepop
Member



Posts: 482
Location: Old folks home.
Joined: 08.04.08
Rank:
Moderate
Posted on 21-05-10 22:58
Grep, in Perl, takes a pattern and an array. It then searches through to find mathces and returns those. Smart matching would also work if you know that better.


"The definition of insanity is doing the same thing over and over again and expecting different results.
~Albert Einstein~


csullivan.codeinspire.net/images/boomsig2.png
fashizzlepop@gmail.com http://csullivan.codeinspire.net/