Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 27th, 2012, 08:16 AM
additude additude is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 463 additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 16 h 21 m 52 sec
Reputation Power: 45
Pattern Matching characters and word counts

I am working on a pretty simple "newspaper" style project where the user submits a text file with some special embeded codes that I catch with some pattern matching and then format that into an HTML table with one column, two columns or three columns. I let the user choose the column length (in number of text characters) and the number of columns to use.

I have everything done with extracting the text, regexing my embeded codes, putting everything I need into an array, counting characters & words and formatting the HTML.

My problem is I need to employ some form of word wrapping from the bottom of first table column stretching to the top of the second column and so on based on the required column character length.

Any ideas appreciated.

I am not sure what the best approach is. if I can take my text and feed it to another regex based on character/word count parameters? Then need to massage it to not split the bottom line in half?
Code:
^.{1,$column_length}$


is something I am considering but I am not sure about the finishing of the "last line" in the column.

The character column length isn't super critical and I can complete the last line in first column before starting the second column and so on.

I am also using css to justify the text in the table.

Any ideas, help or approach is greatly appreciated.

Thanks for reading.

Last edited by additude : October 27th, 2012 at 08:25 AM.

Reply With Quote
  #2  
Old October 27th, 2012, 11:02 AM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 506 Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 19 h 4 m 21 sec
Reputation Power: 385
I probably understand roughly what you want, but you are not providing enough details. Please provide an example of your data, as well as the code written so far, so that we can suggest solutions.

Reply With Quote
  #3  
Old October 27th, 2012, 11:24 AM
FishMonger FishMonger is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2009
Posts: 1,645 FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 22 h 51 m 5 sec
Reputation Power: 1170
I'd probably look into using one of the text wrapping modules on cpan.

http://search.cpan.org/search?m=all&q=text+wrap&s=1

Reply With Quote
  #4  
Old November 13th, 2012, 07:17 AM
additude additude is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 463 additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 16 h 21 m 52 sec
Reputation Power: 45
Thanks FishMonger & Laurent_R, I went over to CPAN and decided to use Text::Wrap::Smart::XS and I installed the mod using the MCPAN shell.

But I ended up with an issue after installing the mod and I hope you or someone might be willing to give me some advise on how to correct the install.

This is what I have:
At one time there was /perl5/5.8.8/ installed on the linux system and @INC is still pathed for /5.8.8/....

But there has been a version upgrade at some point to /perl5/5.15.4/ and perl -v tells me 5.15.4 is operating.

All my current scripts are happy tho with @INC the way it is pointing to /perl5/5.8.8/. Probably because all the installed mods were installed and compiled with 5.8.8.

This new install of Text::Wrap::Smart::XS wants to install to /perl5/5.15.4/ which is right, but because of @INC pathed the way it is, Text::Wrap::Smart::XS can't be found.

I have tried path prefixing @INC with
Code:
use lib=".../perl5/5.15.4/...";
and I have tried many different sequences of pathing but it all leads me to other problems with the script like when using diagnostics.pm, XSLoader.pm, etc. to name a few because in many cases it seeks out the 5.15.4 path filename instead of the 5.8.8 path filename.

I've tried several things, but there is nothing that works 100%.

I wish I could just install this mod using /perl5/5.8.8/ and maybe I would be done with it, but I am at a loss as to if that is even a possibility at this point or maybe there is another way to install this mod I am not aware of to make it work?

Any help or advise would be greatly appreciated. I have googled and read several articles but I am either missing something; or finding out I am S-O-L; or I don't understand what to do.

I have also posted a similiar question over in the Linux Help

Reply With Quote
  #5  
Old November 13th, 2012, 09:12 AM
FishMonger FishMonger is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2009
Posts: 1,645 FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 22 h 51 m 5 sec
Reputation Power: 1170
Those 2 version of perl are not binary compatible, so any module installed under 5.8.8 that needed XS code will need to be reinstalled under 5.15.4

If perl -v points to /perl5/5.15.4 but only the /perl5/5.8.8/ paths are in @INC, then someone didn't do the upgrade properly.

How are you executing your script?

Did you specify the proper path on the shebang line?

Reply With Quote
  #6  
Old November 14th, 2012, 08:19 AM
additude additude is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 463 additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level)additude User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 4 Days 16 h 21 m 52 sec
Reputation Power: 45
Thanks FishMonger
#!/usr/bin/perl

I just transfered my old server to a new server a few months ago and haven't installed any new perl mods since the transfer. When I was trying to install this Text::Wrap::Smart::XS I discovered this issue.

I am probably responsible for the incorrect install. Not knowing the scope of what I was doing I tried installing the 5.15.4 perl upgrade thru PLESK and it was apparently not compatable with the old server OS and it broke. So I ended up moving over to a new server and now I have this.

All my previous scripts that I have are working and run fine on the new server even with the previous 5.8.8 mods installed that those scripts use.

This scripts are in a domain's cgi-bin and I call them from IE browser.

Do you have any thoughts on possibly reinstalling? or am I looking to open a huge can of worms with all my 5.8.8 stuff?

Any suggestions to resolve this?

I am learning the hard way

Thanks...

Reply With Quote
  #7  
Old November 14th, 2012, 08:58 AM
FishMonger FishMonger is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2009
Posts: 1,645 FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 22 h 51 m 5 sec
Reputation Power: 1170
What version of perl is on this new server and is it the only version installed?

When you copied your scripts over to the new server, did you also copy over modules. If so, are those module pure perl, or were they built with XS code dependencies?

If they rely on XS code and were built for a different version of perl than what you're using on this new server, then those modules will need to be reinstalled/compiled.

If you're not sure what XS code is, here's some info.
http://en.wikipedia.org/wiki/XS_%28Perl%29

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Pattern Matching characters and word counts

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap