do you mean that you want the 100 in a variable?
If so, here is one way:
while <TXT>{
# Splitting the line by white spaces.
my $Number = (split /\s+/, $_)[0];
# Deleting the dot at the end.
$Number =~ [EMAIL PROTECTED]@@;
print "$Number\n";
}
HTH,
Yargo.
-----Original Message-----
From: Matthew Stapleton [mailto:[EMAIL PROTECTED]
Sent: Saturday, March 22, 2003 3:32 AM
To: [EMAIL PROTECTED]
Subject: extracting numbers from a string
Hello,
I am learning Perl and having some fun with it. In a script I am writing
I am wanting to read a line of a file and then extract a digit from the
beginning of the line. A typical line looks something like this:
100. text text text
So I am using a file handle to open the file and read the lines on by one
with a while loop.
while (<TXT>){}
That part is pretty straight forward. Each line is then given to $_
But how do I get just the digit at the beginning of the line out of $_ ?
I thought about adding zero to $_ and then passing this to another
variable but this does not seem to work.
Can someone help me?
Thanks,
Matthew Stapleton
#############
http://webpages.marshall.edu/~staple12
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]