Sponsored Content
Top Forums Shell Programming and Scripting [Perl] Strange problem with array Post 302467030 by Klashxx on Thursday 28th of October 2010 04:28:48 AM
Old 10-28-2010
Do it this way:
Code:
#!/usr/bin/perl -w #-d

use strict;

my $pu;
my $pu_list_cmd;

my @pu_list = (
"PU_0001",
"PU_0002",
"PU_0003",
"PU_0004",
"PU_0005");

printf "pu_list at the beginning: @pu_list\n";
foreach (@pu_list) {
  $pu = $_;
  printf "$pu\n";
  printf "pu_list in foreach loop: @pu_list\n";
} # End of foreach loop

#printf "pu_list at the end: @pu_list\n";


printf "pu_list at the beginning: @pu_list\n";
foreach $pu (@pu_list) {
  $pu_list_cmd = "echo \"$pu applied\"";
  printf "$pu";

  open (CMD, '-|', "$pu_list_cmd");
  while (<CMD>) {
    chomp;
    if ( /applied$/ ) {
      printf " ... OK.\n";
    } elsif ( /ERROR: There is no PU/ ) {
      printf " ... not installed.\n";
    }
  } # End of while loop
  close (CMD);
  printf "pu_list in foreach loop: @pu_list\n";
} # End of foreach loop

printf "pu_list at the end: @pu_list\n";

This User Gave Thanks to Klashxx For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strange array handling in ksh93

I wrote a script in ksh93 (the OS is AIX 5.2, ML7), which failed to run. After some testing i found out why, but the answer is a bit dissatisfying. Look for yourself: #!/bin/ksh93 # --------- Step Names typeset achStepName="foo" typeset achStepName="bar" typeset achStepName="fubar"... (3 Replies)
Discussion started by: bakunin
3 Replies

2. Shell Programming and Scripting

Perl script strange problem

Hi All, I have one strange problem in perl script. Bellow is the contents of the script i am trying to write: #!/usr/local/bin/perl my $module_list = ''; my @running_module; my $count=0; my $flag=0; my $ccprojecthome=$ENV{CCPROJECTHOME}; @module_list = `cat... (2 Replies)
Discussion started by: vaibhav
2 Replies

3. Shell Programming and Scripting

PERL, push to hash of array problem

$key = "a"; $value = "hello"; %myhash = {} ; push @{ myHash{$key} }, $hello; print $myHash{$key}."\n"; this script prints "hello" but has following error message. Reference found where even-sized list expected at ./test line 5. can any one help me to fix this problem?? (3 Replies)
Discussion started by: bonosungho
3 Replies

4. Shell Programming and Scripting

Strange behaviour with perl i/o?

Hi All, I got a strange problem here. I have a perl script which is fetching data from a database table and writing a file with that data. If i run that script from linux command line, the file it creates is a normal ascii text file without any binary character in it.But... (9 Replies)
Discussion started by: DILEEP410
9 Replies

5. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

6. Shell Programming and Scripting

Perl and string array problem

#!/usr/bin/perl my @arr=("hello", "how", "are", "you"); $l=length(@arr); print $l; This print 1.Why? How can i print the array size = 4? I want to store these in an array. hello how are you And then i want to access these element through indexing. How can i do this? (4 Replies)
Discussion started by: cola
4 Replies

7. Shell Programming and Scripting

Perl nested array problem

I have a array reference which has some number of array references inside it.The nested array references also contains the array references. my $Filename = "sample.xml"; my $Parser = new XML::Parser( Style => 'tree' ); my $Tree = $Parser->parsefile( $Filename ); Here the $Tree is the... (6 Replies)
Discussion started by: karthigayan
6 Replies

8. Shell Programming and Scripting

Array in Perl - Detect several file to be in one array

Hi everyone I have one question about using array in perl. let say I have several log file in one folder.. example test1.log test2.log test3.log and the list goes on.. how to make an array for this file? It suppose to detect log file in the current directory and all the log file will... (3 Replies)
Discussion started by: sayachop
3 Replies

9. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies
Ace::Graphics::Glyph::box(3pm)				User Contributed Perl Documentation			    Ace::Graphics::Glyph::box(3pm)

NAME
Ace::Graphics::Glyph::box - The "box" glyph SYNOPSIS
See L<Ace::Graphics::Panel> and L<Ace::Graphics::Glyph>. DESCRIPTION
This is the most basic glyph. It draws a filled box and optionally a label. OPTIONS The following options are standard among all Glyphs. See individual glyph pages for more options. Option Description Default ------ ----------- ------- -fgcolor Foreground color black -outlinecolor black Synonym for -fgcolor -bgcolor Background color white -fillcolor Interior color of filled turquoise images -linewidth Width of lines drawn by 1 glyph -height Height of glyph 10 -font Glyph font gdSmallFont -label Whether to draw a label false BUGS
Please report them. SEE ALSO
Ace::Sequence, Ace::Sequence::Feature, Ace::Graphics::Panel, Ace::Graphics::Track, Ace::Graphics::Glyph::anchored_arrow, Ace::Graphics::Glyph::arrow, Ace::Graphics::Glyph::box, Ace::Graphics::Glyph::primers, Ace::Graphics::Glyph::segments, Ace::Graphics::Glyph::toomany, Ace::Graphics::Glyph::transcript, AUTHOR
Lincoln Stein <lstein@cshl.org>. Copyright (c) 2001 Cold Spring Harbor Laboratory This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See DISCLAIMER.txt for disclaimers of warranty. perl v5.14.2 2001-02-20 Ace::Graphics::Glyph::box(3pm)
All times are GMT -4. The time now is 06:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy