October 27th, 2012, 09:16 AM
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?
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 09:25 AM.
October 27th, 2012, 12:02 PM
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.
October 27th, 2012, 12:24 PM
November 13th, 2012, 08:17 AM
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
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
November 13th, 2012, 10:12 AM
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?
November 14th, 2012, 09:19 AM
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
November 14th, 2012, 09:58 AM
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.