Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Souteast Coast
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Help (simple Perl script)

    I've created a perl scritp that prints the users email address along with the date into and text file. The problem I'm having is that when I view the text file the date and email address is on two different lines.

    Example:
    date
    E-mail address

    What I want is:
    date , email address
    date , email address

    I want to be able to import this into a database or spreadsheet, Hence the comma.

    Here's the script:

    #!/usr/local/bin/perl

    print "Content-type: text/html\n\n";

    $queryString = $ENV{'QUERY_STRING'};
    @pairs = split (/&/, $queryString);
    foreach $nameValue (@pairs)
    {
    ($name, $value)= split (/=/, $nameValue);
    $email{$name}=$value;
    }

    $date = `date`;

    $emailFile = "newsletter.txt";

    open (FILE, ">> $emailFile") || die ("Cannot Open File");
    print FILE "$date";
    print FILE "$email{'txtEmail'}";
    close (FILE);

    Thanks,
    Hogtied

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I may be wrong here because im no expert but can you not change the last bit of your script to this:

    open (FILE, ">> $emailFile") || die ("Cannot Open File");
    print FILE "$date","$email{'txtEmail'}";
    close (FILE);

    The syntax might not be right but have a go.

    Hope it helps


  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mex
    Posts
    122
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not sure if you already solve it but you can also do this:

    open (FILE, ">> $emailFile") || die ("Cannot Open File");
    print FILE ("$date , $email{'txtEmail'}");
    close (FILE);

    calilo

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Souteast Coast
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts
    print FILE ("$date, $email{'txtEmail'}");

    This coding prints to the file as follows:

    Wed Oct 16 22:03:25 EDT 2002
    , hhh@hhh.com

    ------------------------------------------------------

    print FILE "$date","$email{'txtEmail'}";

    This coding prints to the file as follows:

    Wed Oct 16 22:07:30 EDT 2002
    hhh@hhh.com

    -----------------------------------------------

    This is what i would like it to look like:

    Wed Oct 16 22:07:30 EDT 2002, hhh@hhh.com


    any suggestions????

    Thanks
    hogtied

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Souteast Coast
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks people for you inputs but I've solved it one way. Not the way i want but it'll do.

    print FILE "$email{'txtEmail'} , $date";

    Thanks
    hogtied


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •