CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Console formatting and limitations

 



friendship
New User

Jan 15, 2014, 10:44 AM

Post #1 of 7 (1707 views)
Console formatting and limitations Can't Post

Hi strangers,

I'm completely new to Perl and expanding on a script to serve my needs. When run, the script opens the console and edits blocks of text. For instance, "omg I love you :)" would print as "oh my god I love you smile" in the console. The problem I'm having is the text becomes split based on the width of the console, so longer strings have line breaks. There is also a buffer for the console as far as how long a string I can enter and have printed.

One slight workaround is a find-replace on paragraph marks in Word, which fixes segmented words ("lo<p>ve") but that sometimes leads to words beside each other ("loveyou"). Am I missing something about the script where I can have it work through the string outside of the console, thus bypassing its limitations?

Also, I cannot reproduce the script as it is not mine to share. My impression of it is it is very basic and changes things based on if "x" replace with "y" rules.

Any help would be greatly appreciated!


FishMonger
Veteran / Moderator

Jan 15, 2014, 11:32 AM

Post #2 of 7 (1705 views)
Re: [friendship] Console formatting and limitations [In reply to] Can't Post

Without seeing the script it is impossible to tell you what's wrong, especially based on your limited and unclear description of the problem.

If you can't post the script, then write a short but complete test script that demonstrates the same issue. With that info we should be able to point you in the right direction.


friendship
New User

Jan 15, 2014, 1:15 PM

Post #3 of 7 (1696 views)
Re: [FishMonger] Console formatting and limitations [In reply to] Can't Post

Here's a very hacked down version of the script. I'm running in through Padre to open the console which allows me to input a string of text to be converted.


Code
#!/usr/bin/perl 
#


while(<>) {
chomp;
$_ = Filter($_);
print "$_\n";
}


sub Filter {
local($_) = @_;
# chomp;
print "$n orig:$_\n" if $debug_filt;
s/\t+/ /g;
s/ */ /g;
s/\r//g;

print "at 04=($_)\n" if $debug_filt > 1;

if( /[a-z] 1 /i || / 1 [a-z]/i ) {
s/ 1 / one /g; # ??
}
s/\bLOL\b/laugh out loud/ig;

return $_;
}

1;


So inputting this chunk:


Quote
David Crystal notes that use of LOL is not necessarily genuine,[18] just as the use of smiley faces or grins is not necessarily genuine, posing the rhetorical question "How many people are actually 'laughing out loud' when they send LOL?". Franzini[2] concurs, stating that there is as yet no research that has determined the percentage of people who are actually laughing out loud when they write LOL.


Prints this text, which I select and copy:


Quote
David Crystal notes that use of laugh out loud is not necessarily genuine,[18] j
ust as the use of smiley faces or grins is not necessarily genuine, posing the r
hetorical question "How many people are actually 'laughing out loud' when they s
end laugh out loud?". Franzini[2] concurs, stating that there is as yet no resea
rch that has determined the percentage of people who are actually laughing out l
oud when they write laugh out loud.


I'm guessing I'm using the script fundamentally wrong, and that there is a means to use it without the console, but I'm not sure. Thanks!


FishMonger
Veteran / Moderator

Jan 15, 2014, 1:41 PM

Post #4 of 7 (1689 views)
Re: [friendship] Console formatting and limitations [In reply to] Can't Post

Have you tried running your script directly from the console instead of through Padre?

I don't use Padre, so I just ran it directly from the command line and couldn't reproduce your issue. This indicates to me that the problem is related to your Padre configuration.


friendship
New User

Jan 15, 2014, 2:02 PM

Post #5 of 7 (1685 views)
Re: [FishMonger] Console formatting and limitations [In reply to] Can't Post

Ran it straight from console and had the same issue. Is the problem that I'm using Windows 7's archaic console rather than a linux alternative?

I did a search for alternatives that would run in Windows but only came up with aesthetic covers of the Windows console.


(This post was edited by friendship on Jan 15, 2014, 2:04 PM)


FishMonger
Veteran / Moderator

Jan 15, 2014, 2:16 PM

Post #6 of 7 (1679 views)
Re: [friendship] Console formatting and limitations [In reply to] Can't Post

The output will be wrapped based on your "Window Buffer Size".

You could increase that value if you wish.

The buffer size (width and height) should be equal to or greater than the configured window size.


(This post was edited by FishMonger on Jan 15, 2014, 2:20 PM)


friendship
New User

Jan 16, 2014, 10:23 AM

Post #7 of 7 (1659 views)
Re: [FishMonger] Console formatting and limitations [In reply to] Can't Post

Wonderful! I had tried changing the Command History buffer size but changing the width on "Screen Buffer Size" did it. Thanks for helping with my silly issue!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives