D
\Dandy\ Randy
Hey everyone, I could use some help with the following. I have written a
small Perl emailing program for our company. My script uses a file called
addressed.txt. This file contains names and email addresses separted by a
"|" character. A sample is below: Note the @ symbol is in brackets so this
post ignores the @ symbol and doesnt create a linkable email address.
Jogn Doe|john(@)email.com
Jane Doe|jane(@)email.com
The sending script opens this file and assigns its data to a @ array.
open (list, "<addresses.txt") or &error("Unable to open the data file for
reading");
flock list, 2;
@list=<list>;
close(list);
Later this data is sent to the sendmail module for sending to each
recipient. My boss has said that he doesnt want to send the full name, only
the first name ... so here is the question: How can I chop off the last name
from the name data? The first name and last name are separated by a simple
space. This is how I currently separate the names from the email addresses:
foreach $list (@list) {
chomp ($list);
($name,$email)=split(/\|/,$list);
}
I'm needing a set of commands that will take the variable $name ... and
remove any data that appears after the first space it encounters - including
the space itself. The result would be if I printed $name, only John or Jane
would be shown, the last name was removed. Hope I have explained this ok.
Thanx to all who read or respond. Code examples are greatly appriciated.
R
small Perl emailing program for our company. My script uses a file called
addressed.txt. This file contains names and email addresses separted by a
"|" character. A sample is below: Note the @ symbol is in brackets so this
post ignores the @ symbol and doesnt create a linkable email address.
Jogn Doe|john(@)email.com
Jane Doe|jane(@)email.com
The sending script opens this file and assigns its data to a @ array.
open (list, "<addresses.txt") or &error("Unable to open the data file for
reading");
flock list, 2;
@list=<list>;
close(list);
Later this data is sent to the sendmail module for sending to each
recipient. My boss has said that he doesnt want to send the full name, only
the first name ... so here is the question: How can I chop off the last name
from the name data? The first name and last name are separated by a simple
space. This is how I currently separate the names from the email addresses:
foreach $list (@list) {
chomp ($list);
($name,$email)=split(/\|/,$list);
}
I'm needing a set of commands that will take the variable $name ... and
remove any data that appears after the first space it encounters - including
the space itself. The result would be if I printed $name, only John or Jane
would be shown, the last name was removed. Hope I have explained this ok.
Thanx to all who read or respond. Code examples are greatly appriciated.
R