Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple question

Status
Not open for further replies.

cnw40007

Technical User
Mar 4, 2003
35
IE
Hi
is there a way of getting the username of an email address and print it out instead of printing the full email address using perl.This is my code but it prints out the full email address
...
while(<HEADER>)
{
if(/To:([^\@]+)/)
{

print OUTPUT;}
}
 
Yuo just want the bit of the email address before the @, right? You're almost there! Try:

[tt]while(<HEADER>)
{
if(/To:([^\@]+)/)
{
print OUTPUT $1;
}
}[/tt]

$1, $2, $3 etc... match the corresponding bracketed area in the most recent regular expression, in this case $1 = ([^\@]+) (or rather, the bit of text that satisfies this condition). -- Chris Hunt
Extra Connections Ltd
 
grand that worked.Do you have any idea on how i would compare this off a spreadsheet. Eg my spreadsheet looks like this
cnw40001
cnw40002
....
cnw40020.
If there is a match with the username of the email then print match!I have installed the spreadsheet modules but im not sure how to use it.Im new to perl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top