On Jan 7, 2008 8:17 PM, Dale Mosby <[EMAIL PROTECTED]> wrote: > I am trying to think of a good way to write to a file > a path/filename along with some additional data, > and then read it back later. While this is strictly > Linux now, I would like the code to work across > platforms if possible. > > I realize that I will have to deal with translation > of the path delimiter characters. What I'm wondering > about is how to deal with a potentially unlimited > set of characters in file names. snip
If we are just talking about UNIX-like and Win32, then you can just use / as the separator (it just works). If you need to be portable to weird platforms like VMS or a mainframe you want File::Spec*. snip > > For example, consider the really simple file format: > /usr/bin/vi:lrwxrwxrwx:root:root > > I can easily parse this with split but things are > going to break when a file or directory name contains > a colon or whatever I have chosen as my delimiter. snip This is really not portable. Many systems don't have the same concept of permissions. If you are just concerned about delimiters, use a true CSV format. Take a look at CSV::Text**. snip > Bonus question: Can I serialize a data structure on > one machine then un-serialize on another, possibly of > a different OS and maybe slightly different PERL version? > Stated another way, how much divergence between two > systems is tolerated with a serialized data structure? snip Take a look at YAML*** and YAML::Syck****. * http://search.cpan.org/dist/PathTools/lib/File/Spec.pm ** http://search.cpan.org/dist/Text-CSV/lib/Text/CSV.pm *** http://search.cpan.org/dist/YAML/lib/YAML.pm **** http://search.cpan.org/dist/YAML-Syck/lib/YAML/Syck.pm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/