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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Shifting Arrays



Jun 11, 2000, 8:22 PM

Post #1 of 2 (812 views)
Shifting Arrays Can't Post

Iím trying to take the content from a file named myfile.txt and put it into an array then take the first value in the array and just print it.

The problem is I can only get this to work on my computer. When Iím trying to get it to work on a webpage and print $key from another sub function is just doesnít work. I could really use some help here. I've been working on this for awhile but I just canít figure out why it doesnít work. Smile

Here is what I have:

sub getinfo {
open(OPTIONS, "myfile.txt");
while(<OPTIONS> ) {
@info = split(/:/, $_, 4);
$key = shift(@info);
$infoHash{$info[0]} = join(":", @info);

myfile.txt includes:


And to print:
sub printme {
print "<td><font face=verdana,arial,helvetica size=2>$key</font></td>";


Jun 11, 2000, 9:15 PM

Post #2 of 2 (812 views)
Re: Shifting Arrays [In reply to] Can't Post

Check system calls for errors. The environment that scripts execute in as CGIs is different than when you're running them from the command line, and what works from the later might not work from the former.

open(OPTIONS, "myfile.txt") or die "myfile.txt: $!";

[This message has been edited by dws (edited 06-11-2000).]


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

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