Join us at IRC!
Hacking isn't just Computers & Exploits. It's a Philosophy. - Mr_Cheese
Thursday, May 24, 2012
Navigation
Members Online
Total Online: 27
Web Spiders: 16
Guests Online: 23
Members Online: 4

Registered Members: 70180
Newest Member: RAWRFEARME744798
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Grep and LWP

nodnil
Member



Posts: 7
Location: Australia
Joined: 19.11.08
Rank:
Apprentice
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.

% 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:

#!/usr/bin/perl

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

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


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

RE: Grep and LWP

wolfmankurd
Member



Posts: 1519
Location: UK
Joined: 30.05.05
Rank:
God
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.
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'.




BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.


Widowmakr@hotmail.com http://LetsHackStuff.com
Author

RE: Grep and LWP

nodnil
Member



Posts: 7
Location: Australia
Joined: 19.11.08
Rank:
Apprentice
Posted on 21-05-10 13:03
Thanks for your reply.

Well when I searched I found this:

@LIST = grep(expresblockedsion, @ARRAY);

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

RE: Grep and LWP

wolfmankurd
Member



Posts: 1519
Location: UK
Joined: 30.05.05
Rank:
God
Posted on 21-05-10 13:28
#!/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 :/


BY READING MY POST, YOU ACCEPT IT AS IS AND AGREE TO MY DISCLAIMER OF ALL WARRANTIES, EXPRESS OR IMPLIED, AS WELL AS DISCLAIMERS OF ALL LIABILITY, DIRECT, INDIRECT, CONSEQUENTIAL OR INCIDENTAL, THAT MAY ARISE FROM THE USE OF THIS (MIS)INFORMATION.




Edited by wolfmankurd on 21-05-10 13:28
Widowmakr@hotmail.com http://LetsHackStuff.com
Author

RE: Grep and LWP

nodnil
Member



Posts: 7
Location: Australia
Joined: 19.11.08
Rank:
Apprentice
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 :)

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

RE: Grep and LWP

spyware
Member



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




"The chowner of property." - Zeph
“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
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert
http://bitsofspy.net
Author

RE: Grep and LWP

fashizzlepop
Member



Posts: 482
Location: Old folks home.
Joined: 08.04.08
Rank:
Uber Elite
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~


fashizzlepop@gmail.com http://csullivan.codeinspire.net/
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.