![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| perl -write values in a file to @array in perl | meghana | Shell Programming and Scripting | 27 | 06-07-2009 06:05 PM |
| 'who' command -- getting data returned into variables (in bash) | SilversleevesX | Shell Programming and Scripting | 1 | 05-08-2009 05:55 PM |
| [Perl] Accessing array elements within a sed command in Perl script | userix | Shell Programming and Scripting | 2 | 10-03-2008 01:05 PM |
| perl: storing regex in array variables trouble | xist | Shell Programming and Scripting | 3 | 08-29-2008 09:07 AM |
| Getting variables into a array. | vivsiv | Shell Programming and Scripting | 2 | 02-06-2008 03:45 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Perl Array Variables to be returned to main
Hi All,
I can;t seem to print out the array in sequence using the below subroutine. My first element in the array @lotsuffix is suppose to be $lotsuffix[1] as defined in the subroutine, but when the array variable is being pass on the main program, my first element actually becomes $lotsuffix[0] ! Can any expert give some advice on this ? How can i overcome this problem ? Code:
#!/usr/bin/perl
use strict;
my @lotsuffix;
my @date;
capture_LOTSUFFIX_DATE("test");
print "LOTSUFFIX1= $lotsuffix[1]\n";
print "LOTSUFFIX2= $lotsuffix[2]\n";
print "LOTSUFFIX3= $lotsuffix[3]\n";
print "LOTSUFFIX4= $lotsuffix[4]\n";
print "LOTSUFFIX5= $lotsuffix[5]\n";
print "LOTSUFFIX6= $lotsuffix[6]\n";
print "LOTSUFFIX7= $lotsuffix[7]\n";
print "LOTSUFFIX8= $lotsuffix[8]\n";
print "LOTSUFFIX9= $lotsuffix[9]\n";
print "LOTSUFFIX10= $lotsuffix[10]\n";
sub capture_LOTSUFFIX_DATE {
my $counting = 1;
my $line;
for ($counting = 1; $counting <= 10 ; $counting++ ) {
print "reports_${counting}_${_[0]}.txt\n";
open(FH, "< $HISTORY/reports_${counting}_${_[0]}.txt" ) or die $!;
while( $line = <FH> ) {
my @Fld = split(' ', $line );
if ( $Fld[1] eq 'LOTSUFFIX=' ) {
$lotsuffix[$counting] = $Fld[2];
print "$lotsuffix[$counting]\n";
}
if ( $Fld[1] eq 'DATE=' ) {
$DATE[$counting] = $Fld[2];
my @fields = split(/-/, $DATE[$counting]);
$date[$counting] = sprintf ("%s-%s",$fields[1],$fields[2]);
print "$date[$counting]\n";
}
}
close FH;
}
return (@lotsuffix , @date);
}
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|