Re: Good Resource (book) for RegEx

2008-12-04 Thread asmith9983

Hi
From my experience after reading what has been suggested is to try and do some 

real examples which test you knowledge to the limit.
What is the difference between a Basic Regular Expression and an Extended 
Regular Expression  ?  When you think you know, try putting together a 30 
minute talk explaining them which you can give to your dog,cat,parrot, your 
Mother,Granmother, etc.  Explain they will get bored but you will learn about 
your gaps in your knowledge. I recently did something similar to test my 
knowledge.


--
Andrew in Edinburgh,Scotland

On Wed, 3 Dec 2008, Stealth wrote:


On Wednesday 03 December 2008 10:46:21 am Rex wrote:

In order to ramp up quickly on the nitty-gritty of Regular
Expressions in Perl, what will be a good book to start with? I do
have moderate familiarity with RegEx, but am still not using all
that Perl's RegEx engine has to offer. Hence the question.

Thanks,
Rex


Look at the perldoc on regex and get a copy of Mastering Regular
Expressions by Friedl second or third edition.




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: not understanding pipe command

2008-12-04 Thread Raymond Wan


Hi Richard,


Richard wrote:
while going over below example from the book, I am not understanding 
why/how below program works.

Can someone explain this to me in better way?



Have you tried running it?  does it work like what you expect?



what is READER exactly reading from???
and what does print while READER do ? I thought all the print 
happens during factorial() and fibonacci()



It is reading from a pipe.  Take a look at the description of the pipe 
function and what a pipe is (in case you do not know):


http://perldoc.perl.org/functions/pipe.html
http://en.wikipedia.org/wiki/Pipe_(Unix)

 is reading in from the pipe.  Take a look at:

http://perldoc.perl.org/perlop.html#I%2fO-Operators

So, while there is something left to read, print it out.  Go to the 
above link and look at the first shaded box which says The following 
lines are equivalent.  The line that is confusing you is the last line 
in that box...as it says, all of those are equivalent.


to answer your last question, then, the answer is no, the printing 
isn't happening in just the two functions you named.  Take a look at the 
above links to see if they give you a clue.  And if you are wondering 
what the select line is doing, take a look at this and look up the 
select function:


http://perldoc.perl.org/perlfaq5.html#How-do-I-flush%2funbuffer-an-output-filehandle%3f--Why-must-I-do-this%3f

And BTW, you can cut out almost half of the code if you just focus on 
either fibonacci or factorial and not both.


Ray



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Not getting all the element.

2008-12-04 Thread Randal L. Schwartz
 slow == slow leaner [EMAIL PROTECTED] writes:

slow  while (@numbers){

Meta question: Did you see this combination of @... on a web page or book
somewhere, and if so, where?  Or did you construct this through some thought
process, and if so, can you explain it?

I keep seeing this bad meme crop up from time to time, and I'd like to follow
it upstream to see how to prevent this sort of derailing.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: not understanding pipe command

2008-12-04 Thread Richard

Raymond Wan wrote:


Hi Richard,


Richard wrote:
while going over below example from the book, I am not understanding 
why/how below program works.

Can someone explain this to me in better way?



Have you tried running it?  does it work like what you expect?



what is READER exactly reading from???
and what does print while READER do ? I thought all the print 
happens during factorial() and fibonacci()



It is reading from a pipe.  Take a look at the description of the pipe 
function and what a pipe is (in case you do not know):


http://perldoc.perl.org/functions/pipe.html
http://en.wikipedia.org/wiki/Pipe_(Unix)

 is reading in from the pipe.  Take a look at:

http://perldoc.perl.org/perlop.html#I%2fO-Operators

So, while there is something left to read, print it out.  Go to the 
above link and look at the first shaded box which says The following 
lines are equivalent.  The line that is confusing you is the last 
line in that box...as it says, all of those are equivalent.


to answer your last question, then, the answer is no, the printing 
isn't happening in just the two functions you named.  Take a look at 
the above links to see if they give you a clue.  And if you are 
wondering what the select line is doing, take a look at this and look 
up the select function:


http://perldoc.perl.org/perlfaq5.html#How-do-I-flush%2funbuffer-an-output-filehandle%3f--Why-must-I-do-this%3f 



And BTW, you can cut out almost half of the code if you just focus on 
either fibonacci or factorial and not both.


Ray




thanks!! I will study them and let you know.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




issue command once connected IRC

2008-12-04 Thread blake askew
I am trying to write a script that will connect to an IRC channel and check
if the server is a botnet cc server. I have found several templates for
connecting to irc, but they all rely on the MOTD to confirm connectivity.
The problem is often botnets do not set up commands such as MOTD and LUSERS.
I would like to connect to the suspected ip and then issue a few commands
such as LUSER, LIST, WHO, STATS and MOTD, then exit. I am having trouble
finding a reference that discusses how to do this. Most of what I have seen
is for legite IRC, which has the script connect, join a channel and then do
a trival task. Can someone help me modify or point me to a good example of
how to accomplish this?

Here is my IRC subroutine that allows me to connect and then does nothing:

sub irc {

# create the IRC object
my $irc = new Net::IRC;
print (Creating connection to IRC server...);
my $conn = $irc-newconn(Server   = $ip,
 Port = $port,
 Nick = jsxpiid,
 Ircname  = habvhgdjba,
 Username = hvbcsrcx)
or die (Can't connect to IRC server.);
   print (Connected\n);

# action to take once connected
sub on_connect {
my $self = shift;
  print *** Connected to IRC.\n;
}

# print any output data while connected
sub on_init {
my ($self, $event) = @_;
my (@args) = ($event-args);
shift (@args);

print *** @args\n;

}

# handle what happens when receiving public (channel) text.
sub on_public {
my ($self, $event) = @_;
my @to = $event-to;
my ($nick, $mynick) = ($event-nick, $self-nick); # Sender
text,
+Bot nick
my $host=$event-host; # Sender's hostname
my ($arg) = ($event-args); # The message

# parse the channel text
print $nick $arg\n;

}

# handles what happens when receiving private message text
sub on_msg {
my ($self, $event) = @_;
my ($nick) = $event-nick; # Message Sender
my ($arg) = ($event-args); # Message Text
my $host=$event-host;

# Here's where we want to parse message text
print  - $nick -  $arg\n;

}

# use if nick is taken, setting it to an alternate nick.
sub on_nick_taken {
my ($self) = shift;

$self-nick(fxcvbynru);
}

# install handler subs
print (Installing local handlers...);
$conn-add_handler('public', \on_public);
$conn-add_handler('msg',\on_msg);

print (Completed\n);
print (Installing global handlers...);
$conn-add_global_handler([ 251,252,253,254,302,255 ], \on_init);
$conn-add_global_handler(376, \on_connect);
$conn-add_global_handler(433, \on_nick_taken);

print (Completed\n);

# start irc connection
$irc-start;

}
# end irc subroutine


Re: issue command once connected IRC

2008-12-04 Thread blake askew
Seems I was a little too hasty. I was able to change the numerical values
the code was using in connecting to get what I wanted. Now I just need to
figure out how to disconnect once successfully connected. Please let me know
if anyone has any ideas about how I should accomplish this. Thanks

On Fri, Dec 5, 2008 at 12:15 AM, blake askew [EMAIL PROTECTED] wrote:

 I am trying to write a script that will connect to an IRC channel and check
 if the server is a botnet cc server. I have found several templates for
 connecting to irc, but they all rely on the MOTD to confirm connectivity.
 The problem is often botnets do not set up commands such as MOTD and LUSERS.
 I would like to connect to the suspected ip and then issue a few commands
 such as LUSER, LIST, WHO, STATS and MOTD, then exit. I am having trouble
 finding a reference that discusses how to do this. Most of what I have seen
 is for legite IRC, which has the script connect, join a channel and then do
 a trival task. Can someone help me modify or point me to a good example of
 how to accomplish this?

 Here is my IRC subroutine that allows me to connect and then does nothing:

 sub irc {

 # create the IRC object
 my $irc = new Net::IRC;
 print (Creating connection to IRC server...);
 my $conn = $irc-newconn(Server   = $ip,
  Port = $port,
  Nick = jsxpiid,
  Ircname  = habvhgdjba,
  Username = hvbcsrcx)
 or die (Can't connect to IRC server.);
print (Connected\n);

 # action to take once connected
 sub on_connect {
 my $self = shift;
   print *** Connected to IRC.\n;
 }

 # print any output data while connected
 sub on_init {
 my ($self, $event) = @_;
 my (@args) = ($event-args);
 shift (@args);

 print *** @args\n;

 }

 # handle what happens when receiving public (channel) text.
 sub on_public {
 my ($self, $event) = @_;
 my @to = $event-to;
 my ($nick, $mynick) = ($event-nick, $self-nick); # Sender
 text,
 +Bot nick
 my $host=$event-host; # Sender's hostname
 my ($arg) = ($event-args); # The message

 # parse the channel text
 print $nick $arg\n;

 }

 # handles what happens when receiving private message text
 sub on_msg {
 my ($self, $event) = @_;
 my ($nick) = $event-nick; # Message Sender
 my ($arg) = ($event-args); # Message Text
 my $host=$event-host;

 # Here's where we want to parse message text
 print  - $nick -  $arg\n;

 }

 # use if nick is taken, setting it to an alternate nick.
 sub on_nick_taken {
 my ($self) = shift;

 $self-nick(fxcvbynru);
 }

 # install handler subs
 print (Installing local handlers...);
 $conn-add_handler('public', \on_public);
 $conn-add_handler('msg',\on_msg);

 print (Completed\n);
 print (Installing global handlers...);
 $conn-add_global_handler([ 251,252,253,254,302,255 ], \on_init);
 $conn-add_global_handler(376, \on_connect);
 $conn-add_global_handler(433, \on_nick_taken);

 print (Completed\n);

 # start irc connection
 $irc-start;

 }
 # end irc subroutine