Home  |  Linux  | Mysql  | PHP  | XML
From:Richard Lee Date:Wed May 14 14:58:36 2008
Subject:Re: assign default value to variables I assign from split
Dr.Ruud wrote:
> "Jenda Krynicky" schreef:
>   
>> Dr.Ruud:
>>     
>>> Richard Lee:
>>>       
>
>   
>>>> [$file1,$file2,$file3,$file4,$file5,$file6,$file10,$file25]
>>>> I didn't want to put them in array
>>>> since I need to use individual named variable later
>>>>         
>>> And why is that?
>>>       
>> Maybe because in the real code they are not $file1, $file2,...
>> but rather $username, $password, $last_login, $created,
>> $permissions, ...
>>     
>
> Then you create named constants for that, with enumeration if you like;
> or use a hash.
>
>
>   
>> And assigning the default is the last thing that's done to all of
>> them.
>>     
>
> There would be no problem to do that.
>
> But better stop guessing and let Richard answer.
>
>   
yes, variables are particular names and later I wanted to refer back by 
variable names.

However, for now I have done this so far so I just added as array 
instead of breaking out by var names..
-- code is incomplete (meaning I haven't finished yet) --

use warnings;
use strict;
use Data::Dumper;

my $directory = q#/home/server1/arch#;
my @array = qx/ls -tr $directory | tail -1/;

my @hh;
for ( @array ) {
        my $file = $_;
        open FILE, "ls -tr | zcat -d $directory/$file |", or die qq/you 
truly suck $!\n/;
        my $count;
        my %hh;
        while (<FILE>) {
             chomp;
             next if /^$/;
             next if /^#/;
  
             my @array   = map $_||'default', (split 
/\|/)[3,4,6,7,12,40,41,42,43,46,56,64];
             next if $array[0] eq 'default';
             $array[10] =~ s/\,/\-/g;
             push @hh, \@array;
        }
        close FILE;
}

system("clear");
print 
"===================================================================================================\n\n";

my %missing_address;
my %duration_report;

for (@hh) {
    my $yahoo = $_;
    $missing_address{$$yahoo[1]}++ if $$yahoo[8] =~ /^default$/ and 
$$yahoo[0] != m/espn|google|msn/;
    $$yahoo[4] +=
}

if (%missing_cics) {
   for (keys %missing_address) {
       print "MISSING ADD: $_ : $missing_address{$_} \n";
   }
}

for (keys %duration_report) {
     print "total duration $_  : $duration_report{$_}\n";
}
Navigate in group perl.beginners at sever nntp.perl.org
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants