RE: Hi & a question

2003-12-26 Thread Pandey Rajeev-A19514
hey !!!

do you celebrate only perl even in the christmas vacation !!!
Take a break !! Have a kit kat christmas cake.
Merry Christmas to this perl group 

Rajeev 

-Original Message-
From: John McKown [mailto:[EMAIL PROTECTED]
Sent: Friday, December 26, 2003 11:08 PM
To: Perl Beginners Mailing List
Subject: Hi & a question


I'm new here and a very novice Perl coder. And I have a question, of 
course .

Is it more "Perl-like" to get information from the shell via UNIX 
Environment Variables or via the command line? For an example, I have 
writing a Perl program which reacts to messages sent to it. It has four 
input parameters. The current program gets this information, which is two 
distinct subdirectories, a port number, and an IP address, via four 
different environment variables. My question is should I do it that way or 
should I pass this information in via the command line. 

E.g.

export DIR1=...
export DIR2=...
export IPADDR=...
export IPPORT=...
perl-script.perl

or

perl-script.perl DIR1 DIR2 IPADDR IPPORT

Although my current code uses the first way, I'm beginning to think that 
the second is preferrable because it would be more portable to non-UNIX 
environments.

I hope everybody is having a good holiday.

--
Maranatha!
John McKown


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Help needed on perl wrappers

2003-12-09 Thread Pandey Rajeev-A19514
Hi,

I was interested in formatted display on screen.

I can display ONE text paragraph in any part of the screen with Text::wrap. My 
question was how to adjust MANY such independent paragraphs in one screen (exactly in 
a newspaper format where you have 8-10 columns of news items on a single page).

I wanted to know is there something like Text::wrap which can do this. Or Text::wrap 
can handle only one paragraph. If nothing like that exists then I might have to give 
up Text::wrap and use my own logic to adjust it.

Moreover, I also wanted to use Term::Size to adjust the text with changing screen size.

Is there any convenient way to do this ? I was looking for readymade stuff.
Please suggest.

Regards
Rajeev

-Original Message-
From: Tom Kinzer [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 12:05 PM
To: [EMAIL PROTECTED]
Subject: RE: Help needed on perl wrappers



I'm trying to figure out WHY you would ever want to create what you are
asking for.  Why-- is a good question here, because there may be a way to
get to the real goal instead of creating this.  For instance if it's just
going into an HTML document, a table of course, would be easier.  Just an
example, so WHY are you wanting to do this?

If this is really want you want, then: Do you really want a ragged left on
the right column?  Do you really want to use tabs?  I'm thinking spaces
would be easier to deal with for this problem and could buy you a justified
left margin on the right column.

More info please.

-Tom Kinzer

-Original Message-----
From: Pandey Rajeev-A19514 [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 09, 2003 8:16 PM
To: '[EMAIL PROTECTED]'
Subject: Help needed on perl wrappers


Hi,

I have a text that I read from a file. I want to display the text on the
screen in a column in a newspaper style.
I do it like this

$initial_tab = "\t\t";
$subsequent_tab = "\t\t";
print wrap($initial_tab, $subsequent_tab, @text1);
print fill($initial_tab, $subsequent_tab, @text1);

It will print like this ...
I am a boy and I go to school
everyday. I have to do a lot of
homework and I dont get time
to play these days.


But if I have more than one independent text i.e. @text2, @text3 to be
displayed in different columns, then what shall i do.
I want something like this ...

I am a boy and I go to schoolShe is a girl and she
also goes
everyday. I have to do a lot ofto school. I do all
her homework
homework and I dont get time   and she gets plenty of
time to
to play these days   play.

Is there any mechanism to achieve this ?

Best Regards
Rajeev

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



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


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




Help needed on perl wrappers

2003-12-09 Thread Pandey Rajeev-A19514
Hi,

I have a text that I read from a file. I want to display the text on the screen in a 
column in a newspaper style.
I do it like this

$initial_tab = "\t\t";
$subsequent_tab = "\t\t";
print wrap($initial_tab, $subsequent_tab, @text1);
print fill($initial_tab, $subsequent_tab, @text1);

It will print like this ...
I am a boy and I go to school
everyday. I have to do a lot of
homework and I dont get time
to play these days.


But if I have more than one independent text i.e. @text2, @text3 to be displayed in 
different columns, then what shall i do.
I want something like this ...

I am a boy and I go to schoolShe is a girl and she also goes
everyday. I have to do a lot ofto school. I do all her homework
homework and I dont get time   and she gets plenty of time to
to play these days   play. 

Is there any mechanism to achieve this ?

Best Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Need help on perl graphical interface

2003-11-05 Thread Pandey Rajeev-A19514
Hi,

I don't know anything about perl graphics. I would explain excatly what I want.

I want to develope a interactive graphical interface which can display all the nodes 
in a network in a tree representation. 
I should be able to draw that tree upon reading a data base (or real time data). 
I should be able to click on to a particular node in that network and should be able 
to do what I wish on that node( i.e. to make it interactive and what I wish to do is 
not that important right now).

Can any one tell me is it possible in perl ? I have the necessary backend support in 
perl.

Do you recommend to use XML or Jawa or Xwindows instead ? 

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



regex. help

2003-09-24 Thread Pandey Rajeev-A19514
Hi ,

I have a question regarding matching strings that have embeded perl special characters.

$abc = 'MC10.G(12)3c';

$efg = 'MC10.G(12)3c';

Now I want to check whether they are same or not by doing

if ($abc =~ /$efg/) { do something;}

For this I need to insert a '\' before every special char. 

Can some one tell me an easy way to do ?

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Need help on Hash Slices. !!

2003-09-23 Thread Pandey Rajeev-A19514
Hi Bob,

There is a simple problem here 

The file is -->

TEST_CASE_FILE_PATH = ../testcases/CAT/
TEST_CASE_OUTPUT_PATH = ../testlogs/
SERVER_NAME = sunomcr

$VAR1 = 'TEST_CASE_FILE_PATH';
$VAR2 = '../testcases/CAT/';
$VAR3 = 'SERVER_NAME';
$VAR4 = 'sunomcr';
$VAR5 = 'TEST_CASE_OUTPUT_PATH';
$VAR6 = '../testlogs/';

foreach $key (%hash_line) { print "$key => $hash_line{$key}\n";}
The output is like this -->

TEST_CASE_FILE_PATH => ../testcases/CAT/
../testcases/CAT/ => 
SERVER_NAME => sunomcr
sunomcr => 
TEST_CASE_OUTPUT_PATH => ../testlogs/
../testlogs/ => 

It seems it takes all the elements in the list as the key.

Regards
Rajeev

-Original Message-----
From: Bob Showalter [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 23, 2003 8:56 PM
To: 'Pandey Rajeev-A19514'; [EMAIL PROTECTED]
Subject: RE: Need help on Hash Slices. !!


Pandey Rajeev-A19514 wrote:
> Hi,
> 
> I have a list like
> 
> @list = ( "key1: Vlan1 :0989\n"
>   "key2: Vlan2 :0989\n"
>   "key3: Vlan3 :0989\n"
>   "key4: Vlan4 :0989\n");
> 
> I wanted to make a hash with keys as key1, key2 , key3, key4.
> 
> I want to write something like this :
> **
>   my @keys, @values, @key_to_value;
>   (@keys, @values) = map /(key\d+): (\w+).*?$/, @list;
>   @[EMAIL PROTECTED] = @values;
> 
> But the problem is the map function just creates one list
> i.e. @keys .. so I am not able to make the hash.
> 
> ie .. I want to extract @keys and @values in one go and then
> use the HASH SLICE to get the desired result.
> 
> Can some one help me. The only this is I don't want to
> extract @keys and @values separately.

Since map is returning a list in the form key, value, key, value, ...
you can just assign directly to a hash:

   my %key_to_value = map /(key\d+): (\w+)/, @list;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Need help on Hash Slices. !!

2003-09-23 Thread Pandey Rajeev-A19514
Hi,

I have a list like

@list = ( "key1: Vlan1 :0989\n"
"key2: Vlan2 :0989\n"
"key3: Vlan3 :0989\n"
"key4: Vlan4 :0989\n");

I wanted to make a hash with keys as key1, key2 , key3, key4.

I want to write something like this :
**
  my @keys, @values, @key_to_value;
  (@keys, @values) = map /(key\d+): (\w+).*?$/, @list;
  @[EMAIL PROTECTED] = @values;

But the problem is the map function just creates one list i.e. @keys .. so I am not 
able to make the hash.

ie .. I want to extract @keys and @values in one go and then use the HASH SLICE to get 
the desired result.

Can some one help me. The only this is I don't want to extract @keys and @values 
separately.

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Help needed on Telnet.pm

2003-09-22 Thread Pandey Rajeev-A19514
Hi,

I need an urgent help and direction regarding capture of scrolling text using the 
Telnet.pm module.

Apart from the False Telnet servers(unusual ascii characters) described in the module, 
ther is one more scenario where the output on a telnet session shell does not get 
captured.  

Does Telnet.pm capture output from other than the STDOUT ?

I have a case where I telnet to a router through a console connection. All commands 
work well and returns the output. 
But, there is a special command that turns on the monitoring system of that machine. 
So some text keep on scrolling (text that appear even without issuing any user 
command). Such texts are not captured by telnet module. 

I am not doing any mistake in setting the prompt.

In expect language, I am able to capture the scrolling text but not in Telnet.pm.

I am in urgent need.

Please tell me if I am missing something.

Thanks in advance.
Rajeev


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Problem with input record separator

2003-09-21 Thread Pandey Rajeev-A19514
Hi Paul,

I has tried the $/ = ""; but it did not work because my logfile itself was faulty.
The problem is that between two paragraphs, the empty line does not match /^\n$/ but 
it matches some spaces too i.e. /^\s*\n$/. 

Probably that is the reason it fails. I guess. but I cant give any regex for $/ 

currently I am making record by running in a loop. Do you feel that I am missing 
something silly.

Regards
Rajeev

-Original Message-
From: Paul Johnson [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 21, 2003 5:42 PM
To: Pandey Rajeev-A19514
Cc: [EMAIL PROTECTED]
Subject: Re: Problem with input record separator


On Sun, Sep 21, 2003 at 04:11:30PM +0530, Pandey Rajeev-A19514 wrote:

> I am stuck with input record separator

You are correct that you should be changing the IRS ...

> I have a file .. say "abc"
> 
> ***
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> ***
> 
> I read the file in @lines.
> open(IN, "abc);
> @lines = ;

... but you haven't done so.

Set $/ = ""; before reading the file to read it in paragraph mode.  Or
run with perl -00 ...

perldoc perlvar for more info on $/
perlvar perlrun for more info 0n -00

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Problem with input record separator

2003-09-21 Thread Pandey Rajeev-A19514
Hi ,

I am stuck with input record separator

I have a file .. say "abc"

***











***

I read the file in @lines.
open(IN, "abc);
@lines = ;

Now I want to split the file into three records (three other lists).

@a = ("\n",
  "\n",
  "\n");

@b and @c similarly should contain the other two records.

I tried to join the whole file and then tried to split it on "\n\n" but could not get 
anything..

Any help is welcome.

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Help on processinf Date String.

2003-09-09 Thread Pandey Rajeev-A19514
Hi ,

I have to start with input as date string which I need to process.
$date1 = "Wed Sep 10 15:51:50 CST 2003";
$date2 = "15:52:00.885 cst Wed Sep 10 2003";

I have to find the difference in between the two dates. Which is the best module to do 
that and probably a sample code would do more help.

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



search replace

2003-09-06 Thread Pandey Rajeev-A19514
Hi ,

How do I search replace text in a file from a perl script. i.e. by opening the file in 
write mode and then do a search replace.

I don't want to do a command line search replace.

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



please help !! pattern match

2003-09-05 Thread Pandey Rajeev-A19514
Hi ,

I need some help me to extract a pattern. The delimiters is a pair of "abcd" and 
"efgh". Can some one help me with an efficient use of Greedy and non greedy matches, 
look ahead and lookbehind features. 

I want the smallest match involving the two delimiters. I want all the matches. i.e. 
fisrt match , last match and all ther other matches in between. 


Here is what I tried to extract the first match and the results(a bad one) I got.

$abc = <

Need help on modules

2003-07-31 Thread Pandey Rajeev-A19514
Hi,

I want to create a module, say ABC.pm.
I dont want to build and install the module.

I want to use a function xyz() of the module ABC in some other script.
AND, I want to call the function as 
xyz();
instead of
ABC::xyz();

Can anyone tell me how to do that without installing the module ?
Is it sufficient to push the Module path in @INC ?

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Problem with pass by reference

2003-07-28 Thread Pandey Rajeev-A19514
Hi,

The dimension of the data increases by each pass by reference.

In this subroutine, @FORMATTED_OUTPUT was filled up as a 2 dimensional array 
$FORMATTED_OUTPUT[$i][$j].
sub ABC {
.. SOME CODE
return (\$rows, \$cols, [EMAIL PROTECTED]);
}

In subroutine DEF, ABC is called, and the dimension of @buffer increased to 3, ie it 
became a three dimensional array and the array elements can be accessed as 
$buffer[0][$i][$j].
sub DEF {
my @buffer, $row, $col;

($$row, $$col, @buffer) = ABC('INPUT', 'Interface', 'OUTPUT', 'IP-Address');
PRINT (\$$row, \$$col, [EMAIL PROTECTED]);
}

sub PRINT {
 do the prinnting of the buffer whose row and columns are also passed.
 Here the dimension of @buffer becomes 4.
 here the array elements can be accessed as $buffer[0][0][$i][$j].
}


How can I avoid the increases in dimension of datatype when passed by reference.
Please help.

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Please help !! Socket

2003-07-17 Thread Pandey Rajeev-A19514
Hi,

I want to create differnent Socket Handles in a function and the function creates the 
created Socket Handle..
my $sock = gensym(); 

I am getting the same instance of Handle "S".

Please some one tell me how to create different instances of sockets in perl.

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Help !!! on sockets

2003-07-16 Thread Pandey Rajeev-A19514
Hi,

I am sorry to inform you so late.

Actually, my subroutine "returned" before printing. Else everything was correct.

Thanks for your help.

Regards
Rajeev

-Original Message-
From: Kipp, James [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 17, 2003 12:33 AM
To: Pandey Rajeev-A19514; [EMAIL PROTECTED]
Subject: RE: Help !!! on sockets


 
> When I print the @buffer outside the while loop , I am not 
> getting the output.
> 
> Note : The commented line i.e. #print "Server: $_"; works and 
> prints all the lines read from the socket.
> 
> Please somebody tell me what error have I been making.
> 
> Regards
> Rajeev
> 
> sub send_msg {
> $sock = shift @_;
> $msg = shift @_;
> 
> my @buffer;
> 
> select($sock);
> $| = 1;
> select(STDOUT);
> 
> print $sock $msg, "\n";
> while (<$sock>) {
> if( $_ =~ /^DONE$/) {
> print "Server: $_";
> return;
> }
> #print "Server: $_";
> push @buffer, $_;
> }
> print @buffer;
> }
 
try: $buffer .= $_; 
print $buffer;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Help !!! on sockets

2003-07-16 Thread Pandey Rajeev-A19514
Hi ,

I have done a silly mistake which am not able to detect.

Below is a subroutine, that takes the Socket_Handle and the Message as arguments.
First i send the message and then I start reading the Socket in a while loop until 
DONE is detected.
I am pushing each line in a @buffer.

When I print the @buffer outside the while loop , I am not getting the output.

Note : The commented line i.e. #print "Server: $_"; works and prints all the lines 
read from the socket.

Please somebody tell me what error have I been making.

Regards
Rajeev

sub send_msg {
$sock = shift @_;
$msg = shift @_;

my @buffer;

select($sock);
$| = 1;
select(STDOUT);

print $sock $msg, "\n";
while (<$sock>) {
if( $_ =~ /^DONE$/) {
print "Server: $_";
return;
}
#print "Server: $_";
push @buffer, $_;
}
print @buffer;
}

*

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Socket Problem (I got the answer) Thanks

2003-07-15 Thread Pandey Rajeev-A19514
Hi ,

I got the answer Thanks

Please ignore the previous mail from me 

rgds
rajeev
-Original Message-
From: Pandey Rajeev-A19514 
Sent: Tuesday, July 15, 2003 3:20 PM
To: [EMAIL PROTECTED]
Subject: Socket Problem


Hi,

I have a problem with sockets that goes like this..
I want to create a socket and then want to use it at a later time to send messages..
How do I save sockets .? It seems that I can not save "S". S is a constant ... I dont 
know what wrong am I doing..

Can some one help me ? I need to create many sockets and store them ..

I want my function calls as shown below ..
$sock = perl_client($ip_addr , $port_num);
send_msg($sock, $message);

I used a standard code for socket creation 

sub perl_client {
..
...

$sockaddr = 'S n a4 x8';
$this = pack($sockaddr, AF_INET, 0, $thisaddr);
$that = pack($sockaddr, AF_INET, $port, $thataddr);

if (bind(S, $this)) {
print "Bind succeeded.\n";
}
else  {
die $!;
}

if (connect(S, $that)) {
print "Connect succeeded.\n";
return S;
}


sub send_msg {
(S, $msg) = @_;

select(S);
$| = 1;

select(STDOUT);

if ($child = fork) {

print S $msg;
sleep 3;
do dokill();
}
else {
while (<$sock>) {
print "Server: S";
}
}

}
*

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Socket Problem

2003-07-15 Thread Pandey Rajeev-A19514
Hi,

I have a problem with sockets that goes like this..
I want to create a socket and then want to use it at a later time to send messages..
How do I save sockets .? It seems that I can not save "S". S is a constant ... I dont 
know what wrong am I doing..

Can some one help me ? I need to create many sockets and store them ..

I want my function calls as shown below ..
$sock = perl_client($ip_addr , $port_num);
send_msg($sock, $message);

I used a standard code for socket creation 

sub perl_client {
..
...

$sockaddr = 'S n a4 x8';
$this = pack($sockaddr, AF_INET, 0, $thisaddr);
$that = pack($sockaddr, AF_INET, $port, $thataddr);

if (bind(S, $this)) {
print "Bind succeeded.\n";
}
else  {
die $!;
}

if (connect(S, $that)) {
print "Connect succeeded.\n";
return S;
}


sub send_msg {
(S, $msg) = @_;

select(S);
$| = 1;

select(STDOUT);

if ($child = fork) {

print S $msg;
sleep 3;
do dokill();
}
else {
while (<$sock>) {
print "Server: S";
}
}

}
*

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Regex parsing question

2003-07-11 Thread Pandey Rajeev-A19514
Hi Rob,

Thanks ! That was helpful. 
Do we have a lex and Yacc equivalent in Perl ?

I am writing an automation tool based on Client and server for Cisco devices.
I am doing the testcase parsing in Lex and Yacc (flex and bison) to create the parser 
tree and then I user the server written in Perl to do all the regex jobs. ( More 
details are irrelevant in this context).

In my test case file I wanted to specify a regular expression equivalent (a one liner) 
that can be generic enough for any kind of pattern matching. 

For eg. If my buffer contains something like this

Vlan1  10.20.0.53  YES NVRAM  upup  
Vlan2  10.21.0.1   YES NVRAM  upup  
Vlan5  10.20.0.17  YES NVRAM  upup  
Vlan6  10.3.4.1YES manual administratively down down
Vlan7  192.168.190.5   YES NVRAM  updown
Vlan8  10.21.4.129 YES NVRAM  updown 
*
and I want to list out all the A Vlan which is up/up then I write an regular exp as
(Not writing the actual syntax of my testcase file)
Vlan(\s|\d|\.|\w|)*up(\s|\d|\.|\w|)*up

and I get the result as
Vlan1  10.20.0.53  YES NVRAM  upup  
Vlan2  10.21.0.1   YES NVRAM  upup  
Vlan5  10.20.0.17  YES NVRAM  upup  

This was a simpler one..
But there are certain set of patterns which starts somwhere in one line, may have 
intermediate pattern in the middle lines and will end in another line. 

I just wanted a simple way of writing a oneliner regex for any kind of pattern 
matching such that I dont have to write any if-else code in perl.

I needed a generic one liner GENERIC-REGEX such that

if($buffer =~ /GENERIC-REGEX/) {
 print "My job is done";
}

Is it possible.. or  will I have to dig deeper in regex fundamentals.

Thanks for ur help.

Regards
Rajeev

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 10:46 PM
To: [EMAIL PROTECTED]
Subject: Re: Regex parsing question


Rob Dixon wrote:
> Perl wrote:
> > I am attempting to parse a log file that looks something like:
> >
> > 759033281 TE18  constructor - add to MDBTable
> > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD
> > 759033281 TE18  AddRef=2
> > EX:/O=MSGENG/OU=EUROPE/CN=RECIPIENTS/CN=PHARWOOD
> > 759033281 TE18  S-REXCH-MSG-07
> > 759033281 TE18  S-REXCH-MSG-06
> > 759033281 TE18  C-REXCH-MSG-07
> > 759033281 TE18  C-REXCH-MSG-06
> > 759033281 TE18  Vups_MailboxLogon done 0x0
> > 759033281 TE18  C-REXCH-MSG-06
> > 759033281 TE18  No timestamp for thread
> > 759033281 TE18  IMAPISession::OpenMsgStore  M
> > 109 Q  0
> >
> >
> > The only lines I am interested in are ones that have "PHARWOOD"
> > followed by a line that has "OpenMsgStore" in it.
> >
> > If I could explain this in English, I would want to say:
> >
> > "Search for an instance of "PHARWOOD" and once found print that
> > line. Then search for the very next instance of "OpenMsgStore"
> > that follows PHARWOOD (whether it be the next line or several
> > lines down) and print that."
> >
> >
> >
> > The code I have so far works but I don't understand how to change
> > my Regex filter to change from PHARWOOD to OpenMsgStore and back
> > again. Or is there a simpler method?
> >
> > Any help welcome,
> >
> > --Paul
> >
> >
> > ---
> >
> > $umlogs = "z\:";
> > opendir (DIR, "$umlogs") || die "Unable to open $umlogs
> > because:\n$!\n"; @dirs = readdir(DIR);
> > foreach $dir (@dirs) {
> > if ($dir =~/^V_DEBUG/i) {
> >
> >
> > open (LOGFILE, "$umlogs\\$dir") || die "unable to open $dir
> > because:\n$!\n";
> >
> > print "$umlogs\\$dir\n";
> > while () {
> > my @fields = split / /;
> >
> >
> > if (/PHARWOOD/) {
> >
> > print $_;
> >
> >
> > }
> > }
> > }
> >
> >
> > }
>
> This loop does what you ask
>
>   print if /PHARWOOD/ .. /OpenMsgStore/ while ;
>
> but if your input looks like
>
>
>   PHARWOOD
> :
>   PHARWOOD
> :
>   OpenMsgStore
>
> then it will print the whole sequence, not just those lines
> starting at the second 'PHARWOOD'. Is that what you want?
>

I'll get it right this time!

The loop needs to be

  while () {
print if /PHARWOOD/ ... /OpenMsgStore/;
  }

as you can't modify a statement with both an if .. and a while ..

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Need Regex help !!

2003-07-11 Thread Pandey Rajeev-A19514
Hi Rob,

Yes, I need a tight pattern representation because the buffer I need to parse is 
slightly complicated than what I had pasted in the mail. 

/(FastEthernet|down)/i) gives me an option of "FastEthernet" OR "down".

I want something like "FastEthernet" AND "down". How do we give AND operation ? 

I want my match to be successful only if all the patterns matches. I thought that 
there might be an easy way to represent them thru Regex and would not have to do any 
if-else ckecking.

Please tell me if you understood my needs or else I will send a bigger mail.

Regards
Rajeev


-Original Message-
From: Rob Anderson [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 3:13 PM
To: [EMAIL PROTECTED]
Subject: Re: Need Regex help !!


Hi Rajeev,

I'm not sure why you feel the need to join your buffer into a big string.
>From what you describe couldn't you just process each buffer element one by
one?

foreach my $buffer_entry (@buff) {
if($buffer_entry =~ /(FastEthernet|down)/i) {
print $buffer_entry;
}
}

Let us know if your trying to do something more complicated that I've not
understood.

HTH,

Rob

"Pandey Rajeev-A19514" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> In short, I have a defined set of pattern that can occur across any number
of lines(scalars) in a buffer (array of scalars) and I need to print only
those lines(Scalars) that contain the full or partial pattern. For eg. For
the buffer @buff (as shown below), I have to find out the occurance of
"FastEthernet" and "down".
>
> I have pasted a code below :
> I join the buffer to make a Scalar and then search for the pattern.
>
>


> my @buff;
> $buff[0] = "Jul  5 03:22:29.635 cst: SNMP: 10.1.0.1 queue overflow,
dropping packet\n";
> $buff[1] = " ifEntry.1.13 = 13\n";
> $buff[2] = " ifEntry.2.13 = FastEthernet3/9\n";
> $buff[3] = " ifEntry.3.13 = 6\n";
> $buff[4] = " lifEntry.20.13 = administratively down\n";
> $buff[5] = " ifEntry.2.13 = FastEthernet3/9\n";
> $buff[6] = " ifEntry.3.13 = 6\n";
> $buff[7] = " lifEntry.20.13 = administratively down\n";
>
> $temp = join($",@buff);
> if($temp =~ /FastEthernet(\n|\d|\w|\.|\/|\s|=)*down/i) {
> print "MATCH found\n";
> }
>

***
>
> Now, that the match has been found, I just want to print only those
scalars in @buff which contains the specified pattern.
>
> The print should be
> ifEntry.2.13 = FastEthernet3/9
> lifEntry.20.13 = administratively down
>
>
> Regards
> Rajeev
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Need Regex help !!

2003-07-11 Thread Pandey Rajeev-A19514
Hi,

In short, I have a defined set of pattern that can occur across any number of 
lines(scalars) in a buffer (array of scalars) and I need to print only those 
lines(Scalars) that contain the full or partial pattern. For eg. For the buffer @buff 
(as shown below), I have to find out the occurance of "FastEthernet" and "down".

I have pasted a code below :
I join the buffer to make a Scalar and then search for the pattern.


my @buff;
$buff[0] = "Jul  5 03:22:29.635 cst: SNMP: 10.1.0.1 queue overflow, dropping packet\n";
$buff[1] = " ifEntry.1.13 = 13\n";
$buff[2] = " ifEntry.2.13 = FastEthernet3/9\n";
$buff[3] = " ifEntry.3.13 = 6\n";
$buff[4] = " lifEntry.20.13 = administratively down\n";
$buff[5] = " ifEntry.2.13 = FastEthernet3/9\n";
$buff[6] = " ifEntry.3.13 = 6\n";
$buff[7] = " lifEntry.20.13 = administratively down\n";

$temp = join($",@buff);
if($temp =~ /FastEthernet(\n|\d|\w|\.|\/|\s|=)*down/i) {
print "MATCH found\n";
}
***

Now, that the match has been found, I just want to print only those scalars in @buff 
which contains the specified pattern.

The print should be
ifEntry.2.13 = FastEthernet3/9
lifEntry.20.13 = administratively down


Regards
Rajeev



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Need help for Telnet.pm

2003-07-07 Thread Pandey Rajeev-A19514
HI,

I am using Telnet.pm module to telnet to a SUN machine.

1. When I run simple unix commands, the command times out.

2. We have another CLI (Command line Interface ) for some utility which also allows me 
to run unix commands by setting the path as PATH=$UPATH. 
So first I have to give the CLI command(thru telnet module) to enter the utility 
prompt. There I set the path by   PATH=$UPATH. Then I run unix commands and I get the 
output.

In case no. 1, normal unix commads are timed out. I feel that the shell which gets 
spawned by the telnet module is not getting initialised with the environment variables 
properly. Even if I give the full path of the unix command it does not run.

Can anyone tell me what mistake I might be doing ?

Regards
Rajeev


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



scandir

2003-07-06 Thread Pandey Rajeev-A19514
Hello,

Do we have a perl function equivalent with the same functionality as the function 
"scandir" in c language ?

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Regular expression problem.

2003-07-06 Thread Pandey Rajeev-A19514
Hi,

I am sorry, I didn't realise that colors won't be visible.
I have to check the combination of "FastEthernet3/9" becomes "administratively down"

 An excerpt of my output buffer looks like this.
 ***
  ifEntry.1.13 = 13
  ifEntry.2.13 = FastEthernet3/9
  ifEntry.3.13 = 6
  lifEntry.20.13 = administratively down
 Jul  5 03:22:33.851 cst: SNMP: Queuing packet to 10.3.0.1
 Jul  5 03:22:33.851 cst: SNMP: V1 Trap, ent products.310, addr 10.20.0.1, gentrap 
2,spectrap 0
  ifEntry.1.13 = 13
  ifEntry.2.13 = FastEthernet3/9
  ifEntry.3.13 = 6
  lifEntry.20.13 = administratively down
 Jul  5 03:22:34.079 cst: %SYS-5-CONFIG_I: Configured from console by vty2 (10.3.0.9)
 
  
All the scalars (i.e. lines) in the array of scalars (the excerpt of the buffer) end 
with a NEW LINE character.

I have to write a regex ( a one liner because I want to give a regex in one of my 
testcase input file) such that it matches patterns spreading across many lines and 
then print those lines.

Like 
*
MATCHED :
ifEntry.2.13 = FastEthernet3/9
lifEntry.20.13 = administratively down
*


Thanks
Rajeev
 
-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Saturday, July 05, 2003 8:21 PM
To: [EMAIL PROTECTED]
Subject: Re: Regular expression problem.


Pandey Rajeev-A19514 wrote:
> Hi,
>
> Can anyone give me a regular expression(perhaps a one liner) ?
> Matching an expression in a single line is easy. But if I have to find it out in a 
> array of scalars, it becomes tricky for me.
>
> An excerpt of my output buffer looks like this.
> ***
>  ifEntry.1.13 = 13
>  ifEntry.2.13 = FastEthernet3/9
>  ifEntry.3.13 = 6
>  lifEntry.20.13 = administratively down
> Jul  5 03:22:33.851 cst: SNMP: Queuing packet to 10.3.0.1
> Jul  5 03:22:33.851 cst: SNMP: V1 Trap, ent products.310, addr 10.20.0.1, gentrap 2, 
> spectrap 0
>  ifEntry.1.13 = 13
>  ifEntry.2.13 = FastEthernet3/9
>  ifEntry.3.13 = 6
>  lifEntry.20.13 = administratively down
> Jul  5 03:22:34.079 cst: %SYS-5-CONFIG_I: Configured from console by vty2 (10.3.0.9)
> 
>
> I need to write a simple regular expression which matches the occurance of the 
> combination of pattern as shown in RED.
>
> I have to write many such reg. expressions but thay have to be simple and preferably 
> a one liner.

As far as I know nobody can see which of your text is shown in red. Please post
in ASCII to newsgroups in general.

Also, what is this fascination with one-liners? The best solution is one which
describes the problem clearly. I doubt if I'd be congratulated for offering a
recipe for Angel Cake within a single sentence?

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Regular expression problem.

2003-07-05 Thread Pandey Rajeev-A19514
Hi,

Can anyone give me a regular expression(perhaps a one liner) ?
Matching an expression in a single line is easy. But if I have to find it out in a 
array of scalars, it becomes tricky for me.

An excerpt of my output buffer looks like this. 
***
 ifEntry.1.13 = 13 
 ifEntry.2.13 = FastEthernet3/9 
 ifEntry.3.13 = 6 
 lifEntry.20.13 = administratively down
Jul  5 03:22:33.851 cst: SNMP: Queuing packet to 10.3.0.1
Jul  5 03:22:33.851 cst: SNMP: V1 Trap, ent products.310, addr 10.20.0.1, gentrap 2, 
spectrap 0 
 ifEntry.1.13 = 13 
 ifEntry.2.13 = FastEthernet3/9 
 ifEntry.3.13 = 6 
 lifEntry.20.13 = administratively down
Jul  5 03:22:34.079 cst: %SYS-5-CONFIG_I: Configured from console by vty2 (10.3.0.9)


I need to write a simple regular expression which matches the occurance of the 
combination of pattern as shown in RED.

I have to write many such reg. expressions but thay have to be simple and preferably a 
one liner.

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Beginnner .. please help

2003-07-04 Thread Pandey Rajeev-A19514
Hi,

I am new to perl and need some help.

How do we pass array of scalars to a subroutine.
I need something like this

***
sub ABC {
 my(@buffer) shift;
 print @buffer;
}

I want to call this subroutine from some other code like.

ABC( @this_buffer );
*

Shift  works for scalars, but does it work for Array of Scalars ?

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]