Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Problem with larger files (and s/)

by jethro (Monsignor)
on Jun 24, 2008 at 22:40 UTC ( #693839=note: print w/replies, xml ) Need Help??


in reply to Problem with larger files (and s/)

The NOT\t\tNULL issue is trivially corrected with
if (not s/NOT NULL/\t\tNOT NULL/s) { s/NULL/\t\tNULL/s; }
(at least I hope so, didn't test it).

The following regex works too:

s/(NOT\s+)?NULL/\t\t$1NULL/s
To find the solution to the other problem I would suggest loading that 9k file into an editor (not word, not wordpad, but you probably know that), cut it by half and feeding it to your program again. If the problem is still there when it is 300 bytes long you know it isn't because of size, but probably the wrong file format.

If not, put another print statement before all the regexp to see if perl reads the file incorrectly or mangles it in your code (which to me looks perfectly ok).

Replies are listed 'Best First'.
Re^2: Problem with larger files (and s/)
by Cloudster (Novice) on Jun 25, 2008 at 14:54 UTC
    Thank you very much for your trivial correction, it was spot-on. I'm learning Perl via an older copy of O'Reilly's Perl CD collection, and had not yet seen an example of using /s as an if test. Works like a charm.

    As far as the Unicode problem, see my reply to the previous reply.

    *facepalm again*
      Sorry, the 'trivially' wasn't meant as in 'trivial problem' but more like 'less sophisticated solution', i.e. without packing it into one regex or using negative lookahead (which I wanted to mention, but I couldn't remember the name, which was ample proof to me that it is a non-trivial solution). ;-)
        I had replied to your message, but apparently it vanished. I had no problem with your usage of the term 'trivial', and I appreciate you not giving a highly-dense solution as I'm still learning the language and high density would require more brainpower than I'm willing to devote to it. I also plan on posting this code on SQLServerCentral.com for other DBAs to use and modify, and by using a simpler, 'trivial' implementation, the code will be more easily modified by others. If they know how to make it more dense, let 'em.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://693839]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2019-08-25 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?