0: (The one that doesn't work...see [Stranger and Stranger...])<P>
1: (<I>Begin <TT>/cgi-bin/printnode4.pl</TT>)</I>
2:
3: <CODE>
4: #!/usr/bin/perl
5:
6: #Printnode version 4
7:
8: #Called from basedir/cgi-bin
9: #options: ?node=x
10: #result prints basedir/nodes/x if exists and is arg
11: #or basedir/err404loc if not
12: #or basedir/nodes/$nonodespec if no arg named node
13:
14: #(C) me 1999
15:
16: $nonodespec = "default.html";
17: $err404loc = "404.html";
18:
19: $data_from_get_method = $ENV{'QUERY_STRING'};
20:
21: # break up the answer into field value pairs
22: @GET_FIELD_PAIRS = split(/&/,$data_from_get_method);
23:
24: # determine the exact name and value for each pair
25:
26: foreach $pair (@GET_FIELD_PAIRS)
27: {
28: # split field name from value on =
29: ($field_name, $field_value) = split (/=/, $pair);
30:
31: # translate '+' to ' ' --- convert + back to spaces
32: $field_value =~ tr/+/ /; # translate string in place
33:
34: # decode the &nn values
35: $field_value =~ s/%([a-fA-F0-9][a-f-A-F0-9])/pack("C",hex($1))/eg;
36:
37: # put all of the values into an associative array
38: # for use later
39: $GETFORMDATA{$field_name} = $field_value;
40:
41: }
42:
43: #set nodedisp to $GETFORMDATA("node") and read file into $data
44: #or default if none
45:
46: if (defined $GETFORMDATA{"node"}) {
47: $nodedisp= $GETFORMDATA{"node"};
48: }
49: else {
50: $nodedisp= $nonodespec;
51: }
52: my $baquux= join "", "../nodes/$nodedisp";
53: if ( -e $baquux) {
54: </CODE> In reply to printnode4.pl by nine9
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |