Pls ignore my earlier solution - it's actually quite silly because it does nothing but duplicates the array @info_array.
To do what you want to do, here is a revised solution:
@array = qw(a b c d);
# $array_len gives you the length of @array
$array_len = @array;
for (0..$#array) {
$a =...
@info_array = (POS,G,AB,R,H,2B);
@a;
for (0..$#info_array) {
$a[$_] = $info_array[$_];
}
In this way, you don't have to know beforehand how many elements are in @info_array, if i understood you correctly.
pearl2
try this:
open (FH, "news.txt") or die $!;
@lines = <FH>;
close (FH);
# To delete the first element in the array @lines
pop @lines;
Something like that.
pearl2
hi robert,
you can try one of these:
$line = "Member ID: 12345";
$line =~ s/.*:\s(\d+)/\1/g;
print "$line\n";
OR
$line = "Member ID: 12345";
($mem, $id) = split/: /, $line;
print "$id\n";
just a suggestion, cos i'm a still a perl novice.
pearl2
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.