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
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 file).

What I do right now is :

my $digit = 0;
for (@commands)
{
    $digit =~ /^\d+/;
    print FILE "DIGIT = $digit \n";
}

The resulting file displays :
0
0
0
0
0
0
... etc.

Here are some sample segments :
1NP256ES-0  <-- here it should take 1
61PC61      <-- here it should take 61
1LT         <-- here it should take 1
16PC16      <-- here it should take 16

I am missing something for sure ... but what? Any clues?

Thank you so much in advance,

Best regards,

Steve Hemond
Programmeur Analyste / Analyst Programmer
Smurfit-Stone, Ressources Forestieres
La Tuque, P.Q.
Tel.: (819) 676-8100 X2833
[EMAIL PROTECTED]




-- Flemming Greve Skovengaard And when you kill a man, you're a murderer a.k.a Greven, TuxPower Kill many, and you're a conqueror <[EMAIL PROTECTED]> Kill them all ... Ooh ... Oh you're a god! 4168.08 BogoMIPS - MegaDeth, Countdown to Extinction

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to