if($string =~ /^[0-9]/)
checks to see if the string starts with 0. If it doesn't, it checks if the
string starts with 1. If it doesn't, it checks if the string starts with 2,
and so on until the condition is true. If the condition is never true, then
it will do whatever is in your else {} (or elsif). The ^ character means
"starts with" in a regex.
Scot R.
inSite
-----Original Message-----
From: Bo Mangor [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 20, 2002 1:49 PM
To: [EMAIL PROTECTED]
Subject: SV: number
Hi again
Great thanks to all the quickly answers!
I tried a couple of them and - yes it works - thanks!
But how does it work? "if(string =~/^[0-9]/)"
The part string =~/^[0-9]/ - does it split the string into single
numbers and check if each of them is a part of the list [0-9] ??
I want to be scour that I have understood the Principe correct.
Best regards
Bo
-----Oprindelig meddelelse-----
Fra: Christopher G Tantalo [mailto:[EMAIL PROTECTED]]
Sendt: 20. juni 2002 20:25
Til: Bo Mangor
Emne: Re: number
Bo Mangor wrote:
> Hi there
>
> I'm a new bird to Perl - and I have a little problem.
>
> I have a file input where I split the file into an array and that
works
> fine, but there is some "spam" in the beginning of the file I want to
> get rid of - the problem is that I never know how many lines there is
> with this "spam"!
>
> Therefore I want to make a check that excludes all lines there doesn't
> start with a number in other languages I would make a check like
>
> If (! isNaN(string)) {
> ....
> }
>
> How do I make this check In Perl?
if(string =~/^[0-9]/)
{
# do something
# number at start of string...
}
else
{
# do something else
}
that should work
>
> I haven't been able to find something similar in Perl, but I know that
> it should be possible.
>
> Best regards
> Bo
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
-------------------------------
Just Your Friendly Neighborhood
_SPIDEY_
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.370 / Virus Database: 205 - Release Date: 6/5/2002
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]