CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Can anyone solve this?

 



skforum
Deleted

Mar 26, 2001, 2:42 PM

Post #1 of 5 (518 views)
Can anyone solve this? Can't Post

I have wrote a small script for counter which is follows:
I am calling following script as follows from HTML page:
<IMG SRC="/cgi-bin/count.cgi">

## Print new count back on count holder
open(COUNTER, "count.txt");
print COUNTER $count;
close(COUNTER);

@digits = split(//, $count); ## Split $count into digits.

print "Content-type: image/gif\n\n";
foreach (@digits)
{
open(JPEG, "../counter/$_\.gif") || die "Error Banner Show $!";
binmode JPEG;
print <JPEG>;
close(JPEG);
}

The above program prints only the first digit of counter ie. let say counter is 5679 , it only displays 5.

why doesn't it prints rest of the digits?
Any help aapreciated.



unknownSym
stranger

Mar 27, 2001, 9:57 AM

Post #2 of 5 (509 views)
Re: Can anyone solve this? [In reply to] Can't Post

Put your print "Content-Type" line in your foreach loop just above the "open" statement. That should do it.

--unknownSym



skforum
Deleted

Mar 27, 2001, 12:18 PM

Post #3 of 5 (504 views)
Re: Can anyone solve this? [In reply to] Can't Post

NO , It did not worked !! I am really frustrated here ..cant' beleive why it only print first digit
Help me out PerlGURU here !!!



skforum
Deleted

Mar 27, 2001, 7:21 PM

Post #4 of 5 (498 views)
Re: Can anyone solve this? [In reply to] Can't Post

Is there anyone who has tried to print graphics this way please help me out here !!



oldtimer
Deleted

Mar 30, 2001, 5:10 PM

Post #5 of 5 (484 views)
Re: Can anyone solve this? [In reply to] Can't Post

#!/usr/local/bin/perl

######################################################################
# BEFORE TRYING TO EDIT THIS SCRIPT, READ THE README FILE
######################################################################
#
# The Dream Catcher's Web Free CGI Scripts
# Simple Counter
#
# Created by Seth Leonard
#
# http://dreamcatchersweb.com/scripts/
#
# (c)2000 Seth Leonard
# All Rights Reserved
#
######################################################################
# ONLY EDIT THIS PART OF THE SCRIPT!!

$number_of_digits = "";
$end = ".gif";

$pathtocounter = "/home/you/public_html/counter.txt";
$pathtoimages = "http://www.something.com/you/counter/";

$graphics = "yes";

# DO NOT EDIT BELOW THIS LINE!!
############################################################################

# Tell Browser

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

# Get Count

open (COUNTER, "$pathtocounter");
$count = <COUNTER>;
chop ($count) if $count =~ /\n$/;
close (COUNTER);

# Increase Count

$count += 1;

open (COUNTER, ">$pathtocounter");
print COUNTER ("$count");
close (COUNTER);

@digits = split(//, $count);

if ($number_of_digits eq "") {
$howmany = @digits;
} else {
$howmany = $number_of_digits;
}

# Give empty digits a value

$spline = '%0' . $howmany . 'd';
$count = sprintf("$spline", $count);

@digitimages = split(//, $count);

# Print Output Counter

foreach $digitimage (@digitimages) {
if ($graphics eq yes) {
$image = "<img src=$pathtoimages" . "$digitimage" . "$end>";
print ("$image");
} else {
$plain = $digitimage;
print ("$plain");
}
}

exit;


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives