#!/usr/bin/perl use strict; use warnings; use NEURO qw(load_study); use Data::Dump qw(dump); my $study = "mopead"; my %std = load_study($study); my $src_dir = '/nas/corachan/MOPEAD/'; #my $raw_dir = $std{'DATA'}.'/raw'; my $ids_file = $std{'DATA'}.'/ids.csv'; my $names_file =$std{'DATA'}.'/ni_names.csv'; my $proj_file = $std{'DATA'}.'/mopead.csv'; #Leo los que han subido my @orig_str = qx/ls $src_dir/; chomp @orig_str; my %idsinfo; my $idscount; open IDS, "<$ids_file" or die $!; while(){ chomp; my ($key, $value) = split(/,\s?/); $idsinfo{$key} = $value; $idscount = $value; } $idscount++; close IDS; my @not_in_db = grep !$idsinfo{$_}, @orig_str; foreach my $guy (@not_in_db) { $idsinfo{$guy} = $idscount; $idscount++; } open IDS, ">$ids_file" or die $!; open NDS, ">$names_file" or die $!; open PDS, ">$proj_file" or die $!; foreach my $guy (sort {$idsinfo{$a} <=> $idsinfo{$b}} keys %idsinfo) { print IDS $guy,",",$idsinfo{$guy},"\n"; printf NDS "%s,%04d\n", $guy,$idsinfo{$guy}; printf PDS "%04d;mop\n", $idsinfo{$guy}; } close PDS; close NDS; close IDS;