![]() |
![]() |
#1 |
"Ed Hall"
Dec 2009
Adirondack Mtns
2·32·197 Posts |
![]()
First, it's entirely possible I'm misunderstanding the actual problem, but here's is my take:
I have more than one version of the Perl script that retrieves factordb composites and runs YAFU to factor them. None of my versions display the intermediate information that is normally shown by YAFU as it runs. To my limited knowledge base, it appears that Perl cannot process incoming text until a LF is received and YAFU uses a CR only so that subsequent lines overwrite instead of scrolling. I was looking at the script and cannot fully understand how retrieved information is processed, but wondered if there might be a way to feed YAFU's output through to stdout without intermediate processing, possibly with getc? The code I'm currently looking at includes the following section which runs YAFU. (I do not know who its author is, since I can't find it in the script.): Code:
open(YAFU, "./yafu \"factor($composite)\" |") or die "Couldn't start yafu to factor $composite $!"; while (<YAFU>) { print "$_"; chomp; if (/^[CP].*? = (\d+)/) { push( @results, $1 ); print "*****\n"; } } close(YAFU); Thanks! |
![]() |
![]() |
![]() |
#2 | |
If I May
"Chris Halsall"
Sep 2002
Barbados
9,421 Posts |
![]() Quote:
|
|
![]() |
![]() |
![]() |
#3 | |
"Ed Hall"
Dec 2009
Adirondack Mtns
67328 Posts |
![]() Quote:
If I have the concept of what I want to do figured out correctly, I'll expect to invoke YAFU and look a binary stream being returned, catch a certain number of bits/bytes and send them for display, treating them as text. Will Perl let me do this directly or will I have to do some kind of type conversion? Off to study this, in hopes of not being sidetracked too soon... |
|
![]() |
![]() |
![]() |
#4 | |
If I May
"Chris Halsall"
Sep 2002
Barbados
100100110011012 Posts |
![]() Quote:
If it is a simple matter of the lines overwriting each other in your above script, I might suggest you try changing your code to be: Code:
while (<YAFU>) { chomp; print "$_\n"; if (/^[CP].*? = (\d+)/) { push( @results, $1 ); print "*****\n"; } } |
|
![]() |
![]() |
![]() |
#5 |
Oct 2006
Berlin, Germany
593 Posts |
![]()
I think the script is based on my script https://www.rechenkraft.net/wiki/Ben...:Yoyo/factordb
The while loop is line oriented, so it sticks to the end of line indication. If no EOL is comming it doesn't continue to the next loop. If you don't want this line handling, you have to use binmode and read buffers of bytes. But in this case you will have problems with the regexp inside the loop which checks for C or P at the beginning of the line, because you don't have this line mode anymore. |
![]() |
![]() |
![]() |
#6 | ||
"Ed Hall"
Dec 2009
Adirondack Mtns
354610 Posts |
![]() Quote:
Quote:
Anyway, thanks for clarifying what I had thought was the issue. Whether I rewrite to use binmode or not will probably be based on how much study I'll need, but sometimes I use these whims to force myself to learn something new about a programming language. And, I had noticed the catch for C and P, and that I would still need to address that. The YAFU code must be sending at least a CR in order to overwrite. Shouldn't I be able to catch any CRs to signal a check for C or P, using their ASCII codes? |
||
![]() |
![]() |
![]() |
#7 |
If I May
"Chris Halsall"
Sep 2002
Barbados
9,421 Posts |
![]() |
![]() |
![]() |
![]() |
#8 | |
"Ed Hall"
Dec 2009
Adirondack Mtns
2×32×197 Posts |
![]() Quote:
However, you have given me a thought: If I modify YAFU to send CRLF, then I should be able to strip the LF in the perl code... |
|
![]() |
![]() |
![]() |
#9 | |
"Ed Hall"
Dec 2009
Adirondack Mtns
67328 Posts |
![]() Quote:
Code:
printf("\r"); fflush(stdout); Code:
printf("\n"); fflush(stdout); And, all of this is just to work with the ECM portion. I haven't even found out where to work in YAFU for the SIQS portion. I'm beginning to think it might be easier to "exec" YAFU and harvest the factors from the log... |
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
HI needing help on installing Perl/ntheory | Trejack | Information & Answers | 5 | 2016-04-17 03:02 |
Factoring polynomials in perl | chris2be8 | Programming | 12 | 2015-08-26 16:23 |
Here is a fun little game for Katydids called "Hypergraphia".Children enjoy | Kathegetes | Miscellaneous Math | 35 | 2014-04-30 21:18 |
they used to be called programs... | chappy | Lounge | 15 | 2012-08-11 21:02 |
Perl help with bigint | kuratkull | Programming | 28 | 2007-04-30 14:14 |