Re: Problem recording the first digits into a scalar

2004-03-09 Thread Flemming Greve Skovengaard
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+/;

Re: Problem recording the first digits into a scalar

2004-03-09 Thread Wiggins d Anconia
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

Re: Problem recording the first digits into a scalar

2004-03-09 Thread Wiggins d Anconia
> 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

Re: Problem recording the first digits into a scalar

2004-03-09 Thread Flemming Greve Skovengaard
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

Problem recording the first digits into a scalar

2004-03-09 Thread Hemond, Steve
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