An alternative might be a tied hash, where the key is the email address.
- Roger -
- Original Message -
From: "Chris Zampese" <[EMAIL PROTECTED]>
To: "perl list" <[EMAIL PROTECTED]>
Sent: Wednesday, January 30, 2002 2:10 AM
Subject: simple file question
Hello everyone,
I have a variab
while ( ) {
push(@new_names, $_) unless ($_ eq $myvar);
}
# now you have a list of new names you can append to the file
open(FILEHANDLE, ">>somefile.txt");
print FILEHANDLE join("\n", @new_names);
close FILEHANDLE;
deen
On Wed, 30 Jan 2002, Chris Zampese wrote:
> Hello eve
BTW, I forgot a chomp...
while( ) {
chomp;
...
same as before...
}
- Original Message -
From: "Tanton Gibbs" <[EMAIL PROTECTED]>
To: "Chris Zampese" <[EMAIL PROTECTED]>; "perl list" <[EMAIL PROTECTED]>
Sent: Tuesday, January 29
Chris Zampese wrote:
>
> Hello everyone,
Hello,
>I have a variable $myvar (an email address), and
> I would like to open a simple text file which contains
> email addresses (one on each line) and check to see if
> the address in $myvar is in there, if it is not, then
> append it o the end o
Write your print statement like this
if /$email2/o
{
print FILE2;
}
-Original Message-
From: Chris Zampese [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 29, 2002 9:18 PM
To: perl list
Subject: Re: simple file question
Just found a regex in the docs. I now have this...
while
You can use the following
open INF, "filename.txt" or die "Could not open file: $!\n";
my $myvar = <>; # get email address from stdin
my $found = 0;
while( ) {
if( $myvar eq $_ ) {
$found = 1;
last;
}
}
close(INF);
if( !$found ) {
open OUTF, ">>filename.txt" or die "Could not o
Just found a regex in the docs. I now have this...
while () {
print if /$email2/o;
}
but I am still not sure how to print to the file??
- Original Message -
From: "Chris Zampese" <[EMAIL PROTECTED]>
To: "perl list" <[EMAIL PROTECTED]>
Sent: Wednesday, January 30, 2002 3: