Yes, your code is more readable and fail safe.
Also I was not aware of the performance penalty in using $&, so thanks
for teaching me something too. I am still learning Perl.
Wiggins d Anconia wrote:
This should give you what you need:
my $digit = 0;
foreach (@commands) {
/^\d+/;
Please bottom post
> This should give you what you need:
>
> my $digit = 0;
> foreach (@commands) {
> /^\d+/;
> print FILE "DIGIT = $&\n";
> }
>
While simple, use of $& takes a performance penalty and a readability
penalty
>From perldoc perlvar:
"The use of this variable a
> Hi ppl,
>
> I have to split a file in pieces and I place every segment in an array.
> Each segment begins with digit(s). What I want to do is to parse the
> array, and for each segement, record its first digits into a scalar so I
> can do further manipulations on it (actually I only print the
This should give you what you need:
my $digit = 0;
foreach (@commands) {
/^\d+/;
print FILE "DIGIT = $&\n";
}
Hemond, Steve wrote:
Hi ppl,
I have to split a file in pieces and I place every segment in an array.
Each segment begins with digit(s). What I want to do is to parse the
a
Hi ppl,
I have to split a file in pieces and I place every segment in an array.
Each segment begins with digit(s). What I want to do is to parse the
array, and for each segement, record its first digits into a scalar so I
can do further manipulations on it (actually I only print the scalar
into a