Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: $var{$var1} = $var1; ?

by AcidHawk (Vicar)
on Apr 07, 2003 at 08:16 UTC ( [id://248531]=note: print w/replies, xml ) Need Help??


in reply to $var{$var1} = $var1; ?

Just a note.

Line 80 declares $signature again when you have already done this in line 15.

"my" variable $signature masks earlier declaration in same scope at 248529.pl line 80.

Remove the my on line 80.

-----
Of all the things I've lost in my life, its my mind I miss the most.

Replies are listed 'Best First'.
Re: Re: $var{$var1} = $var1; ?
by Anonymous Monk on Apr 07, 2003 at 16:01 UTC
    I removed the second my and a few other small changes but nothing helped. The $signature shows up in the email if it exists and it prints to screen doing a db test print. If you run the script over again the $sig{$signature} doesn't stick and you get an empty string.

    Any other suggestions?

    #!/usr/bin/perl -w use strict; use warnings; use POSIX; use CGI qw/:standard/; require SDBM_File; my %sig; my $sigsave = "sig.dbm"; my %emails; my $list = "list.dbm"; my $adminmail = "admin\@test.com"; my $sendmail = "/usr/lib/sendmail"; my $signature; tie %emails, 'SDBM_File', $list, O_CREAT | O_RDWR, 0644; if ( !tied %emails ) { print "database unsuccessful $!.\n"; } tie %sig, 'SDBM_File', $sigsave, O_CREAT | O_RDWR, 0644; if ( !tied %sig ) { print "database unsuccessful $!.\n"; } print header, start_html('Email Management'); print "DB contents: $sig{$signature}\n"; print start_form(), table( Tr( td("Subject: "), td( textfield( -name => 'subject', -size => 40 ) ) ), Tr( td("Message: "), td( textarea( -name => 'message', -columns => 40, -rows => 5 ) ) ), Tr( td("Signature: "), td( textarea( -name => 'signature', -default => $sig{$signature}, -columns => 40, -rows => 5 ) ) ), Tr( td( checkbox_group( -name => 'todo', -values => [ 'use', 'save' ], -rows => 2, -columns => 2 ), ), td(submit) ), ), end_form(), hr(); # rid ourselves from those nasty params my $message = param('message'); my $subject = param('subject'); $signature = param('signature'); my $todo = param('todo'); if ( param() ) { if ( $message && $subject eq "" ) { print "Your subject or email content was missing.\n"; } else { foreach my $key ( keys %emails ) { print "Things we have: $key <br>\n"; } print "<br>\n"; while ( my ( $key, $value ) = each(%emails) ) { # Email Subs, special commands $message =~ s/\[name\]/$value/; #[name] = user name open( MAIL, "| $sendmail -t" ); print MAIL "To: $key\n"; print MAIL "From: $adminmail\n"; print MAIL "Subject: $subject\n\n"; print MAIL "$message\n"; if ( $todo eq "use" && $signature ne "" ) { print MAIL "$signature\n"; } print MAIL ".\n"; close(MAIL); print "Email was sent to: $key !<br>"; } } if ( $todo eq "save" ) { print "<br>"; print "Saving to database<br>\n"; $sig{$signature} = $signature; print "\$sig{\$signature}: $sig{$signature}"; } } untie %emails; untie %sig;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://248531]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-18 06:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found