I am absolutely new and trying to modify a password reminder script to work on my site.
my database is set up like this:
(in a file called userpass.dat)
UserName|Password|email@address.com&AnotherName|AnotherPass|anothermail@whatever.com&
The $user, $name, $email are seperated by "|" and each
entry is seperated by "&", without a carriage return

the script starts like this, after the shebang

$datafile = "/web/home/data/userpass.dat"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/~!/ ~!/g; $FORM{$name} = $value; } $string = $FORM{'mail'}; open(INF,$datafile); @mydata = <INF>; close(INF); $count = 0; foreach $i (@mydata) { chomp($i); ($user,$pass,$email) = split(/\|/,$i); if (uc($email) eq uc($string)) { open (MAIL, "| $sendmail -t") || die "I can't open sendmail\n"; print MAIL "To: $email\n"; print MAIL "From: $myemail\n"; print MAIL "Subject: The passwords\n"; print MAIL "\n"; print MAIL "Here are the passwords you asked for:\n"; print MAIL "\n"; print MAIL "Field 1: $user\n"; print MAIL "Field 2: $pass\n"; print MAIL "Field 3: $email\n"; print MAIL "\n";
Can anyone tell me where I am going wrong ??
I tried changing the first
($name, $value) = split(/=/, $pair);
to ($name, $value) = split(/&/, $pair);
and that didnt work.
The script runs but gives me the error message that
it cant find the email address in the database.
Any suggestions ?
Thanks,

In reply to Lost acolyte, splitting fields out of flat-file database by caciqueman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.