[33149] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4428 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 8 03:09:21 2015

Date: Fri, 8 May 2015 00:09:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 8 May 2015     Volume: 11 Number: 4428

Today's topics:
        Cheap Audemars Piguet Watches,Blancpain Watches,Breguet wholesaler2016@gmail.com
    Re: custom 'multigrep' <gamo@telecable.es>
    Re: custom 'multigrep' <rweikusat@mobileactivedefense.com>
    Re: Doubt about a sample code in "Hashes" chapter, Perl <gravitalsun@hotmail.foo>
    Re: Doubt about a sample code in "Hashes" chapter, Perl <bauhaus@futureapps.invalid>
    Re: Folding dirpath into wildcard for fileglob. <see.my.sig@for.my.address>
    Re: Folding dirpath into wildcard for fileglob. <gravitalsun@hotmail.foo>
    Re: Folding dirpath into wildcard for fileglob. <gravitalsun@hotmail.foo>
    Re: Folding dirpath into wildcard for fileglob. <rweikusat@mobileactivedefense.com>
    Re: Folding dirpath into wildcard for fileglob. <rweikusat@mobileactivedefense.com>
    Re: Folding dirpath into wildcard for fileglob. <gravitalsun@hotmail.foo>
    Re: How do I use "when" to check for "one of two option <rweikusat@mobileactivedefense.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 6 May 2015 11:29:35 -0700 (PDT)
From: wholesaler2016@gmail.com
Subject: Cheap Audemars Piguet Watches,Blancpain Watches,Breguet Watches,Cartier Watches,Jaeger LeCoultre Watches,Patek Philippe Watches,Piaget Watches,Rolex Watches,Vacheron Constantin Watches www.FashionLeader.co
Message-Id: <2eede38c-492d-4ff1-912b-214b95035fab@googlegroups.com>

Cheap Audemars Piguet Watches,Blancpain Watches,Breguet Watches,Cartier Watches,Jaeger LeCoultre Watches,Patek Philippe Watches,Piaget Watches,Rolex Watches,Vacheron Constantin Watches www.FashionLeader.co


------------------------------

Date: Thu, 07 May 2015 06:48:08 +0200
From: gamo <gamo@telecable.es>
Subject: Re: custom 'multigrep'
Message-Id: <mieqq8$s7o$1@speranza.aioe.org>

El 04/05/15 a las 04:48, Fillmore escribió:
>> I know how to implement this easily with a fixed number of Keys, but the
>> varying number of keys is confusing me.
>
> Use a loop, Luke.

You know that

$file = $ARGV[0];
$nkeys = @ARGV-1;

so a loop with a

open FILE, "<", $file or die;
while (<FILE>){
	$ok=0;
	for $counter (1..$nkeys){
		$curr_key = $ARGV[$counter];	
		$ok++ if (/$curr_key/);
	}	
	print if $ok == $nkeys;
	print "NONE: $_" if $ok ==0;
}
close FILE;

or something similar could do the task, KISS mode.

-- 
http://www.telecable.es/personales/gamo/
The generation of random numbers is too important to be left to chance


------------------------------

Date: Thu, 07 May 2015 15:44:32 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: custom 'multigrep'
Message-Id: <87mw1g1m7j.fsf@doppelsaurus.mobileactivedefense.com>

gamo <gamo@telecable.es> writes:
> El 04/05/15 a las 04:48, Fillmore escribió:
>>> I know how to implement this easily with a fixed number of Keys, but the
>>> varying number of keys is confusing me.
>>
>> Use a loop, Luke.
>
> You know that
>
> $file = $ARGV[0];
> $nkeys = @ARGV-1;
>
> so a loop with a
>
> open FILE, "<", $file or die;
> while (<FILE>){
> 	$ok=0;
> 	for $counter (1..$nkeys){
> 		$curr_key = $ARGV[$counter];	
> 		$ok++ if (/$curr_key/);
> 	}	
> 	print if $ok == $nkeys;
> 	print "NONE: $_" if $ok ==0;
> }
> close FILE;
>
> or something similar could do the task, KISS mode.

If the idea is to keep things simple, why not get rid of a few not
really useful complications such as writing code in order to stop the
program from being usable as a filter or using a counting loop instead
of making the runtime do the counting for you?

----
my ($line, $oks);

while ($line = <STDIN>) {
    $oks = grep { $line =~ /$_/ } @ARGV;
    
    print $line if $oks == @ARGV;
    print "NONE: $line" unless $oks;
}
----

This is as inefficient as your version but needs fewer dedicated
'moving parts'/ indirections, hence, it should qualify as simpler.

Even something using an explicit file argument and an explicit counting
loop can be implemented in a simpler way making different design
descisions, ie, use $_ for the second loop instead of the first, and
doing things in a less roundabout way[*]:

----
my ($file, $line);

open($file, '<', shift) or die;
while ($line = <$file>) {
    my $oks;
    
    $oks += $line =~ /$_/ for @ARGV;
    
    print $line if $oks == @ARGV;
    print "NONE: $line" unless $oks;
}
----

[*] $ok++ if (/$curr_key/) is equivalent to

if (/$curr_key/ == 1) {
    $ok += 1;
}

so using $ok += /$curr_key/ instead seems rather straight-forward.

Better-safe-than-sorry disclaimer: "If life's a competition, who wins?
The guy dying first or the guy dying last?" ...


------------------------------

Date: Tue, 05 May 2015 14:12:50 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Doubt about a sample code in "Hashes" chapter, Perl Cookbook 2nd
Message-Id: <mia8ij$jto$1@news.grnet.gr>

On 4/5/2015 20:31, Raymundo wrote:
> Hello,
>
> Thank you.
>
> G.Y. Park from South Korea
>

I read your post, and end up to conclusion that actually there is not 
something specific that you need help at.


------------------------------

Date: Tue, 05 May 2015 14:01:24 +0200
From: "G.B." <bauhaus@futureapps.invalid>
Subject: Re: Doubt about a sample code in "Hashes" chapter, Perl Cookbook 2nd
Message-Id: <miabci$d33$1@dont-email.me>

On 04.05.15 19:31, Raymundo wrote:
> Am I missing or misunderstanding something?

For a start, the use of passive voice and active voice
in view of perhaps the plural of a noun:
  "includes"
vs. the 3rd person singular of a verb:
  "includes"
stays ambiguous because the first does not obviously decide
on a the direction of the relation between keys and values
in the hash, unlike the second.

Somehow Perl writers seem to like ambiguous names.
Maybe TIMTOWTDI at work, as an excuse.

If "includes" is a plural, then to what objects should
"includes" in

   if ($includes{$x})

call attention? Included files, or files that include?
Both? Both in some circumstances, but not in others?
It sure seems possible to extrapolate the intended meaning
from a study of the program, but then the variable could
more honestly be named 'L' or similar.

I guess you'd have to ask the author.



------------------------------

Date: Tue, 05 May 2015 19:26:21 -0700
From: Robbie Hatley <see.my.sig@for.my.address>
Subject: Re: Folding dirpath into wildcard for fileglob.
Message-Id: <Z5udnTlincpr5tTInZ2dnUVZ572dnZ2d@giganews.com>


On 5/1/2015 1:18 PM, George Mpouras wrote:

> On 1/5/2015 20:22, Robbie Hatley wrote:
>> Last night I wrote, in another thread:
>
>
> I suspect you want the following
>
>
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $files = GetFiles('/tmp', '*.???');
>
>
> sub GetFiles
> {
> my $dir  = exists $_[0] ? $_[0] : '.';
> my $mask = exists $_[1] ? $_[1] : '*';
> my $result;
> unless (-d $dir) {warn "Directory \"$dir\" does not exist\n"; return []}
> opendir DIR, $dir or eval {warn "Could not read directory $dir\n"; return []};
> $mask =~s/([^?*]+)/\Q$1\E/g;
> $mask =~s|\?|.|g;
> $mask =~s|\*+|.*?|g;
> $mask = qr/^$mask$/i;
> while (readdir DIR){
> next unless -f "$dir/$_";
> next unless $_=~$mask;
> push @{$result},$_}
> closedir DIR;
> $result
> }

That's somewhat similar to how I had my GetFiles sub for several months
up until a few days ago, in that it uses opendir/readdur/closedir.

Interesting translation from csh-wildcard language to RE language.
I suspect something like that is going on "under the hood" in the
implementation of <${wildcard}>. But I prefer to use a real fileglob
instead, as then no translation is required.

Yesterday it suddenly occurred to me that my "dirpath" argument
is unnecessary, because directory path can be PART OF the wildcard,
like so:

Getfiles('F', '/rhe/scripts/*.pl /rhe/src/*.c')

which can grab files of various kinds from various places all at once.

So my GetFiles sub now looks like the following; this is a bit
lengthy, but gives you an idea of what this sub is doing; I actually
keep this in a module called RH/Dir.pm and "use" it in scripts
to get an array of file records; then I can access fields from those
records by $file->{Name} $file->{Size} $file->{Inode} etc.


# GetFiles returns a reference to an array of filerecords for user-requested
# types of files, matching a user-given wildcard. Both the "types" and
# "wildcard" arguments are optional.
#
# First argument, if present, should be a code consisting of one of the
# following letters:
# F = regular Files only
# D = Directories only (but not SYMLINKDs).
# B = Both regular files and directories (but not SIMLINKDs).
# A = All files (regular, directories, links, pipes, sockets, etc, etc, etc)
#
# Second argument is a Csh-style wildcard specifying which files to return.
# This can include specifying directories, file name extentions, etc.
#
sub GetFiles (;$$) {
    my $types       = 'A'     ; $types    = shift if @_ ;
    my $wildcard    = '.* *'  ; $wildcard = shift if @_ ;
    my @filepaths   = ();
    my @filerecords = ();

    @filepaths = <${wildcard}>;
    if ( ! @filepaths ) {
       warn "Warning from GetFiles: fileglob returned no file paths.\n";
    }

    # Zero all RH::Dir counters here. (You should save a copy in main:: if you want to
    # keep this info, because it gets zeroed each time GetFiles or GetRegularFilesBySize
    # are run. These counters are "per directory info fetch" only.)
    $totfcount = 0;
    $regfcount = 0;
    $sdircount = 0;
    $linkcount = 0;
    $slkdcount = 0;

    # Iterate through file paths, collecting info on files:
    FILE: foreach my $path (@filepaths)
    {
       # First of all, does this path even exist? Now that I've gone over to
       # using fileglobs in this module, it is up to script writers to use
       # wildcards that actually do make sense. Some wildcards yield nonsensical
       # expansions, or expansions which are not the name or path of any file.
       if ( ! -e $path ) {
          warn
          "\n".
          "Warning from GetFiles: no file exists with this path:\n".
          "$path\n".
          "$!\n".
          "Moving on to next file.\n";
          next FILE;
       }

       # Get name from path:
       my $name = get_name_from_path($path);

       # Reject '.' and '..' to avoid infinite loops & infinite recursions:
       if ('.' eq $name || '..' eq $name) {next FILE;}

       # Set "is" variables to keep track of what kind of file this is:
       my $is_regu = -f $path;               # regular file
       my $is_sdir = -d $path && ! -l $path; # non-link dir
       my $is_link = -l $path && ! -d $path; # non-dir link
       my $is_slkd = -d $path &&   -l $path; # SYMLINKD

       # Increment counters:
       ++$totfcount;
       ++$regfcount if $is_regu; # regular file
       ++$sdircount if $is_sdir; # non-link dir
       ++$linkcount if $is_link; # non-dir link
       ++$slkdcount if $is_slkd; # SYMLINKD

       # Filter files according to $types:
       given ($types) {
          when ('F') {next FILE unless $is_regu            ;} # regular files
          when ('D') {next FILE unless $is_sdir            ;} # non-link dirs
          when ('B') {next FILE unless $is_regu || $is_sdir;} # regular files & non-link dirs
          when ('A') {                                     ;} # All
          default    {                                     ;} # All
       }

       # Get current file's info:
       my ($dev, $inode, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime)
       = lstat($path);

       # Get date and time from mtime:
       my ($date, $time) = RH::Util::format_time($mtime, 'Pacific', '24H', 'short');

       # Set type code:
       my $type;
       if    ($is_regu) {$type = 'F';} # Regular file.
       elsif ($is_sdir) {$type = 'D';} # Non-link directory.
       elsif ($is_link) {$type = 'L';} # Non-directory link.
       elsif ($is_slkd) {$type = 'S';} # SYMLINKD.
       else             {$type = 'U';} # Unknown.

       # Push file info record for this file onto array:
       push @filerecords,
          {
             'Name'  => $path,
             'Dev'   => $dev,
             'Inode' => $inode,
             'Mode'  => $mode,
             'Nlink' => $nlink,
             'UID'   => $uid,
             'GID'   => $gid,
             'Rdev'  => $rdev,
             'Size'  => $size,
             'Atime' => $atime,
             'Mtime' => $mtime,
             'Ctime' => $ctime,
             'Date'  => $date,
             'Time'  => $time,
             'Type'  => $type,
          };
    }
    # Return reference to array:
    return \@filerecords;
}





-- 
Cheers,
Robbie Hatley
Midway City, CA, USA
perl -le 'print "\154o\156e\167o\154f\100w\145ll\56c\157m"'
http://www.well.com/user/lonewolf/
https://www.facebook.com/robbie.hatley


------------------------------

Date: Wed, 06 May 2015 11:02:26 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Folding dirpath into wildcard for fileglob.
Message-Id: <michpj$s58$1@news.grnet.gr>

On 6/5/2015 05:26, Robbie Hatley wrote:
> sub GetFiles (;$$) {
     # Return reference to array:


>     return \@filerecords;
> }
>


ok

There are some warnings if
use strict;
use warnings;


the FILE: is not needed , you can simple say    next if ... or   if 
(...) { next }  because you actually have only one flat foreach

there is no reason to return ... as last statement, it will return for 
sure !


Your code can be optimized at many points . If I found some time I give 
a shot.


------------------------------

Date: Wed, 06 May 2015 17:55:46 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Folding dirpath into wildcard for fileglob.
Message-Id: <mida0j$9d$1@news.grnet.gr>

this is faster but again I think something is wrong with the idea anyway









#!/usr/bin/perl
use strict;
use warnings;


my (
$totfcount,
$regfcount,
$sdircount,
$linkcount,
$slkdcount,
$filerecords) =
Getfiles('F','/etc/*.??    /usr/share/doc/transcode/pvm3/*.cfg');


print "$totfcount\n";
use Data::Dumper; print Dumper $filerecords;



sub Getfiles {
my $types     = shift || 'A';
my $wildcard  = shift || '.* *';
my $totfcount = 0;
my $regfcount = 0;
my $sdircount = 0;
my $linkcount = 0;
my $slkdcount = 0;
my $filerecords;
my $type;

     foreach my $path (< $wildcard >) {
     my ($name) = $path =~/([^\/]*)$/;
     next if $name=~/^\.+$/ || ! -e $path;

         if (-f $path) {
         next unless ($types eq 'F') || ($types eq 'B');
         ++$regfcount;
         $type = 'F'
         }
         elsif (-d $path) {
             if ( -l $path ) {
             # dir-link
             next unless $types eq 'Α';
             ++$slkdcount;
             $type = 'S'
             }
             else {
             # non-link dir
             next unless ($types eq 'D') || ($types eq 'B');
             ++$sdircount;
             $type = 'D'
             }
         }
         else {
         next unless $types eq 'Α';

             # non-dir link
             if (-l $path) {		
             ++$linkcount;
             $type = 'L'
             }
             else {
             $type = 'U'
             }
         }

     ++$totfcount;
     my ($dev, $inode, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, 
$mtime, $ctime) = lstat $path;
     push @{$filerecords}, 
{'Path',$path,'Name',$name,'Dev',$dev,'Inode',$inode,'Mode',$mode,'Nlink',$nlink,'UID',$uid,'GID',$gid,'Rdev',$rdev,'Size',$size,'Atime',$atime,'Mtime',$mtime,'Ctime',$ctime,'Type',$type}
     }

$totfcount, $regfcount , $sdircount , $linkcount, $slkdcount, $filerecords
}



------------------------------

Date: Wed, 06 May 2015 16:32:55 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Folding dirpath into wildcard for fileglob.
Message-Id: <87d22diuvs.fsf@doppelsaurus.mobileactivedefense.com>

George Mpouras <gravitalsun@hotmail.foo> writes:
> On 1/5/2015 20:22, Robbie Hatley wrote:
>> Last night I wrote, in another thread:
>
>
> I suspect you want the following
>
>
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $files = GetFiles('/tmp', '*.???');
>
>
> sub GetFiles
> {
> my $dir  = exists $_[0] ? $_[0] : '.';
> my $mask = exists $_[1] ? $_[1] : '*';
> my $result;
> unless (-d $dir) {warn "Directory \"$dir\" does not exist\n"; return []}
> opendir DIR, $dir or eval {warn "Could not read directory $dir\n";
> return []};

As I already wrote a couple of times in the past: The stat in front of
the open is not only completely useless (as the open will report ENOENT
in case the name doesn't exist) but additionally wrong: That the
directory didn't exist by the time the kernel(!) performed the stat
doesn't mean it won't exist by the time the process would have called
open hadn't the stat been there to begin with and vice versa.


> $mask =~s/([^?*]+)/\Q$1\E/g;
> $mask =~s|\?|.|g;
> $mask =~s|\*+|.*?|g;

Considering that passing undef as pattern argument is very likely
useless, the above can also be accomplished by the following,
single-pass algorithm:

    for ($_[1] // '*') {
	/\G([^?*]+)/gc and $mask .= "\Q$1", redo;
	/\G(\?+)/gc and $mask .= '.' x length($1), redo;
	/\G(\*+)/g and $mask .= '.*', redo;
    }

> $mask = qr/^$mask$/i;

Perl caches a regexp with variables interpolated into it in the 'op
structure' of the match using it and won't recompile the pattern unless
the interpolated variable(s) actually changed. Further, matching the
result of a qr still executes enough of the regex compiler that it is
usually actually slower than interpolating directly, cf

----------
use Benchmark;

my @a = ('AAAA') x 100;

my $p = 'A{3}';
my $qr = qr/$p/;

timethese(-3,
	  {
	   qr => sub {
	       /$qr/ for @a;
	   },

	   direct => sub {
	       /$p/ for @a;
	   }});
-----------

> while (readdir DIR){
> next unless -f "$dir/$_";
> next unless $_=~$mask;
> push @{$result},$_}
> closedir DIR;
> $result
> }

Returning a reference to an anonymous array or undef is a weird,
'un-Perlish' way to return a possibly empty list. This also affects the
caller because it cannot use the return value of the function without
checking whether or not it's defined first. Lastly, you should either
use an autovifified glob reference as dirhandle or localize the glob
you're using so that executing the function won't have 'surprising' side
effects on the global environment and because perl will then close the
handle automatically once the binding/ lexical referring to the glob
goes out of scope.

Code modified to address this (possibly introducing different bugs,
issues :-):

----------
#!/usr/bin/perl
use strict;
use warnings;

my @files = GetFiles('/tmp', '*.???');

print(join("\t", @files), "\n");


sub GetFiles
{
    my $dir  = $_[0] // '.';
    my $mask;
    local *DIR;
    
    opendir DIR, $dir or do {
	warn("opendir $dir: $!");
	return;
    };

    for ($_[1] // '*') {
	/\G([^?*]+)/gc and $mask .= "\Q$1", redo;
	/\G(\?+)/gc and $mask .= '.' x length($1), redo;
	/\G(\*+)/g and $mask .= '.*', redo;
    }

    return grep { /^$mask\z/ } readdir(DIR);
}


------------------------------

Date: Wed, 06 May 2015 16:51:34 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Folding dirpath into wildcard for fileglob.
Message-Id: <878ud1iu0p.fsf@doppelsaurus.mobileactivedefense.com>

George Mpouras <gravitalsun@hotmail.foo> writes:

[translate glob pattern to regex]

[...]

> $mask =~s|\*+|.*?|g;

Another remark: This differs from a 'real' glob insofar as a * of the
latter won't match a dot at the beginning of a name in order to support
hiding dot-files. A regex behaving like this could be

(?:(?:(?<=.)\.|[^.]).*)?

which matches either nothing at all or a sequence starting with
something which is either not a dot or a dot with something in front of
it and followed by any number of 'other characters'.


------------------------------

Date: Wed, 06 May 2015 20:53:06 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Folding dirpath into wildcard for fileglob.
Message-Id: <midke7$bsc$1@news.grnet.gr>

>
> Another remark: This differs from a 'real' glob insofar as a * of the
> latter won't match a dot at the beginning of a name in order to support
> hiding dot-files. A regex behaving like this could be
>
> (?:(?:(?<=.)\.|[^.]).*)?
>
> which matches either nothing at all or a sequence starting with
> something which is either not a dot or a dot with something in front of
> it and followed by any number of 'other characters'.
>

thats good !


------------------------------

Date: Tue, 05 May 2015 17:08:57 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: How do I use "when" to check for "one of two options"?
Message-Id: <871tiv3t2e.fsf@doppelsaurus.mobileactivedefense.com>

"G.B." <bauhaus@futureapps.invalid> writes:
> On 29.04.15 21:31, Rainer Weikusat wrote:
>> "G.B." <bauhaus@futureapps.invalid> writes:
>>> On 29.04.15 09:42, Martijn Lievaart wrote:
>>>> On Tue, 28 Apr 2015 16:35:03 +0100, Rainer Weikusat wrote:
>>>
>>>>> /^a\z/i
>>>>>
>>>>> would need to be used to match only a or A.
>>>>
>>>> True, thanks for the correction.
>>>>
>>>> (so I have been making this mistake in this context all my perl life :-( )
>>
>> [...]
>>
>>> ("Everything is just a..., but, you know, \n isn't just...,
>>> and then \r neither, because ... Well, just chop and, oh, wait, chomp
>>> and move on.") So, rather than blaming yourself for accidents of
>>> computing history (cf. Douglas Crockford's talks), get paid for these
>>> design mistakes as a necessity of life. They'll stay in any case.
>>
>> Could you perhaps enlighten about the relation between "\r, \n, chop and
>> chomp" and "Perl regex anchors"? And what is "everything"
>
> I think I could, but suffice it to say that the writer of an RE
> will hardly ever be concerned with \n, say, once both the OS
> and its programs use typed data (as some have done):

[...]

> So, both the lack of typed data, and then a workaround(**) based
> on special characters, lead to Perl REs, as a consequence of Unix
> style. Thus they emphasize certain characters like 'n', 'v', 'r',
> and treat them specially in special context, too, as seen.
> That does not simplify the task, or clarify the expression, IMHO.

'Typed data' is a somewhat ill-defined term in this context, ie, 'byte'
is certainly 'a type', hence, a sequence/ stream of bytes is obviously
typed data. Even when looking at a level that's semantically 'above' 
sequence of bytes, things aren't so clear cut: A so-called 'text file'
is a file containing variable length records with no implicitly defined
structure, separated by a record separator byte sequence, eg, \x0a or
\0x0d\0x0a (or \0x0d to emphasize that movement doesn't necessarily mean
progress :->). Such a file has to be parsed in order to interpret its
contents correctly, however, we could as well be dealing with a sequence
of bits encoding binary structures according to ASN.1 DEP, certainly as
'typed' as it can possibly be, and compared to parsing that, breaking a
text file into 'lines' is a walk in a small, backyard lawn. Even when
assuming the the 'type information' isn't embeddeed in the data but
defined separately, eg, the kind of stuff published by the Miserable
Programmers Expert Group, the effort necessary for 'making sense of it'
is decidedly not negligible.

IMHO, your statement makes little sense beyond "had someone else written
and debugged the deserialiation code, I wouldn't have to". That's
arguably true but applicable to any kind of serialization
convention. The only way to avoid the problem entirely is using a memory
image/ core dump as external data format (or some part of 'a core dump',
eg, serialize C data structures by writing them byte-by-byte until a
structure-sized chunk has been written). But this has other drawbacks,
not the least that languages whose native data structures are defined
precisely enough that such an approach is actually guaranteed to work
(as opposed to "writing something only the program which wrote it can
make sense of" or "only the incarnation of the program which wrote it"
[process] or even "only the incarnation of the program which wrote it in
the state it was in at the time of writing") are at least 'uncommon'.


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 4428
***************************************


home help back first fref pref prev next nref lref last post