Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: assign defa...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 13 of 16 Topic 11061 of 12261
Post > Topic >>

Re: assign default value to variables I assign from split

by rich.japh@[EMAIL PROTECTED] (Richard Lee) May 14, 2008 at 06:17 PM

John W. Krahn wrote:
> Richard Lee wrote:
>> Dr.Ruud wrote:
>>>
>>> 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 @[EMAIL PROTECTED]
 = qx/ls -tr $directory | tail -1/;
>
> You are only getting one file name (tail -1) so why are you assigning 
> it to an array?  It would be more efficient to do that directly in 
> perl. Also you haven't removed the newline.
>
>
>> my @[EMAIL PROTECTED]
>> for ( @[EMAIL PROTECTED]
 ) {
>>        my $file = $_;
>
> Usually written as:
>
> for my $file ( @[EMAIL PROTECTED]
 ) {
>
> Since @[EMAIL PROTECTED]
 only has one file name in it why do you need the loop?
>
>
>>        open FILE, "ls -tr | zcat -d $directory/$file |", or die qq/you 
>
> My version of zcat does not have a -d switch, what does it do on your 
> system?  It appears that "ls -tr | " in front of zcat is superfluous? 
> What do you think it will do there?
>
>
>> truly suck $!\n/;
>>        my $count;
>>        my %hh;
>>        while (<FILE>) {
>>             chomp;
>>             next if /^$/;
>>             next if /^#/;
>>  
>>             my @[EMAIL PROTECTED]
   = map $_||'default', (split 
>
> Why does this array have the same name as the other array in file scope?
>
>
>> /\|/)[3,4,6,7,12,40,41,42,43,46,56,64];
>>             next if $array[0] eq 'default';
>>             $array[10] =~ s/\,/\-/g;
>
> More efficient as:
>
>              $array[10] =~ tr/,/-/;
>
>
>>             push @[EMAIL PROTECTED]
 \@[EMAIL PROTECTED]
>>        }
>>        close FILE;
>
> When you close a piped open you should verify that the pipe closed 
> correctly:
>
>          close FILE
>              or warn $! ? "Error closing ls pipe: $!"
>                         : "Exit status $? from ls";
>
>
>> }
>>
>> system("clear");
>> print 
>>
"===================================================================================================\n\n";

>>
>>
>> my %missing_address;
>> my %duration_re****t;
>>
>> for (@[EMAIL PROTECTED]
) {
>>    my $yahoo = $_;
>
> Usually written as:
>
> for my $yahoo ( @[EMAIL PROTECTED]
 ) {
>
>
>>    $missing_address{$$yahoo[1]}++ if $$yahoo[8] =~ /^default$/ and 
>> $$yahoo[0] != m/espn|google|msn/;
>>    $$yahoo[4] +=
>
> $$yahoo[] is usually written as $yahoo->[].
>
> $$yahoo[8] =~ /^default$/ is usually written as $yahoo->[8] eq
'default'.
>
> $$yahoo[0] != m/espn|google|msn/ is incorrect, you probably meant 
> $yahoo->[0] !~ m/espn|google|msn/.
>
>
>> }
>>
>> if (%missing_cics) {
>>   for (keys %missing_address) {
>>       print "MISSING ADD: $_ : $missing_address{$_} \n";
>>   }
>> }
>>
>> for (keys %duration_re****t) {
>>     print "total duration $_  : $duration_re****t{$_}\n";
>> }
>
>
> John
thanks for pointing things out.. I am going to finish this script 
tonight and inco****ate correction and post.. thank you so much
 




 16 Posts in Topic:
want to assign default value to variable I assign from split but
rich.japh@[EMAIL PROTECTE  2008-05-12 23:39:07 
Re: want to assign default value to variable I assign from split
Jenda@[EMAIL PROTECTED]   2008-05-13 08:14:35 
Re: want to assign default value to variable I assign from split
krahnj@[EMAIL PROTECTED]   2008-05-13 04:32:48 
Re: want to assign default value to variable I assign from split
rob.dixon@[EMAIL PROTECTE  2008-05-13 08:34:42 
Re: want to assign default value to variable I assign from split
rich.japh@[EMAIL PROTECTE  2008-05-13 18:22:38 
Re: want to assign default value to variable I assign from split
rob.dixon@[EMAIL PROTECTE  2008-05-14 01:02:40 
Re: want to assign default value to variable I assign from split
Uri Guttman <uri@[EMAI  2008-05-14 04:10:24 
Re: assign default value to variables I assign from split
rvtol+news@[EMAIL PROTECT  2008-05-13 09:56:02 
Re: assign default value to variables I assign from split
Jenda@[EMAIL PROTECTED]   2008-05-14 11:26:22 
Re: assign default value to variables I assign from split
rvtol+news@[EMAIL PROTECT  2008-05-14 22:45:24 
Re: assign default value to variables I assign from split
rich.japh@[EMAIL PROTECTE  2008-05-14 16:58:36 
Re: assign default value to variables I assign from split
krahnj@[EMAIL PROTECTED]   2008-05-14 15:10:26 
Re: assign default value to variables I assign from split
rich.japh@[EMAIL PROTECTE  2008-05-14 18:17:40 
Re: assign default value to variables I assign from split
rich.japh@[EMAIL PROTECTE  2008-05-28 22:30:09 
Re: assign default value to variables I assign from split
krahnj@[EMAIL PROTECTED]   2008-05-28 19:55:02 
Re: assign default value to variables I assign from split
rich.japh@[EMAIL PROTECTE  2008-05-29 00:01:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 17:59:40 CST 2008.