Re: Perl Sockets oddity..

2008-09-24 Thread Andy Dixon
On 24 Sep 2008, at 15:44, Rob Dixon wrote: Andy Dixon wrote: I may be being a bit dim, but I wrote this: #!/usr/bin/perl -w use IO::Socket::INET; print "ISONAS Logger (perl) v1\n"; my $socket = IO::Socket::INET->new( PeerAddr => "10.9.1.100", Pe

RE: regex count

2008-09-24 Thread Stephen Reese
> Have a look at the sample data you posted and you will see where. > > > John I believe I found where the ']' needs to go but didn't see any extra ' ' space. The $x count seems off. As I see it every time a regex match is made then $x will increase one. The match numbers results are about 5x g

Re: regex count

2008-09-24 Thread John W. Krahn
Stephen Reese wrote: It appears that there is a space (' ') character at the end of the pattern where there should be a ']' character. John, I'm missing where the closing bracket should go. Have a look at the sample data you posted and you will see where. John -- Perl isn't a toolbox, but a

Re: Trying to modify Perl script

2008-09-24 Thread John W. Krahn
Stephen Reese wrote: printf() (as seen three lines down) has a format string and a list of values corresponding to the % escapes in that string. Because you are using a string literal you should use print() instead. foreach my $i (sort { $quad{$b} <=> $quad{$a} } keys %quad) { if ($n++ >= $

RE: Trying to modify Perl script

2008-09-24 Thread Stephen Reese
> printf() (as seen three lines down) has a format string and a list of > values corresponding to the % escapes in that string. Because you are > using a string literal you should use print() instead. > > > foreach my $i (sort { $quad{$b} <=> $quad{$a} } keys %quad) { > >if ($n++ >= $ntop) {

RE: regex count

2008-09-24 Thread Stephen Reese
> It appears that there is a space (' ') character at the end of the > pattern where there should be a ']' character. John, I'm missing where the closing bracket should go. while () { next unless /Sig:\s*(\d+)\s+Subsig:\s*(\d+)\s+Sev:\s*(\d+)([^\[]+)\[([\d\.]+):(\d+)\s*-> \s*([\d\.]+):(\d

RE: regex count

2008-09-24 Thread Stephen Reese
> I just copied over your code and noticed that the end of > your regular expression (the "/" character) runs across a > newline. Once I moved that back up to this: > > next unless > /Sig:\s*(\d+)\s+Subsig:\s*(\d+)\s+Sev:\s*(\d+)([^\[]+)\[([\d\.]+):(\d+) > \s*->\s*([\d\.]+):(\d+)/; > > $x is incr

Re: Parsing Key/Value pairs

2008-09-24 Thread Li, Jialin
On Wed, Sep 24, 2008 at 2:25 PM, Dan Fish <[EMAIL PROTECTED]> wrote: > I've got a data file with a bunch of key/value pairs in the format > "key=value;". There may be only one to a line, or there may be several. I > know I can figure out how to do this using split, but I thought surely > there >

Parsing Key/Value pairs

2008-09-24 Thread Dan Fish
I've got a data file with a bunch of key/value pairs in the format "key=value;". There may be only one to a line, or there may be several. I know I can figure out how to do this using split, but I thought surely there must be a more "elegant" solution. I was trying to do this using the following

Re: How to make part of regex optional.

2008-09-24 Thread Mr. Shawn H. Corey
On Wed, 2008-09-24 at 18:32 +0200, Rob Coops wrote: > Hi all, > > I am having some trouble matching the following string: > > "Some text+...:...:...:...:...+some more text" > > The trick is there are two dilimiters in this string the + and the : are > used to separate the string, the + signifies

Re: How to make part of regex optional.

2008-09-24 Thread John W. Krahn
Rob Coops wrote: Hi all, Hello, I am having some trouble matching the following string: "Some text+...:...:...:...:...+some more text" The trick is there are two dilimiters in this string the + and the : are used to separate the string, the + signifies a part of the string ended and the : s

How to make part of regex optional.

2008-09-24 Thread Rob Coops
Hi all, I am having some trouble matching the following string: "Some text+...:...:...:...:...+some more text" The trick is there are two dilimiters in this string the + and the : are used to separate the string, the + signifies a part of the string ended and the : signifies a sub part of the st

Re: Perl Sockets oddity..

2008-09-24 Thread Deviloper
meh

Re: Perl Sockets oddity..

2008-09-24 Thread Rob Dixon
Deviloper wrote: > > If I were in your place, I would use Data::Dumper or a IDE with a grafical > debugger and take a look what happens. try the 30 Days Trail of Komodo Pro > Studio > IDE or OptiPerl is you don´t like data::dumper. > > Try in your while loop > > m

Re: Perl Sockets oddity..

2008-09-24 Thread Deviloper
If I were in your place, I would use Data::Dumper or a IDE with a grafical debugger and take a look what happens. try the 30Days Trail of Komodo Pro Studio IDE or OptiPerl is you don´t like data::dumper.  Try in your while loop my $sender = $text->peerhost() pri

Re: Perl Sockets oddity..

2008-09-24 Thread Rob Dixon
Andy Dixon wrote: > > I may be being a bit dim, but I wrote this: > > #!/usr/bin/perl -w > use IO::Socket::INET; > print "ISONAS Logger (perl) v1\n"; > my $socket = IO::Socket::INET->new( > PeerAddr => "10.9.1.100", > PeerPort => "5321" >

Re: csv multi-line to single-line

2008-09-24 Thread Mr. Shawn H. Corey
On Wed, 2008-09-24 at 03:17 -0700, John W. Krahn wrote: > [EMAIL PROTECTED] wrote: > > Hi, > > Hello, > > > We receive a text file with the following entries. > > > > "01","item1","apple one","apple two","apple three" > > "02","item2","body one","body two","body three" > > "03","item

Re: Perl Sockets oddity..

2008-09-24 Thread Andy Dixon
Hello, I have just tried this, and have this code: #!/usr/bin/perl -w use IO::Socket::INET; $| = 1; print "ISONAS Logger (perl) v1\n"; my $socket = IO::Socket::INET->new( PeerAddr => "10.9.1.100", PeerPort => "5321" ) or die

RE: Perl Sockets oddity..

2008-09-24 Thread Deviloper
Try unbuffer IO, this might be on off the Problem. $| = 1; the don´t do: > > while (true) { > >          $socket->recv($text,128); > >          print $text; > > } do > > while ($socket->recv($text,128)) { > >          print $text; > > } Byebye, Bo Stewart Anderson <[EMAIL PROTECTED]> hat am

RE: Perl Sockets oddity..

2008-09-24 Thread Stewart Anderson
> -Original Message- > From: Andy Dixon [mailto:[EMAIL PROTECTED] > Sent: 24 September 2008 12:26 > To: beginners@perl.org > Subject: Perl Sockets oddity.. > > Hello, > > I may be being a bit dim, but I wrote this: > > #!/usr/bin/perl -w > use IO::Socket::INET; > print "ISONAS Logger (pe

Perl Sockets oddity..

2008-09-24 Thread Andy Dixon
Hello, I may be being a bit dim, but I wrote this: #!/usr/bin/perl -w use IO::Socket::INET; print "ISONAS Logger (perl) v1\n"; my $socket = IO::Socket::INET->new( PeerAddr => "10.9.1.100", PeerPort => "5321" ) or die $!; prin

Re: csv multi-line to single-line

2008-09-24 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi, Hello, We receive a text file with the following entries. "01","item1","apple one","apple two","apple three" "02","item2","body one","body two","body three" "03","item2","body one","body two","body three" "04","item2","body one","body two","body t

csv multi-line to single-line

2008-09-24 Thread [EMAIL PROTECTED]
Hi, We receive a text file with the following entries. "01","item1","apple one","apple two","apple three" "02","item2","body one","body two","body three" "03","item2","body one","body two","body three" "04","item2","body one","body two","body three" "05","item1","orange one","