I have no idea how to do this, so help would be much appreciated.
:) The idea is to opendir, readdir,open,<>,split, close, closedir using some loops and usefull data strucures.
As data structure is propose a hash withe filenames as keys and arrayrefs as value.
--#!/usr/bin/perl use strict; use warnings; my %files; my $dir = shift || '.'; opendir DIR,$dir or die "error opeing directory $dir: $!"; while( defined( my $file = readdir DIR ) ){ my $path = "$dir/$file"; next unless -f $path; open my $fh , '<' , $path or do { warn "$file : $! skipping\n"; next }; $files{$file} = []; while(<$fh>){ push @{$files{$file}} , [ split ] } close $fh; } closedir DIR;
In reply to Re: Pick Up Files and put contents into variables
by fruiture
in thread Pick Up Files and put contents into variables
by ap3k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |