[25614] in Perl-Users-Digest
Perl-Users Digest, Issue: 7858 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 4 18:10:50 2005
Date: Fri, 4 Mar 2005 15:10:41 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 4 Mar 2005 Volume: 10 Number: 7858
Today's topics:
dividing strings <robin@infusedlight.net>
Re: dividing strings <1usa@llenroc.ude.invalid>
Re: dividing strings <l.heisler@utoronto.ca>
Re: dividing strings <lawshouse.public@btconnect.com>
Re: dividing strings <1usa@llenroc.ude.invalid>
Re: dividing strings <webmaster @ infusedlight.net>
Re: dividing strings <robin@infusedlight.net>
Re: help with code <ccolumbu@hotmail.com>
Re: help with code <1usa@llenroc.ude.invalid>
Re: help with code <groleau+news@freeshell.org>
Re: how to convert bit vectors to hex <jl_post@hotmail.com>
Re: how to convert bit vectors to hex <jl_post@hotmail.com>
Re: how to convert bit vectors to hex <hy34@njit.edu>
Re: how to convert bit vectors to hex <stampes@xilinx.com>
Re: how to convert bit vectors to hex <hy34@njit.edu>
Re: how to convert bit vectors to hex <stampes@xilinx.com>
Looping through a log file <ajperl@mac.com>
Re: Looping through a log file <do-not-use@invalid.net>
Re: Looping through a log file <ajperl@mac.com>
Re: negative backreference? eric.hall@gmail.com
Re: negative backreference? eric.hall@gmail.com
Re: Net::Telnet, Terminal Programs, Prompts <jmw_misc@hotmail.com>
Re: Passing in the replace string for a regex via the c <1usa@llenroc.ude.invalid>
Re: persistant db connection <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Questions about Perl for Windows <postmaster@castleamber.com>
Re: ranking texts against a white list <tadmc@augustmail.com>
Re: ranking texts against a white list <matternc@comcast.net>
Re: RTF::Text::Converter stov753@aol.com
Re: RTF::Text::Converter stov753@aol.com
Re: WikiConverter <sun_tong@users.sourceforge.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Mar 2005 10:36:26 -0800
From: "robin" <robin@infusedlight.net>
Subject: dividing strings
Message-Id: <1109961386.306024.104060@z14g2000cwz.googlegroups.com>
I'm sorry I couldn't post code for this question, but I have no idea
where
to start on this one.
I need code (or suggestions) for the problem of inserting a string into
a
variable string every x (number) characters and then parsing it back
into
the first original string and then printing the original string with
the
inserted strings.
Thanks,
--
Robin
--
webmaster@infusedlight.net
------------------------------
Date: 4 Mar 2005 19:23:21 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: dividing strings
Message-Id: <Xns960F925FEAB94asu1cornelledu@132.236.56.8>
"robin" <robin@infusedlight.net> wrote in news:1109961386.306024.104060
@z14g2000cwz.googlegroups.com:
> I need code (or suggestions) for the problem of inserting a string into
> a variable string every x (number) characters and then parsing it back
> into the first original string and then printing the original string with
> the inserted strings.
How doy ou propose to deal with:
my $src = 'a' x 10;
my $insert_every_third_character = 'a';
The resulting string will be:
'aaaaaaaaaaaaa'
How are you going to take out the a's?
At least making an attempt to clearly state a question can do wonders in
terms of your ability to actually answer it.
Sinan.
------------------------------
Date: Fri, 4 Mar 2005 19:43:52 GMT
From: "LEH" <l.heisler@utoronto.ca>
Subject: Re: dividing strings
Message-Id: <ICuEow.CDz@campus-news-reading.utoronto.ca>
"robin" <robin@infusedlight.net> wrote in message
news:1109961386.306024.104060@z14g2000cwz.googlegroups.com...
> I'm sorry I couldn't post code for this question, but I have no idea
> where
> to start on this one.
>
> I need code (or suggestions) for the problem of inserting a string into
> a
> variable string every x (number) characters and then parsing it back
> into
> the first original string and then printing the original string with
> the
> inserted strings.
>
> Thanks,
>
>
> --
> Robin
> --
> webmaster@infusedlight.net
>
I would do the following, although there may be a more concise way to do it.
Larry
-- but not sure what you mean by "parsing it back into the first original
string"
------------
use strict;
use warnings;
my $insert="XXX";
my $string="abcdefghijklmnopqrstuvwxyz";
my $size=3;
my @chunks;
#break the string into chunks of appropriate size
foreach ($string=~ /.{1,$size}/g){push (@chunks, $_);}
#put it back together with insert between the chunks
my $final=join($insert,@chunks);
print $final;
------------------------------
Date: Fri, 04 Mar 2005 21:43:07 +0000
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Re: dividing strings
Message-Id: <2glh219aiedprr94ne3lc9uo6i45i6tso7@4ax.com>
On 4 Mar 2005 10:36:26 -0800, "robin" <robin@infusedlight.net> wrote:
>I'm sorry I couldn't post code for this question, but I have no idea
>where
>to start on this one.
>
>I need code (or suggestions) for the problem of inserting a string into
>a
>variable string every x (number) characters and then parsing it back
>into
>the first original string and then printing the original string with
>the
>inserted strings.
Robin, my son, I can't understand a word you're saying. Why not post
some examples of what your start and end points are; maybe some
tolerant person who hasn't killfiled you already (there are a few)
will try to help.
------------------------------
Date: Fri, 04 Mar 2005 21:58:35 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: dividing strings
Message-Id: <Xns960FACB1DEACFasu1cornelledu@127.0.0.1>
"LEH" <l.heisler@utoronto.ca> wrote in
news:ICuEow.CDz@campus-news-reading.utoronto.ca:
> "robin" <robin@infusedlight.net> wrote in message
> news:1109961386.306024.104060@z14g2000cwz.googlegroups.com...
>> I'm sorry I couldn't post code for this question, but I have no idea
>> where to start on this one.
>>
>> I need code (or suggestions) for the problem of inserting a string
>> into a variable string every x (number) characters and then parsing
>> it back into the first original string and then printing the original
>> string with the inserted strings.
...
> I would do the following, although there may be a more concise way to
> do it. Larry
> -- but not sure what you mean by "parsing it back into the first
> original string"
Robin seems to want to extract the milk from the pudding once the
pudding is made. Without further conditions, the problem is not well
defined.
> use strict;
> use warnings;
Good.
> my $insert="XXX";
> my $string="abcdefghijklmnopqrstuvwxyz";
See how you chose the $insert string so that it did not contain any of
the characters? For the problem to be well-defined, such an assumption,
if it exists, must be specified explicitly.
> my $size=3;
>
> my @chunks;
> #break the string into chunks of appropriate size
> foreach ($string=~ /.{1,$size}/g){push (@chunks, $_);}
> #put it back together with insert between the chunks
> my $final=join($insert,@chunks);
> print $final;
Feel free to use as much whitespace as needed to make it easier for
others to read your post.
Is this what you were trying to achieve?
#! /usr/bin/perl
use strict;
use warnings;
my $insert = 'XXX';
my $source = 'abcdefghijklmnopqrstuvwxyz';
my $step = '.' x 4;
$source =~ s/($step)/$1$insert/g;
print "Transformed: $source\n";
$source =~ s/$insert//g;
print "Source (not really): $source\n";
__END__
D:\Home\asu1\UseNet\clpmisc> s1
ransformed: abcdXXXefghXXXijklXXXmnopXXXqrstXXXuvwxXXXyz
ource (not really): abcdefghijklmnopqrstuvwxyz
How about this one?
#! /usr/bin/perl
use strict;
use warnings;
my $insert = 'XXX';
my $source = 'abcdefghijklmnopqrstuvwxyz';
my $step = 4;
my $target;
my $cursor = 0;
while($cursor < length $source) {
my $chunk = substr($source, $cursor, $step);
unless($step == length $chunk) {
$target .= $chunk;
last;
}
$target .= $chunk . $insert;
$cursor += $step;
}
print "Original: $source\nTransformed: $target\n";
__END__
D:\Home\asu1\UseNet\clpmisc> s
Original: abcdefghijklmnopqrstuvwxyz
Transformed: abcdXXXefghXXXijklXXXmnopXXXqrstXXXuvwxXXXyz
Sinan
------------------------------
Date: Fri, 4 Mar 2005 15:30:36 -0700
From: "Robin" <webmaster @ infusedlight.net>
Subject: Re: dividing strings
Message-Id: <7pqdnSN_Bp3hfbXfRVn-hw@comcast.com>
"LEH" <l.heisler@utoronto.ca> wrote in message
news:ICuEow.CDz@campus-news-reading.utoronto.ca...
> "robin" <robin@infusedlight.net> wrote in message
> news:1109961386.306024.104060@z14g2000cwz.googlegroups.com...
>> I'm sorry I couldn't post code for this question, but I have no idea
>> where
>> to start on this one.
>>
>> I need code (or suggestions) for the problem of inserting a string into
>> a
>> variable string every x (number) characters and then parsing it back
>> into
>> the first original string and then printing the original string with
>> the
>> inserted strings.
>>
>> Thanks,
>>
>>
>> --
>> Robin
>> --
>> webmaster@infusedlight.net
>>
>
> I would do the following, although there may be a more concise way to do
> it.
> Larry
> -- but not sure what you mean by "parsing it back into the first original
> string"
>
>
> ------------
> use strict;
> use warnings;
>
> my $insert="XXX";
> my $string="abcdefghijklmnopqrstuvwxyz";
> my $size=3;
>
> my @chunks;
> #break the string into chunks of appropriate size
> foreach ($string=~ /.{1,$size}/g){push (@chunks, $_);}
> #put it back together with insert between the chunks
> my $final=join($insert,@chunks);
> print $final;
wow, thanks, I can see what that code is doing, nice array context.
-Robin
------------------------------
Date: 4 Mar 2005 14:27:21 -0800
From: "robin" <robin@infusedlight.net>
Subject: Re: dividing strings
Message-Id: <1109975241.888264.115460@l41g2000cwc.googlegroups.com>
thanks for all the help. I really appreciate it, the code looks great.
------------------------------
Date: Fri, 4 Mar 2005 10:09:12 -0800
From: "Chad Columbus" <ccolumbu@hotmail.com>
Subject: Re: help with code
Message-Id: <zv1Wd.154667$0u.127041@fed1read04>
Just wondering, couldn't this be done by assigning each of these to a hash key
then sorting with like this:
$hash_to_be_sorted{$a} = '';
$hash_to_be_sorted{$b} = '';
$hash_to_be_sorted{$c} = '';
. . .
foreach $x (sort {$a <=> $b} (keys(%hash_to_be_sorted))) {
push(@return, $x);
}
It will give you back the values in an array where $return[0] is the smallest
and $return[$#return] is the biggest.
Chad
<jl_post@hotmail.com> wrote in message
news:1109948972.278795.247740@f14g2000cwb.googlegroups.com...
> Gabriella wrote:
>> I figure that this code try to compare 2 ligns and sort them in
>> increasing number. 1.2.3 is greater 1.2.2. What I don't see why the
>> person who codes this introduce the $imgA, $imgB What is he trying to
>> achieve ?
>>
>> sub sortRule {
>> my ($wordA, $wordB, @numA, @numB, $lgA, $lgB, $min, $imgA, $imgB);
>> $wordA = $a;
>> $wordB = $b;
>> #print "\nwordA=$wordA\n";
>> #print "wordB=$wordB\n";
>> $wordA =~ s/^([0-9.]+).*$/$1/;
>> $wordB =~ s/^([0-9.]+).*$/$1/;
>> #printc "a=$wordA b=$wordB", 'blue';
>> @numA = split(/\./, $wordA);
>> @numB = split(/\./, $wordB);
>> $lgA = $#numA;
>> $lgB = $#numB;
>> #printc "lgA=$lgA, lgB=$lgB";
>> if ($lgA > $lgB) { $min = $lgB }
>> else { $min = $lgA }
>>
>> my $fin = 0;
>> for (my $i=0; ($i<=$min && !$fin); $i++) {
>> if ($numA[$i] > $numB[$i]) {
>> $imgA = 2;
>> $imgB = 1;
>> $fin = 1;
>> }
>> elsif ($numA[$i] < $numB[$i]) {
>> $imgA = 1;
>> $imgB = 2;
>> $fin = 1;
>> }
>> }
>>
>> if (!$fin) {
>> if ($lgA > $lgB) {
>> $imgA = 2;
>> $imgB = 1;
>> }
>> else {
>> $imgA = 1;
>> $imgB = 2;
>> }
>> }
>>
>> #printc "imgA=$imgA, imgB=$imgB", 'green';
>> return ($imgA <=> $imgB);
>> }
>
>
> Dear Gabriella,
>
> Hmm... the code is difficult to read. It bothers me when people
> figure out a process to achieve what they want, and then don't even
> bother to explain it, as if their way is the only way that could ever
> be thought of or they think their method is so clear that it needs no
> explanation. In other words, if you think up a solution, it's a good
> idea to explain along the way what you are doing, in case somebody
> after you ever tries to figure out what you are doing. (I definitely
> think that you should write the simplest, clearest code, but even then
> it's not always clear what the code is trying to do, which is why I
> think good code should have in-code documentation (in the form of
> comments) explaining what is being done.)
>
> I looked at the code, and it appears that $imgA and $imgB (I don't
> know what "img" is supposed to stand for) are temporary placeholders
> that keep track of which value ($a or $b) is greater. When they are
> set, one of them receives a value of 1 and the other a value of 2. The
> one that got the value of 2 represents the greater value. For example,
> if $imgA gets the value of 2, it means that $a was determined to be the
> greater value.
>
> No comments were included to specify this. It would have been nice
> if the original writer of the code mentioned this. As for me, I think
> it would have been clearer if, instead of setting $imgA, $imgB, and
> $fin, that the function would end immediately returning 1 (if $a was
> greater) or -1 (if $b was greater). At the end of the function, if no
> value was found to be greater, then 0 would be returned.
>
> To illustrate my point, I have included my own small program, which
> is hopefully clearer to you (and should do the same thing):
>
>
> ============= START OF CODE ================
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> sub specialSort
> {
> # Note: 1.2.3 is greater than 1.2.2
>
> # Split out all numbers into arrays @a and @b:
> my @a = split(/\./, $a);
> my @b = split(/\./, $b);
>
> # Compare the numbers in each array.
> # As soon as the number differ, return
> # the proper value (-1 if $a is greater;
> # 1 if $b is greater):
> while (@a and @b)
> {
> my $aNum = shift @a;
> my $bNum = shift @b;
>
> return -1 if $aNum < $bNum; # b is greater
> return 1 if $aNum > $bNum; # a is greater
> }
>
> # All the values so far were identical.
> # If one array still contains values, then
> # it's value is greater:
> return -1 if @b; # b is greater
> return 1 if @a; # a is greater
> return 0; # both numbers the same
> }
>
> ### Main code: ###
>
> # Get the numbers:
> my @listOfNums = <DATA>;
> chomp(@listOfNums); # remove the newlines
>
> # Do the sort:
> my @sortedNums = sort specialSort @listOfNums;
>
> # Print out the sorted values:
> print "$_\n" foreach @sortedNums;
>
> __DATA__
> 7
> 5.2
> 5.7
> 5.9
> 8.56.4.3
> 5.0
> 5.5.5
> 1.788.34.3
> 5.5.4
> 5.2.6
> 5.2.6.7
> ============= END OF CODE ================
>
>
> There is only one problem that I see with my code, and that is that
> it treats the value 5.0 to be greater than 5 . This might be what you
> want (or it might not), so you will have to modify it (to check for
> something like m/(\.0)*$/ ) if you need 5 to equal 5.0 .
>
> I hope this helps, Gabriella.
>
> -- Jean-Luc
>
------------------------------
Date: 4 Mar 2005 20:38:00 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: help with code
Message-Id: <Xns960F9F07E2AA5asu1cornelledu@132.236.56.8>
"Chad Columbus" <ccolumbu@hotmail.com> wrote in
news:zv1Wd.154667$0u.127041@fed1read04:
[ Please do not top-post.
Please do read the posting guidelines for this group.
]
> Just wondering, couldn't this be done by assigning each of these to a
> hash key then sorting with like this:
> $hash_to_be_sorted{$a} = '';
> $hash_to_be_sorted{$b} = '';
> $hash_to_be_sorted{$c} = '';
> . . .
>
> foreach $x (sort {$a <=> $b} (keys(%hash_to_be_sorted))) {
> push(@return, $x);
> }
>
> It will give you back the values in an array where $return[0] is the
> smallest and $return[$#return] is the biggest.
Incidentally, I do not have the faintest idea what you are talking about.
Trying to run the program above gives me an error.
Sinan.
------------------------------
Date: Fri, 04 Mar 2005 17:43:33 -0500
From: Wes Groleau <groleau+news@freeshell.org>
Subject: Re: help with code
Message-Id: <38s6k7F5rt2u3U2@individual.net>
Lord0 wrote:
> This should sort it
> rm -rf *
And if not, at least it will remove the source of the confusion.
--
Wes Groleau
-----------
Daily Hoax: http://www.snopes2.com/cgi-bin/random/random.asp
------------------------------
Date: 4 Mar 2005 08:12:55 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: how to convert bit vectors to hex
Message-Id: <1109952775.296350.209440@l41g2000cwc.googlegroups.com>
hongyan wrote:
> I have a ascii file has the format: each row has 32 bits.
> 00001001000101000000000000000000
> 00001001000010101000000000100000
> 10100001000011000000001000000000
> 10100010000011000000010000000000
> .............
> I want to change that to hex numbers and write it to another
> file as:
> 09140000
> 090a8020
> a10c0200
> a20c0400
> .............
> I tried pack and unpack but I can't get it.
> Can you tell me a way to do it without installing
> the bit::vector package?
Dear Hongyan,
This should be easy to do. Say that your inputfile is named
"in.txt" and you want your output file to be named "out.txt". You can
do this in one line at the DOS/Unix prompt:
# In Unix:
perl -lne 'chomp; print unpack "H*", pack "B*", $_' in.txt > out.txt
# In DOS/Win32:
perl -lne "chomp; print unpack 'H*', pack 'B*', $_" in.txt > out.txt
In both cases, we are packing the 0/1 bit string into a binary string,
then unpacking it into a hex string and printing its value.
I hope this helps you, Hongyan.
-- Jean-Luc
------------------------------
Date: 4 Mar 2005 08:17:01 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: how to convert bit vectors to hex
Message-Id: <1109953020.970184.93100@g14g2000cwa.googlegroups.com>
Whoops! I forgot that using the "-l" switch makes the call to chomp()
unnecessary. Therefore, you can do the same thing with:
# In Unix:
perl -lne 'print unpack "H*", pack "B*", $_' in.txt > out.txt
# In DOS/Win32:
perl -lne "print unpack 'H*', pack 'B*', $_" in.txt > out.txt
Sorry about that.
-- Jean-Luc
------------------------------
Date: 4 Mar 2005 08:52:44 -0800
From: "hongyan" <hy34@njit.edu>
Subject: Re: how to convert bit vectors to hex
Message-Id: <1109955164.024540.219010@g14g2000cwa.googlegroups.com>
Thank you so much, Jean. It works perfectly.
------------------------------
Date: Fri, 04 Mar 2005 10:59:05 -0700
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: how to convert bit vectors to hex
Message-Id: <d0a7la$18f7@xco-news.xilinx.com>
hongyan wrote:
> I have a ascii file has the format: each row has 32 bits.
> 00001001000101000000000000000000
> 00001001000010101000000000100000
> 10100001000011000000001000000000
> 10100010000011000000010000000000
> .............
> I want to change that to hex numbers and write it to another file as:
> 09140000
> 090a8020
> a10c0200
> a20c0400
> .............
> I tried pack and unpack but I can't get it.
Please show us what you tried, and what didn't work.
> Can you tell me a way to do it without installing the bit::vector
> package? I am a novice to perl, thank you very much for your help,
Forgive the cynicism, but since you're posting from a .edu address, and
you're putting restrictions on such as "Don't use the bit::vector
module", I suspect you're looking for help on your homework.
I see Jean already answered your question, but in the future, please
show us your code that isn't working, so we can help you, instead of
coding for you.
~Jeff
------------------------------
Date: 4 Mar 2005 11:23:41 -0800
From: "hongyan" <hy34@njit.edu>
Subject: Re: how to convert bit vectors to hex
Message-Id: <1109964221.045597.78330@z14g2000cwz.googlegroups.com>
Jeff:
Thank you for you remind. This is my first time to post messages here
and it is my fault that I didn't put my own code here. Next time I
will put them.
Actually I am writing an simple assembler with perl for my program
which are going to run on my own designed processor in VHDL.
Again, thank you very much for your words.
------------------------------
Date: Fri, 04 Mar 2005 12:41:12 -0700
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: how to convert bit vectors to hex
Message-Id: <d0adko$18f8@xco-news.xilinx.com>
hongyan wrote:
> Actually I am writing an simple assembler with perl for my program
> which are going to run on my own designed processor in VHDL.
As you can tell from my email address, the people I work around know
something about VHDL and processors :)
> Again, thank you very much for your words.
You're very welcome. As it was your first post, I'll point you at the
Posting Guidelines that are routinelty posted here in case you missed them:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.text
I'm glad Jean was able to help you with your problem. Best wishes for
you and your future coding efforts!
~Jeff
------------------------------
Date: 4 Mar 2005 09:23:46 -0800
From: "AJ Hartley" <ajperl@mac.com>
Subject: Looping through a log file
Message-Id: <1109957026.410580.172190@l41g2000cwc.googlegroups.com>
My project is to parse a text log file created by a propietary
publishing application and stuff the important information into a
database. The actual parsing of the information for a single event
using regular expressions was a slam dunk, though each line requires
it's own expression. But I'm needing some advice with a strategy for
looping through the file.
I'm running this process every mintute or so, no more than 10 events
can stack up in the file during that period.
Each "event" in the log file may contain four or five lines of
information. That's the parsing process mentioned above. Each event is
concluded with a dashed line. If the next line contains nothing, we can
exit. Otherwise the loop continues. Example:
Event 1 title
Event 1 user info
Event 1 time stamp info
Event 1 status info
Event 1 file path info
----------------------------------------
Event 2 title
Event 2 user info
Event 2 time stamp info
Event 2 status info
----------------------------------------
and so on...
My challenge is to figure out how run the parsing on each chunk and
then continue on to the next or exit as necessary based on the dashed
line.
Thanks for any advice you can offer...
------------------------------
Date: 04 Mar 2005 18:37:59 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Looping through a log file
Message-Id: <yzd7jknwbuw.fsf@invalid.net>
"AJ Hartley" <ajperl@mac.com> writes:
> My project is to parse a text log file created by a propietary
> publishing application and stuff the important information into a
> database. The actual parsing of the information for a single event
> using regular expressions was a slam dunk, though each line requires
> it's own expression. But I'm needing some advice with a strategy for
> looping through the file.
>
> I'm running this process every mintute or so, no more than 10 events
> can stack up in the file during that period.
>
> Each "event" in the log file may contain four or five lines of
> information. That's the parsing process mentioned above. Each event is
> concluded with a dashed line. If the next line contains nothing, we can
> exit. Otherwise the loop continues. Example:
>
> Event 1 title
> Event 1 user info
> Event 1 time stamp info
> Event 1 status info
> Event 1 file path info
> ----------------------------------------
> Event 2 title
> Event 2 user info
> Event 2 time stamp info
> Event 2 status info
> ----------------------------------------
> and so on...
>
> My challenge is to figure out how run the parsing on each chunk and
> then continue on to the next or exit as necessary based on the dashed
> line.
Is there a need to worry about log entries being written while we are
reading, so truncated entries may appear?
------------------------------
Date: 4 Mar 2005 09:45:02 -0800
From: "AJ Hartley" <ajperl@mac.com>
Subject: Re: Looping through a log file
Message-Id: <1109958302.224639.24580@z14g2000cwz.googlegroups.com>
I have a utility that checks for file stability before the file is
opened, read and moved to another location. The publishing application
then starts a fresh log file. So my belief is that truncated entries
will not appear.
------------------------------
Date: 4 Mar 2005 09:29:16 -0800
From: eric.hall@gmail.com
Subject: Re: negative backreference?
Message-Id: <1109957356.050957.139170@f14g2000cwb.googlegroups.com>
I've tried wrapping just the "rdns" part in a negative look-ahead, and
I've tried wrapping the whole thing, and neither produces a match when
the values are different.
Here's the first test, using non-matching names:
#!/usr/bin/perl
$_ = "[ rdns=hostname1 helo=hostname2 ]";
if ( /^[^\]]+ (?!rdns=(.*) helo=\1)/ ) {
print "got <$1>\n";
}
$ test.pl
got <>
That looks like it works, but it produces the same results ("got <>")
even when rdns and helo are the same, meaning that the test seems to
err out in all cases.
Am I trapping the wrong output or something?
------------------------------
Date: 4 Mar 2005 12:54:04 -0800
From: eric.hall@gmail.com
Subject: Re: negative backreference?
Message-Id: <1109969644.041561.277830@l41g2000cwc.googlegroups.com>
^[^\]]+ rdns=(\S*) helo=(?!\1) returns hostname1, as needed. From my
admittedly limited understanding, it does not appear that the negative
look-ahead is being interpreted as such, and this gobbledygoo should
not work.
I'm content to live with the mystery, but if somebody could explain it
or reference material that says why it works, I'd be appreciative.
------------------------------
Date: 4 Mar 2005 10:27:01 -0800
From: "Mike" <jmw_misc@hotmail.com>
Subject: Re: Net::Telnet, Terminal Programs, Prompts
Message-Id: <1109960821.419490.56010@f14g2000cwb.googlegroups.com>
I am in this to learn also, i have gathered so much from the postings
on this newsgroup. If you are interested, i have a version using
Term::VT102
that is working fairly well. If you would like send me an email and i
will email you a zip of it. Email to [jmw_misc at hotmail dot com]
Confused on your login, must be something to do with what telnet daemon
you are connecting to. I have only tried to telnet to a Sun box Solaris
2.5.1
I will try to telnet to a windows daemon this weekend at home.
Yes this is a work in progress, so i have not tidied evrything up like
the repeat call back. The new module has that fixed, but still a bunch
of testing things for troubleshooting.
Like the Web page 'JAPH' although it scares people at work when i have
the volume on, LOL. Cant wait til i can figure out how to write a cool
perl hack name.
Mike
zentara wrote:
> On 3 Mar 2005 12:03:29 -0800, "Mike" <jmw_misc@hotmail.com> wrote:
>
> >Thanks for taking a look.
>
> Purely selfish motives...I want to learn how to do it :-)
>
> >
> >If you change the ip address and place the module where you can load
> >it, you should get a text box display with a connect button. Once i
> >press the button, i get whatever the host telnet echos out. Mine
shows
> >a login prompt. Which i then can enter into the text box username
and
> >password. I then see the command prompt and can type commands in.
> >
> >Do you get anything after pressing the connect? If so make sure you
> >select the Text box in order to enter commands. I have added a focus
in
> >the module now, but it is missing in what i posted.
>
> What happens with me, is I connect, then I get a login prompt.
> I enter my name and press enter.
> Then it returns A Password prompt, followed by "Login incorrect"
> even before I get a chance to type in the password. Then another
login
> prompt appears.
>
> ( I have a test user 'z')
> #################################################
> darkstar login: z
> Password: Login incorrect
>
> darkstar login:
> ##################################################
>
> Thats why I suggested you may need expect or IPC::Open3 to handle
> the transaction.
> But you probably could do it through your Telnet object methods,
maybe
> have a separate logon sub, for handling the login?
>
> Maybe you could pass the username and password as args to your
> new Telnet, and when you connect, do a
>
> $self->{TELNET}->open($ip);
> $self->{TELNET}->login($username, $password);
>
> I tried this with no luck
> #----------------------------------------------------------
> sub conn {
> my ( $self, $ip ) = @_;
> $self->{TELNET}->open($ip);
> $self->after( '250', [ \&read_telnet, $self ] );
> $self->{TELNET}->login('z','foopass');
> $self->repeat( '250', [ \&read_telnet, $self ] );
> }
> #-----------------------------------------------------------
>
>
> By the way:
>
> I see where you need to cancel your repeater, but have it
> cancelled out. You could do something like:
>
> self->{repeater} = $self->repeat( '250', [ \&read_telnet, $self ] );
> and later
> self->{repeater}->cancel;
>
> #############################################
>
> After toying with how it works, and seeing how it works from
> a commandline version, it seems you are close to getting it to work.
> Goodluck.
>
>
>
> --
> I'm not really a human, but I play one on earth.
> http://zentara.net/japh.html
------------------------------
Date: Fri, 04 Mar 2005 21:28:04 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Passing in the replace string for a regex via the command line - HOW?
Message-Id: <Xns960FA784D274Easu1cornelledu@127.0.0.1>
Brian McCauley <nobull@mail.com> wrote in
news:d09sev$9t5$1@sun3.bham.ac.uk:
> Anthony Roy wrote:
>
>> A. Sinan Unur wrote:
>> ...
>>
>>> $string =~ s/$in/$out/ee;
>>
>>
>> Excellent - I knew there would be a simple solution. Thanks.
...
> If you insist on having in/out as separate variables then I'd suggest
> the the chomp/eval/here-doc solution as described in my lightning talk
> at YAPC::Europe::2004 where I pleaded for this question (and honest
> answers to it) to be put in the FAQ.
Argh! I do remember you making this point at least once before. I went
back and re-read your talk. It makes sense to me. I am sorry I forgot
about it.
I took me a while to re-locate it (apparently, my skills at using
Google's search interface are not that great), so I am posting the
reference here for others' benefit:
http://birmingham.pm.org/talks/faq/Question.html
Sinan.
------------------------------
Date: Fri, 4 Mar 2005 12:35:05 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: persistant db connection
Message-Id: <pctmf2xa3p.ln2@goaway.wombat.san-francisco.ca.us>
On 2005-03-04, Alexandre Jaquet <alexj@floor.ch> wrote:
> Alexandre Jaquet a écrit :
>>
>> In the startup.pl I specify DBI:mysql:test : If I want it's work for
>>
>> db1, db2 ... ?
>>
>> Apache::DBI->connect
>> ("DBI:mysql:test:localhost",
>> "dbmaster",
>> "tbontb22",
>> {
>> PrintError => 1, # warn() on errors
>> RaiseError => 0, # don't die on error
>> AutoCommit => 1, # commit executes immediately
>> }
>> );
>
> Do I've to execute show databases and do a loop with each database ?
First, DBI->connect does not go in startup.pl! DBI->connect is what
you use in your CGI/mod_perl scripts. connect_on_init is used in
startup.pl (assuming that your startup.pl is called in your httpd.conf).
Second, as Brian already suggested, you don't have to connect_on_init at
all. It is only helpful when starting Apache, to allow it to connect on
startup instead of at the first request wanting a db connection. But
it's not likely to give you a huge boost for that first request, since
setting up the DB connection (especially to localhost) isn't all that
resource-intensive. If you really do plan on having lots of databases,
I'd let Apache manage the initial connections to each database for you.
(Who knows--maybe a particular httpd child will never connect to half those
databases; if you use connect_on_init you've wasted those connections.)
Third, if you still insist on using connect_on_init with all of your
databases, you will need to execute connect_on_init for each database
you want Apache to connect to on startup. However you get that list of
databases is your business (hardcoded, SHOW DATABASES, whatever).
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information
------------------------------
Date: 4 Mar 2005 19:49:02 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Questions about Perl for Windows
Message-Id: <Xns960F8C8E734B4castleamber@130.133.1.4>
Bart Lateur wrote:
> For example, searching for Term::ReadKey:
"term::readkey" filetype:ppd
Thanks for the tip.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Fri, 4 Mar 2005 11:17:26 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: ranking texts against a white list
Message-Id: <slrnd2h616.6tb.tadmc@magna.augustmail.com>
David K. Wall <darkon.tdo@gmail.com> wrote:
> A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
>> you can Google for them on the web.
>
> I bet Google hates the use of their trademarked name as a generic
> verb.... :-)
I hope the smiley means you mean just the opposite...?
I would think they _love_ it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 04 Mar 2005 13:20:18 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: ranking texts against a white list
Message-Id: <i6ednVdCm65_O7XfRVn-sQ@comcast.com>
Tad McClellan wrote:
> David K. Wall <darkon.tdo@gmail.com> wrote:
>> A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
>
>>> you can Google for them on the web.
>>
>> I bet Google hates the use of their trademarked name as a generic
>> verb.... :-)
>
>
> I hope the smiley means you mean just the opposite...?
>
> I would think they _love_ it.
>
Er, no. Because that's how you lose trademarks. Ask Bayer,
for whom aspirin used to be a trademark. Also escalator,
linoleum, zipper and yo-yo, all of which used to be brand
names, and were lost to their owners because they became
generic terms.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: 4 Mar 2005 11:04:25 -0800
From: stov753@aol.com
Subject: Re: RTF::Text::Converter
Message-Id: <1109961670.077139.203120@z14g2000cwz.googlegroups.com>
Actually, it does seem to be in the RTF. I have about half a dozen
files. A couple of them actually parsed. A couple of them squeezed out
the first line or so of the document and nothing more. But on the last
one I got a suggestion to use "sloppy" because the converter had
encountered an "illegal" expression...so I'm trying to figure out how
to use "sloppy". But I'm definitely using the latest version.
Steven Stovall
sstovall@amtrex.com
Brian Wakem wrote:
> Actually come to think of it I had to upgrade to a newer version of
> RTF::TEXT::Converter at one point when it started failing on certain
> documents (change in specification perhaps?). Maybe you should make
sure
> you have the latest version.
>
>
>
> --
> Brian Wakem
------------------------------
Date: 4 Mar 2005 14:02:14 -0800
From: stov753@aol.com
Subject: Re: RTF::Text::Converter
Message-Id: <1109972510.494407.257470@o13g2000cwo.googlegroups.com>
Please disregard my last posting, which was based on an errant run. I
have half a dozen very similar files, and they all yield nothing more
than the first 10 or so text tokens. But I can dump the text token by
token, using the tokenizer -- which I guess is really the best I can
do.
stov753@aol.com wrote:
> Actually, it does seem to be in the RTF. I have about half a dozen
> files. A couple of them actually parsed. A couple of them squeezed
out
> the first line or so of the document and nothing more. But on the
last
> one I got a suggestion to use "sloppy" because the converter had
> encountered an "illegal" expression...so I'm trying to figure out how
> to use "sloppy". But I'm definitely using the latest version.
>
> Steven Stovall
> sstovall@amtrex.com
------------------------------
Date: Fri, 04 Mar 2005 15:56:46 -0500
From: * Tong * <sun_tong@users.sourceforge.net>
Subject: Re: WikiConverter
Message-Id: <pan.2005.03.04.20.56.46.745548@users.sourceforge.net>
On Thu, 03 Mar 2005 18:07:54 -0600, Tad McClellan wrote:
> * Tong * <sun_tong@users.sourceforge.net> wrote:
>
>> ... Nothing works. Anybody can? Please help.
>
> You should provide one or more symptoms if you hope to get a diagnosis.
All "print" from the OP test case gave empty result.
--
Tong (remove underscore(s) to reply)
*niX Power Tools Project: http://xpt.sourceforge.net/
- All free contribution & collection
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7858
***************************************