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 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    I forgot ;)
    Posts
    35
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post The "Date" command

    I am using sambar server http://www.sambar.com and i would like to know how to print the servers date in the Perl File. My PL files content is:

    Code:
    #
    # Tim's Perl Guestbook Version 1.00
    
    $bookfile = "../docs/ts/guestbook.htm";
    
    # Get the input
    read(STDIN, $data, $ENV{'CONTENT_LENGTH'});
    
    # Split the name-value pairs
    @pairs = split(/&/, $data);
    
    foreach $pair (@pairs) 
    {
    	($name, $value) = split(/=/, $pair);
    
    	# Convert the HTML encoding
    	$value =~ tr/+/ /;
    	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    	$value =~ s/<!--(.|\n)*-->//g;
    
    	# Convert HTML stuff as necessary.
    	$value =~ s/<([^>]|\n)*>//g;
    
    	$FORM{$name} = $value;
    }
    
    # Verify that the required data has been received.
    &missing_name unless $FORM{'name'};
    &missing_email unless $FORM{'email'};
    &missing_msg unless $FORM{'msg'};
    
    # Read in the book for editing
    # Note:  These actions on the book file should be atomic (flock()).
    open (FILE, "$bookfile") || die "Can't open $bookfile: $!\n";
    @LINES=<FILE>;
    close(FILE);
    $SIZE=@LINES;
    
    # Open book file
    open (FILE, ">$bookfile") || die "Can't open $bookfile: $!\n";
    
    for ($i = 0; $i <= $SIZE; $i++) 
    {
    	$_=$LINES[$i];
    
    	if (/<!--top-->/) 
    	{
    		print FILE "<!--top-->\n";
       
    		print FILE "<b>$FORM{'msg'}</b><br>\n";
    		print FILE "$FORM{'name'}";
    		if ($FORM{'email'})
    		{
    		print FILE "<div style=\"position: absolute; visibility: hidden\">$FORM{'email'}</div>";
    		}
    
    		print FILE "<HR>\n";
    	}
    	else 
    	{
    		print FILE $_;
    	}
    }
    
    close (FILE);
    
    
    # Response message.
    print "<HTML><HEAD><TITLE>Thanks</TITLE></HEAD><BODY bgcolor=white>\n";
    print "<FONT SIZE=5 COLOR=#996633><B>Thanks for your message</B></FONT>\n";
    print "<BR><BR>Your entry has been added to our guest book:<HR>\n";
    print "<b>$FORM{'msg'}</b><br>\n";
    print "$FORM{'name'}";
    print "<P><HR>\n";
    print "<A HREF=\"/ts/guestbook.htm\">Back to GuestBook.</A><br>\n";
    print "<A HREF=\"/ts/index.htm\">Back to Trowel and Sword home page.</A><br>\n";
    print "</BODY></HTML>\n";
    
    exit;
    
    
    sub missing_name
    {
    	print "<HTML><HEAD><TITLE>Missing Name</TITLE></HEAD><BODY>\n";
    	print "<FONT SIZE=5 COLOR=#996633><B>Name field is blank...</B></FONT>\n";
    	print "<BR><BR>Please repost the name section of the guestbook.<P>\n";
    	print "Return to the <a href=\"/ts/guestbook.htm\">Guest Book</a>.\n";
    	print "</BODY></HTML>\n";
    
    	exit;
    }
    
    sub missing_email
    {
    	print "<HTML><HEAD><TITLE>Missing Email</TITLE></HEAD>\n";
    	print "<FONT SIZE=5 COLOR=#996633><B>Email field is blank...</B></FONT>\n";
    	print "<BR><BR>Please repost the email section of the guestbook.<P>\n";
    	print "Return to the <a href=\"/ts/guestbook.htm\">Guest Book</a>.\n";
    	print "</BODY></HTML>\n";
    
    	exit;
    }
    
    sub missing_msg
    {
    	print "<HTML><HEAD><TITLE>Missing Comments</TITLE></HEAD>\n";
    	print "<FONT SIZE=5 COLOR=#996633><B>Comment field is blank...</B></FONT>\n";
    	print "<BR><BR>Please repost the comment section of the guestbook.<P>\n";
    	print "Return to the <a href=\"/ts/guestbook.htm\">Guest Book</a>.\n";
    	print "</BODY></HTML>\n";
    
    	exit;
    }
    So how could i do this??

    Thanks in advance!
    PM Me if you want the new URL for my forum!

  • #2
    New Coder
    Join Date
    Jul 2002
    Location
    H-Town
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Straight from the Perldoc pages:
    PHP Code:
    $now_string localtime;  # e.g., "Thu Oct 13 04:54:34 1994" 
    You should also know that you are using an archaic method of parsing information from the query string. You should really look into using CGI.pm. It does all the work for you basically. Plus, you guaranteed that it's actually going to work with out bugs. There's no need to strip unwanted characters because it does it for you. Plus, it also lets you work with cookies, display HTML headers, print out forms, and much much more. Once you've moved to CGI.pm you'll wonder why you ever coded without it. Seriously...

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Brisbane, Australia
    Posts
    181
    Thanks
    1
    Thanked 0 Times in 0 Posts
    simply place:

    Code:
    print FILE localtime();
    that directly print the time.

  • #4
    New Coder
    Join Date
    Jul 2002
    Location
    H-Town
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Putting the "()" after localtime will print it out in seconds (a really long number). I'm pretty sure that without the "()" puts it ina text format.


  •  

    Posting Permissions

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