> From: lz <[EMAIL PROTECTED]>
> Date: Tue, 28 May 2002 07:08:52 -0700 (PDT)
> To: [EMAIL PROTECTED]
> Subject: checking for an empty string
>
> Hi guys,
>
> while($line = )
> {
> if ($line =~ /^email address/)
> {
>}
> }
>
> How can I check if $line contains a value or is empty?
chomp
umm.. there's several ways.
The following assumes you chomped the line already. see perldoc -f chomp
if length($line)
if $line # assuming it won't just have a 0 in it.
if $line !~ /^$/
> -Original Message-
> From: lz [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 28, 2002 10:09 AM
> T
while () {
if (!($_)) {
if(m/^email address/) {
}
}
}
I think you want to be shure that you have input, so you match only if the current
line is not empty.
Regs David
--
>
> Hi guys,
>
> while($line = )
> {
> if ($line =~ /^email address/)
> {
>
Hi, God bless you.
Assuming you are trying to read a line which contains:
email addres: [EMAIL PROTECTED]
Then you can use the postmatch variable ($') to look at the rest of
the line (watch also for the change on the regexp that strips the ':'
and any spaces after it).
On Tue, May 28, 2002 at
Ops, forgot to change blank for \s in regexp:
On Tue, May 28, 2002 at 11:34:09AM -0500, Roberto Ruiz wrote:
> Hi, God bless you.
>
> > while($line = )
> > {
> > if ($line =~ /^email\saddress:\s*/)
^^ also change this.
> > {
See you
Roberto Ruiz
--
A train s