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 9th, 2012, 11:14 PM
Calab Calab is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Location: Strathmore, AB, Canada
Posts: 14 Calab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 54 m 43 sec
Reputation Power: 0
Making data 'safe' for writing to a flat file?

The search function is throwing a 500 error, so apologies if this is covered elsewhere.

I'm writing a small file that holds some user data and I want to ensure that I encode it so that I can read it back reliably.

A few pieces of data could contain ANY character that could be stored in a Perl string. Also, some of these strings could be very long.

Some example items that I would write to a file:

Quote:
NAME=Natália Braga
CITY=São Paulo
AGE=25
MEMO=This is some text. It might contain newlines, quotation marks, diacritic marks, or any other "characters" that are legal to store in a perl string.\nHow can I safely convert these data items so that I can later read them back?

Reply With Quote
  #2  
Old October 22nd, 2012, 09:53 AM
1DMF's Avatar
1DMF 1DMF is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2009
Posts: 320 1DMF User rank is Captain (20000 - 30000 Reputation Level)1DMF User rank is Captain (20000 - 30000 Reputation Level)1DMF User rank is Captain (20000 - 30000 Reputation Level)1DMF User rank is Captain (20000 - 30000 Reputation Level)1DMF User rank is Captain (20000 - 30000 Reputation Level)1DMF User rank is Captain (20000 - 30000 Reputation Level)1DMF User rank is Captain (20000 - 30000 Reputation Level)1DMF User rank is Captain (20000 - 30000 Reputation Level)1DMF User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 3 Days 16 h 57 m 54 sec
Reputation Power: 227
Have you looked at the encoding module?

http://perldoc.perl.org/Encode.html

As you are storing personal information in a text file, it will also enable obfuscation!

Edit-> taken from the CPAN docs
------------------------------------------------------
Encoding via PerlIO

If your perl supports PerlIO (which is the default), you can use a PerlIO layer to decode and encode directly via a filehandle.
__________________
Free MP3 Dance Music Downloads

To err is human; To really balls things up you need Microsoft!

Last edited by 1DMF : October 22nd, 2012 at 10:12 AM.

Reply With Quote
  #3  
Old October 22nd, 2012, 09:56 AM
G4143 G4143 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 71 G4143 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 7 h 39 m 39 sec
Reputation Power: 1
I would look at the functionality of the Storable module or the pack/unpack function.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Making data 'safe' for writing to a flat file?

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