hi, I'm trying to get elements from an array (after a certain point) into another array.
However, the array simply takes seemingly random or incorrect elements of the array.
--------------------------code----------------------
#!/usr/bin/perl
print "enter letter to compare to file: ";
chomp($letter = <stdin>); print"\n";
open (SORT, "<C:/sort.dat"
;
@array = <SORT>;
close(SORT);
$pointer = 0;
open (SORT, ">>C:/sort.dat"
;
until ($letter le $array[$pointer]) {
$pointer++;
if ($letter gt $array[$#array]) {
print SORT $letter;
}
}
print "letter will be inserted in between \n----$array[$pointer -1] and \n----$array[$pointer]";
close(SORT);
print "pointer = $pointer\n\n";
$x = 0;
print "x = $x\n\n";
until ($pointer == $#array) {
$temp[$x] = $array[$pointer];
$pointer++;
$x++;
print "$pointer element of array = $array[$pointer] \n";
print "$x element of temp = $array[$x] \n";
}
print "\n";
print"array = $#array, temp = $#temp \n";
-----------------------------------------------------------
if ANYONE can help i'd b really gr8ful!
thanks!
JoE
we are all of us living in the gutter.
But some of us are looking at the stars.
However, the array simply takes seemingly random or incorrect elements of the array.
--------------------------code----------------------
#!/usr/bin/perl
print "enter letter to compare to file: ";
chomp($letter = <stdin>); print"\n";
open (SORT, "<C:/sort.dat"

@array = <SORT>;
close(SORT);
$pointer = 0;
open (SORT, ">>C:/sort.dat"

until ($letter le $array[$pointer]) {
$pointer++;
if ($letter gt $array[$#array]) {
print SORT $letter;
}
}
print "letter will be inserted in between \n----$array[$pointer -1] and \n----$array[$pointer]";
close(SORT);
print "pointer = $pointer\n\n";
$x = 0;
print "x = $x\n\n";
until ($pointer == $#array) {
$temp[$x] = $array[$pointer];
$pointer++;
$x++;
print "$pointer element of array = $array[$pointer] \n";
print "$x element of temp = $array[$x] \n";
}
print "\n";
print"array = $#array, temp = $#temp \n";
-----------------------------------------------------------
if ANYONE can help i'd b really gr8ful!
thanks!
JoE
we are all of us living in the gutter.
But some of us are looking at the stars.