perl.beginners.cgi http://www.nntp.perl.org/group/perl.beginners.cgi/ ... Copyright 1998-2008 perl.org Fri, 29 Aug 2008 19:40:12 +0000 ask@perl.org what specialized tools exist to work with a mailing list (1 message) Hi,<br/><br/>A user of usenet uses a special program, for example gnus. It has been<br/>based on the special protocol. Mailing lists which have been<br/>based on the broadcast delivery is simple to use, but the big amount<br/>unstructed letters is difficult to read. The question-answer<br/>relationship doesn&#39;t image. I want to ask how to arise effectiveness a<br/>mailing list has been based on the broadcast delivery.<br/><br/>Daneel Yaitskov<br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/08/msg13238.html Mon, 25 Aug 2008 12:34:04 +0000 sessions (9 messages) How to make CGI sessions to be shared among multi-webservers? Thanks.<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/08/msg13232.html Sat, 23 Aug 2008 04:21:08 +0000 parsing a line (4 messages) Hello all<br/><br/>I have the following small file that i am parsing one line at a time<br/>(each line consists of hex values)<br/><br/>line 1: 0d<br/>line 2: 00000000<br/>line 3: 00002000<br/>line 4: 0064<br/>line 5: 76d457ed462df78c7cfde9f9e33724c6<br/>line 6: bded7a7b9f6d763e<br/>line 7: 0059010081bb300597603b6f90ef4421<br/>line 8: 001608427754e957a0d281bb30059760<br/>line 9: a72f731c3be600000000000000000000<br/><br/><br/>For line 5, for example, i want to break it up into chunks of 8 hex<br/>charaters (ie for example 76d457ed, 462df78c etc).<br/>I tried to use the shift operator (ie &lt;&lt; or &gt;&gt;) but perl gives an<br/>error.<br/><br/>Any help with the above would be appreciated.<br/><br/>Thanks<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/08/msg13228.html Tue, 19 Aug 2008 07:44:53 +0000 section 508 compliance to Perl-generated forms? (2 messages) Hello,<br/> I have a number of Perl CGI scripts that generate html forms that<br/>need to be made &#39;Section 508&#39; compliant. I have combed CPAN and<br/>perldoc but haven&#39;t been able to find any way to do this, e.g. with a<br/>module. Can anyone send me in the proper direction? Thanks very<br/>much.<br/>Mike<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/08/msg13226.html Fri, 15 Aug 2008 17:27:42 +0000 HELPPPPPPPPPPPPPP (1 message) please help me,this is what i put ,tell me what im doin wrong<br/><br/><br/>Restricted Directory or URL: http://www.googlepages.com<br/><br/><br/>Authentication URL: http://www.googlepages.com<br/><br/><br/>Authentication method: POST<br/><br/><br/>Parameters: Attribute Value<br/>i put .. full name google454543html<br/><br/><br/> password google454543html<br/>---------------------------------------------------------------------------&shy;----<br/>could it be how my webpage name is ???<br/>www.mywebsitename.googlepages.com<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/07/msg13225.html Sun, 27 Jul 2008 11:30:38 +0000 Perl CGI script running as root is unable to do rm, chmod and su (3 messages) Hi!<br/><br/>I&#39;m trying make one script (script1) call another script (script2) and have the <br/>output from script2 returned.<br/>My initial problem was that script2 needs to be executed as root, so I&#39;ve set <br/>the setuid and setgid bit on script1 (script2 unchanged):<br/><br/>-rwsrwsrwx 1 root bin 207 Jul 16 14:19 script1<br/>-rwxrwxr-x 1 root 1060 5648 Jul 16 14:20 script2<br/><br/>However, when script2 is executed rm, su and chmod fails and <br/>/var/apache/logs/error_log shows:<br/><br/>rm: /tmp/script2.sql not removed: Permission denied<br/>chmod: WARNING: can&#39;t change /tmp/status.pl.sql<br/>su: Sorry<br/><br/><br/>I suspect that Perl runs in taint mode and I&#39;ve readup on it but I&#39;m still <br/>unable to get this to work.<br/><br/>Any help would be highly appreciated.<br/><br/>Best Regards,<br/>Jimisola<br/><br/><br/><br/>The files below slightly obfuscated for privacy reason (changed name of files <br/>and some variables).<br/><br/>script1:<br/><br/>#!/usr/bin/perl<br/>##<br/>print &quot;Content-type: text/plain\n\n&quot;;<br/>$ENV{PATH} = &quot;/bin:/usr/bin&quot;;<br/>print &quot;USER: &quot;, `whoami`;<br/>print `script2`;<br/><br/><br/><br/>script2:<br/><br/>#!/bin/perl<br/>$ENV{PATH} = &quot;/bin:/usr/bin&quot;;<br/>print &quot;USER in script2: &quot;, `whoami`;<br/><br/>$|=1;<br/>$sql_file=&quot;/tmp/script2.sql&quot;;<br/>$FLAG=0;<br/>$i=0;<br/>if (@ARGV !=0) {<br/> for ($j=0;$j&lt;=$#ARGV;$j++) {<br/> &amp;check_arg($ARGV[$j]);<br/> &amp;usage if ((@cont &gt; 1) || ($FLAG &gt; 1));<br/> }<br/>}<br/>$user=&quot;user&quot;;<br/>$passwd=&quot;password&quot;;<br/><br/>$msg_query=join(&quot; or &quot;,@msg_query);<br/>$recip_query=join(&quot; or &quot;,@recip_query);<br/>$state=join(&quot;,&quot;,@state);<br/><br/>system &quot;/bin/rm $sql_file &gt; /dev/null&quot;;<br/><br/>open (SQL,&quot;&gt;$sql_file&quot;) || die &quot;Could not open $sql_file\n&quot;;<br/>print SQL &quot;set linesize 200;\n&quot;;<br/>print SQL &quot;set pagesize 0;\n&quot;;<br/>print SQL &quot;colum recip_addr format a30;\n&quot;;<br/>print SQL &quot;colum status format a12;\n&quot;;<br/>print SQL &quot;colum msg_date format 99999999999999999999999999999999;\n&quot;;<br/>print SQL &quot;colum notif_time format 99999999999999999999999999999999;\n&quot;;<br/>print SQL &quot;select r.recip_addr , r.message_id, r.recipient_id, r.code, <br/>m.msg_date, r.notif_time, r.state, r.status \n&quot;;<br/>print SQL &quot;from recipient_tbl r, message_tbl m\n&quot;;<br/>print SQL &quot;where r.message_id=m.message_id\n&quot;;<br/>print SQL &quot;and state in ($state)\n&quot; if ($state ne &quot;&quot;);<br/>if ($msg_query ne &quot;&quot;) {<br/> print SQL &quot;and ($msg_query)\n&quot;<br/>}<br/>if ($recip_query ne &quot;&quot;) {<br/> print SQL &quot;and ($recip_query)\n&quot;<br/>}<br/><br/>print SQL &quot;order by r.message_id;\n&quot;;<br/>print SQL &quot;;\n&quot;;<br/>print SQL &quot;exit;\n&quot;;<br/>close(SQL);<br/>system &quot;chmod 755 $sql_file &gt; /dev/null&quot;;<br/><br/><br/><br/>if (@cont == 0) {<br/> &amp;query;<br/>}<br/>else {<br/> while (1) {<br/> &amp;query;<br/> sleep $cont[0];<br/> }<br/>}<br/><br/><br/>sub query {<br/> open (OUTPUT, &quot;su - oracle -cf &#39;source .profile; sqlplus $user/$passwd <br/>\@$sql_file&#39;|&quot;) || die &quot;Can open SQL\n&quot;;<br/>print &quot;Recipient Address (Recip_addr) Message_ID Recipient_ID Code Msg_Date <br/> NT State Status\n&quot;;<br/>print &quot;------------------------------ ---------- ------------ ------ <br/>------------------- -- ----- ----------\n&quot;;<br/>$count=0;<br/>while (&lt;OUTPUT&gt;) {<br/>chop;<br/>@col= split (/\s+/,$_);<br/>next if (!((@col == 7) || (@col == 8)));<br/>next if (($col[1] =~ /\D/) || ($col[2] =~ /\D/) || ($col[5] =~ /\D/) || ($_ eq &quot;&quot;));<br/>if ($col[4] == $col[5] ) {<br/> $NT=&quot;S&quot;;<br/>} else {<br/> $NT=&quot;D&quot;;<br/>}<br/><br/>$m_date=$col[4]/1000;<br/>$unix_time=time();<br/>($sec,$min,$hr,$day,$mon,$yr,$wday,$yday,$isdst)=localtime($m_date);<br/>$year=$yr+1900;<br/>$month=$mon+1;<br/>printf (&quot;%-30s %-10d %-12s %-6d %04d/%02d/%02d-%02d:%02d:%02d %-2s %5d <br/>%-10s\n&quot;,$col[0],$col[1],$col[2],$col[3], $year,$month,$day, <br/>$hr,$min,$sec,$NT,$col[6],$col[7]);<br/>$count++;<br/>}<br/>print &quot;\nNo. of matching rows : $count\n&quot;;<br/>$q_date=`date &#39;+20%y/%m/%d-%H:%M:%S&#39;`;<br/>print &quot;Query Date : $q_date&quot;;<br/>print <br/>&quot;=====================================================================================================\n\n&quot;;<br/>}<br/><br/><br/><br/>sub check_arg {<br/> local ($arg)=@_;<br/> local (@arg,@val);<br/> &amp;usage if ($arg !~ /\=/ );<br/> @arg=split (/=/,$arg);<br/> &amp;usage if (($arg[1] eq &quot;&quot;) || !(($arg[0] eq &quot;state&quot;) || ($arg[0] eq <br/>&quot;msg&quot;) || ($arg[0] eq &quot;cont&quot;) || ($arg[0] eq &quot;recip&quot;)));<br/> @val=split(/,/,$arg[1]);<br/> if ($arg[0] eq &quot;msg&quot;) {<br/> foreach $x (@val) {<br/> push (@msg_query, &quot;r.message_id like &#39;%$x%&#39;&quot;);<br/> }<br/> $msg_query=join(&quot; or &quot;,@msg_query);<br/> $FLAG++;<br/> }<br/> if ($arg[0] eq &quot;recip&quot;) {<br/> foreach $x (@val) {<br/> push (@recip_query, &quot;recip_addr like &#39;%$x%&#39;&quot;);<br/> }<br/> $recip_query=join(&quot; or &quot;,@recip_query);<br/> $FLAG++;<br/> }<br/> if ($arg[0] eq &quot;state&quot;) {<br/> foreach $x (@val) {<br/> push (@state, &quot;$x&quot;);<br/> }<br/> $FLAG++;<br/> }<br/> if ($arg[0] eq &quot;cont&quot;) {<br/> foreach $x (@val) {<br/> push (@cont, &quot;$x&quot;);<br/> }<br/> }<br/> &amp;usage if ((@cont &gt; 1) || ((@msg_query &gt;= 1) &amp;&amp; (@recip_query &gt;=1)));<br/> &amp;usage if ((@cont == 1) &amp;&amp; ($cont[0] &lt;= 0));<br/>}<br/><br/><br/>sub usage {<br/>...<br/>}<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/07/msg13221.html Wed, 16 Jul 2008 12:50:15 +0000 Determine upload file type (4 messages) I need to write a cgi program to enable our users to upload files using the<br/>web browser, but I am not sure how to figure out the type of file the user<br/>wants to upload (e.g text or binary file). Can CGI.pm accomplish this<br/>automatically?<br/><br/>Any suggestions welcome.<br/><br/>Mimi<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/06/msg13217.html Fri, 20 Jun 2008 03:43:53 +0000 Standard CGI module vs CGI::Fast/CGI::Simple (2 messages) Hi,<br/><br/><br/>I will be developing a database backed CGI application and now looking into<br/>CPAN modules to use. Now my idea is to find people who have experience using<br/>the modules I am considering to hear their opinion. For instance, I normally<br/>write a subroutine which prints the overall layout of all my pages, so each<br/>time I need to sent a page to the user I call the subroutine to pass some<br/>values to print the page (see example):<br/><br/>sub print_layout {<br/>$x = @_;<br/>print # print html header here<br/>print &quot;$x\n&quot;;<br/><br/>print # print html footer here<br/>}<br/><br/>Now I read of CGI::Fast, CGI::Simple and Mason. Question, are these modules<br/>easy to understand and use? Sometimes it take too long to get a module<br/>installed and ready to use, and then comes the documentation etc. Can<br/>someone who has experience with Fast CGI, CGI::Simple or Mason comment on<br/>these? I had a quick look at CGI::Simple docs and it looks almost like the<br/>standard CGI module by Lincoln Stein, so why should this be use?<br/>CGI::Session also looks like Apache::Session.<br/><br/>My application attract lot of traffic and should grow very fast, so I am<br/>looking to plan properly now in order to increase maintainability in the<br/>future.<br/><br/>The web site will generate thumbnails on the fly and speed is crucial due to<br/>high traffic. Any suggestion from experienced CGI developers will<br/>be appreciated.<br/><br/>Mimi<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/06/msg13215.html Tue, 17 Jun 2008 06:37:14 +0000 Module for fast CGI application (Templating) (1 message) Hi,<br/><br/><br/>I will be developing a database backed CGI application and now looking into<br/>CPAN modules to use. Now my idea is to find people who have experience using<br/>the modules I am considering to hear their opinion. For instance, I normally<br/>write a subroutine which prints the overall layout of all my pages, so each<br/>time I need to sent a page to the user I call the subroutine to pass some<br/>values to print the page (see example):<br/><br/>sub print_layout {<br/>$x = @_;<br/>print # print html header here<br/>print &quot;$x\n&quot;;<br/><br/>print # print html footer here<br/>}<br/><br/>Now I read of CGI::Fast, CGI::Simple and Mason. Question, are these modules<br/>easy to understand and use? Sometimes it take too long to get a module<br/>installed and ready to use, and then comes the documentation etc. Can<br/>someone who has experience with Fast CGI, CGI::Simple or Mason comment on<br/>these? I had a quick look at CGI::Simple docs and it looks almost like the<br/>standard CGI module by Lincoln Stein, so why should this be use?<br/>CGI::Session also looks like Apache::Session.<br/><br/>My application attract lot of traffic and should grow very fast, so I am<br/>looking to plan properly now in order to increase maintainability in the<br/>future.<br/><br/>The web site will generate thumbnails on the fly and speed is crucial due to<br/>high traffic. Any suggestion from experienced CGI developers will<br/>be appreciated.<br/><br/>Mimi<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/06/msg13214.html Tue, 17 Jun 2008 03:50:59 +0000 mod_perl compilation?!?!? (1 message) regards everybody<br/>got my perl-5.10.0 compiled with prefix /test as well as apache<br/>now, I&#39;d think, simple mod_perl compilation, right?<br/>/test/bin/perl Makefile.pl MP_APXS=/test/sbin/apxs<br/>well, huh, works fine, no errors<br/>module lands into apache&#39;s module folders, gets dynamically loaded into <br/>apache, fine<br/>but!! when I go to myhost/perl-status I get perl-5.8.8 which is my <br/>distro&#39;s version<br/>how come? had to guess - my mistake during perl compilation?<br/>if yes - how to compile mod_perl without recompiling whole perl?<br/>is there a tool that gives info/looks into module itself?<br/>any help/suggestions greatly appreciated<br/>cheers<br/><br/><br/> <br/>____________________________________________________________________________________<br/>Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now.<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/06/msg13213.html Wed, 11 Jun 2008 09:06:02 +0000 Simple Question... I hope (5 messages) Ok, I&#39;m uploading a file to a 3rd party. The file is being uploaded to<br/>an https site with a cgi extension. The 3rd party finally provided me<br/>with a snippet of their Perl code. They see the attempt coming<br/>through, but there is no data. I understand how all this works... i<br/>think there&#39;s just a dot i&#39;m not connecting somewhere. PLEASE HELP...<br/>Thanks in advance!!!<br/><br/>In my html file I have...<br/>&lt;font size=&quot;4&quot; color=&quot;#000066&quot;&gt;File: &lt;/font&gt;&lt;INPUT TYPE=&quot;file&quot;<br/>NAME=&quot;XML_DATA&quot; size=&quot;47&quot;&gt;&lt;/p&gt;<br/>&lt;INPUT TYPE=&quot;submit&quot; NAME=&quot;submitButtonName&quot; VALUE=&quot;Submit Query&quot;&gt;&lt;/p&gt;<br/><br/>See below:<br/>Here is the Perl snippet of what they&#39;re doing...<br/><br/> my $query = new CGI;<br/> my (@data) = $query-&gt;param;<br/> my (%data,$key);<br/> foreach $key (@data)<br/> {<br/> $data{$key} = $query-&gt;param($key);<br/> &amp;logXmlOrder (&quot;key($key) data($data{$key})&quot;);<br/> }<br/> read(STDIN,$xmlcontent,$ENV{&#39;CONTENT_LENGTH&#39;});<br/> &amp;logXmlOrder (&quot;Content=$xmlcontent&quot;);<br/><br/>Here is what they&#39;re telling me is logged on their side:<br/><br/>key(submitButtonName) data(Submit Query)<br/>Content=<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/06/msg13208.html Wed, 04 Jun 2008 01:40:53 +0000 Could not open testfile.txt: No such file or directory (3 messages) Still cannot see why Perl complains that Could not open file for reading.<br/>File or directory does exist.<br/>I have modified my script and now using Getopt::Long module instead of the<br/>@ARGV variable. Can someone take a look?<br/><br/>The script is now run with command line options like this:<br/>myscript --master --compare file_name --compare another_file<br/><br/>Here is a section of the script<br/><br/>use strict;<br/>use warnings;<br/>#use diagnostics;<br/>use Getopt::Long;<br/><br/>use constant DEFAULT_REPORTDIR =&gt; &quot;.\\compare_report&quot;;<br/><br/>my $master_list = &quot;&quot;;<br/>my @compare_lists = &quot;&quot;;<br/>my $help = &quot;&quot;;<br/><br/>Getopt::Long::Configure (&quot;ignorecase&quot;);<br/><br/>GetOptions(<br/> &quot;master=s&quot; =&gt; \$master_list,<br/> &quot;compare:s&quot; =&gt; \@compare_lists,<br/> &quot;help|?!&quot; =&gt; \$help,<br/>);<br/><br/>usage() if $help;<br/>@compare_lists = split(&#39; &#39;,join(&#39; &#39;,@compare_lists));<br/>foreach (@compare_lists){<br/> die &quot;File $_ does not exist or it&#39;s empty. Please check the file try<br/>again.\n&quot; unless -s $_;<br/>}<br/><br/>################################<br/>#foreach (@compare_lists){print &quot;$_\n&quot;;} # This prints the CLI arguments<br/>correctly.<br/>#################################<br/><br/>my $outputdir = DEFAULT_REPORTDIR;<br/>unless (-d $outputdir){<br/> mkdir ($outputdir) or die &quot;could not create dir for $outputdir: $!\n&quot;;<br/>}<br/><br/># Read the master list and populate our array.<br/>open (MASTERFILE, &quot;&lt;&quot;, $master_list) or die &quot;Could not open $master_list for<br/>reading: $!\n&quot;;<br/>my @master_clients = &lt;MASTERFILE&gt;;<br/>close MASTERFILE;<br/>##############################<br/>#print &quot;master list starts below:\n&quot;;<br/>#foreach (@master_clients){print &quot;$_\n&quot;;}exit;<br/>######################################<br/>my (%inputclient,$list);<br/><br/># Read the other files and compare the content to the master client list.<br/>foreach $list (@compare_lists){<br/> # Output file name set of element curerently processed.<br/> # Open file to read from.<br/> open(INPUTFH, &quot;&lt;&quot;, $list) or die &quot;Could not open $list for reading:<br/>$!\n&quot;; # Could<br/>not open file for reading. File or directory does exist.<br/> while (&lt;INPUTFH&gt;){<br/> chomp;<br/> $inputclient{&quot;s_&quot;} = $_;<br/> }<br/> close INPUTFH;<br/><br/> #$outputfile = &quot;NOT_IN&quot; . &quot;$outputfile&quot;;<br/> my $outputfile = $list;<br/> my (@missing_clients, %outputclient);<br/><br/> open (OUTPUTFILE, &quot;&gt;&quot;, $outputfile) || die &quot;Could not open $outputfile:<br/>$!\n&quot;;<br/> foreach my $aditem (@master_clients){<br/> push (@missing_clients, $aditem) unless exists $inputclient{&quot;$aditem&quot;};<br/> }<br/><br/><br/><br/> On 29/05/2008, Mimi Cafe &lt;mimicafe@googlemail.com&gt; wrote:<br/>&gt;<br/>&gt;<br/>&gt; I am on Windows so it should not be case-sensitive. The script and all<br/>&gt;&gt; required files in one folder. I pass 3 arguments to the script (script.pl<br/>&gt;&gt; file1 file2 file3)and I can open the first file stored in $ARGV[0] as seen<br/>&gt;&gt; below:<br/>&gt;&gt;<br/>&gt;&gt; my $ad_clients = shift @ARGV;<br/>&gt;&gt;<br/>&gt;&gt; open (ADFILE, &quot;&lt;&quot;, $ad_clients) or die &quot;Could not open $ad_clients for<br/>&gt;&gt; reading: $! \n&quot;; # This works fine!<br/>&gt;&gt; my @ad_clients = &lt;ADFILE&gt;;<br/>&gt;&gt; close ADFILE;<br/>&gt;&gt;<br/>&gt;&gt; my %inputclient;<br/>&gt;&gt;<br/>&gt;&gt; foreach my $supplied (@ARGV){<br/>&gt;&gt; open (INPUTFILE, &quot;&lt;&quot;, $supplied) or die &quot;Could not open $supplied for<br/>&gt;&gt; reading: $!\n # This does not works! Error: No such file or directory<br/>&gt;&gt;<br/>&gt; Mimi<br/>&gt;<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt; On 29/05/2008, Ken Foskey &lt;foskey@tpg.com.au&gt; wrote:<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; On Thu, 2008-05-29 at 11:45 +0100, Mimi Cafe wrote:<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; my script is in the same directory as my files, but it cannot find the file<br/>&gt;&gt;&gt; ABC.txt in open() below.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; foreach my $supplied (@ARGV){<br/>&gt;&gt;&gt; # Output file name set of element currently processed.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; # Open file to read from.<br/>&gt;&gt;&gt; open (INPUTFILE, &quot;&lt;&quot;, &quot;$supplied&quot;) or die &quot;Could not open $supplied: $!\n&quot;;<br/>&gt;&gt;&gt; # Error: No such file or directory.<br/>&gt;&gt;&gt; }<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Any help<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Mimi<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; for starters you might want to look at the &lt;&gt; operator:<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; while( &lt;&gt; ) {<br/>&gt;&gt;&gt; }<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Will read each file on the command line in sequence, saves you thinking<br/>&gt;&gt;&gt; about it.<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; If it is Unix it is case sensitive, is this your problem?<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Are you actually in the directory? `bin/myscript.pl bin/ABC.txt`<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt;<br/>&gt;&gt;<br/>&gt;&gt;<br/>&gt;<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/05/msg13205.html Fri, 30 May 2008 05:04:59 +0000 Using a CMS with cgi scripts (2 messages) Hello I have begun to use a CMS/web development tool named Joomla and I was<br/>wondering if you had any<br/>information on implementing perl/cgi scripts into this CMS or if there is<br/>another CMS that would be better to use if i needed to use cgi and<br/>perl.<br/><br/><br/><br/>Any help would be appreciated,<br/>Justin<br/><br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/05/msg13203.html Thu, 29 May 2008 08:40:19 +0000 Include PHP file inside the cgi script (3 messages) Hi all,<br/><br/><br/>Is it possible to include php file inside the cgi script??<br/><br/>I need defined php variable (from php files) inside the cgi script.. <br/><br/>how can i achieve that??<br/><br/><br/>Thanks,<br/>Siva<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/05/msg13200.html Sun, 25 May 2008 21:18:08 +0000 a bit of apache + fcgid (1 message) egards everybody<br/>just subscribed, and as always for simple reason - a problem<br/>as in subject, php is just fine but perl script, apache does not <br/>implement suexec, apache uses fcgid_module (static)<br/>whereas below lines are fine from within shell, apache+fcgid do not want to work<br/><br/>#! /usr/bin/perl<br/>use FCGI;<br/>my $request = FCGI::Request();<br/>while($request-&gt;Accept() &gt;= 0)<br/> {<br/> print &quot;Content-type: text/html\n\n&quot;;<br/> print &quot;&lt;H1&gt;&lt;b&gt;Hello World!&lt;/b&gt;&lt;/H1&gt;&quot;;<br/> }<br/>exit 0;<br/><br/>causes following line to appear in logs:<br/>[Fri Apr 25 10:28:43 2008] [info] mod_fcgid: <br/>/opt/var/www/forum/check-perl.pl spawn score 13 &gt;= 10, skip the spawn <br/>request<br/>[Fri Apr 25 10:28:44 2008] [info] mod_fcgid: <br/>/opt/var/www/forum/check-perl.pl spawn score 12 &gt;= 10, skip the spawn <br/>request<br/>[Fri Apr 25 10:28:47 2008] [notice] mod_fcgid: process <br/>/opt/var/www/forum/check-perl.pl(10203) exit(server exited), terminated <br/>by calling exit(), return code: 255<br/>and..<br/>[Fri Apr 25 10:28:41 2008] [debug] arch/unix/fcgid_proc_unix.c(525): <br/>(111)Connection refused: mod_fcgid: can&#39;t connect unix domain socket: <br/>/opt/etc/httpd/run/mod_fcgid/10007.17<br/>[Fri Apr 25 10:28:42 2008] [debug] arch/unix/fcgid_proc_unix.c(525): <br/>(111)Connection refused: mod_fcgid: can&#39;t connect unix domain socket: <br/>/opt/etc/httpd/run/mod_fcgid/10007.18<br/>[Fri Apr 25 10:28:44 2008] [warn] mod_fcgid: can&#39;t apply process slot <br/>for /opt/var/www/forum/check-perl.pl<br/><br/>I even changed parent folder&#39;s (where socket files are kept) permissions <br/>to a+rw, it was o+rwx,a-rwx, did not help<br/>please advise<br/>cheers<br/><br/><br/> <br/>___________________________________________________________ <br/>Try the all-new Yahoo! Mail. &quot;The New Version is radically easier to use&quot; &#150; The Wall Street Journal <br/>http://uk.docs.yahoo.com/nowyoucan.html<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/04/msg13199.html Mon, 28 Apr 2008 03:39:36 +0000 Variable empty in try block (2 messages) Hi,<br/><br/>Im unsure if this is 100% the correct list, but I am using Perl to form<br/>dynamic web pages (CGI afaik?) so I&#39;ll give it a shot.<br/><br/>I have a script which implements a try-catch block. Before entering the<br/>try portion of this block, I am defining a variable and placing some<br/>content into it, which is a hash table.<br/><br/>The problem seems to be that when I go to access this variable inside the<br/>try block, and subsequently any catch blocks, or the otherwise block, the<br/>variable seems to be empty.<br/><br/>Here is a snip of the code I am using:<br/><br/> my $session = new App($query, $thisModule);<br/><br/> try {<br/> $session-&gt;{AccessControl}-&gt;checkAccess();<br/> &amp;$method($session);<br/> } catch App::AccessControlException with {<br/> my $e = shift;<br/> print &quot;Content-type: text/plain\n\n&quot;;<br/> print &quot;An access control exception has occurred.\n\n&quot;;<br/> print Dumper($e);<br/> } otherwise {<br/> my $e = shift;<br/> print &quot;Content-type: text/plain\n\n&quot;;<br/> print &quot;An error has occurred.&quot;;<br/> print Dumper($e);<br/> }<br/><br/>The first line creates a new instance of an object which contains some<br/>runtime variables and other content based on the request being performed.<br/><br/>If I chuck the following line in immediately after the first line:<br/><br/>warn(Dumper($session));<br/><br/>I see the following in my webserver log file:<br/><br/>$VAR1 = bless( {<br/> &#39;thisModule&#39; =&gt; &#39;module&#39;,<br/> &#39;Request&#39; =&gt; {<br/> &#39;params&#39; =&gt; [<br/> &#39;b&#39;,<br/> &#39;c&#39;<br/> ],<br/> &#39;what&#39; =&gt; &#39;a&#39;<br/> },<br/> &#39;cgiQuery&#39; =&gt; bless( {<br/> &#39;.parameters&#39; =&gt; [],<br/> &#39;use_tempfile&#39; =&gt; 1,<br/> &#39;.charset&#39; =&gt; &#39;ISO-8859-1&#39;,<br/> &#39;.fieldnames&#39; =&gt; {},<br/> &#39;escape&#39; =&gt; 1<br/> }, &#39;CGI&#39; )<br/> }, &#39;App&#39; );<br/><br/>This is fine, its what I want to see.<br/><br/>But if I place this Dumper line inside the try block, I only see the<br/>following:<br/><br/>$VAR1 = bless( {}, &#39;App&#39; );<br/><br/>So it appears that the variable has no content inside the try block.<br/><br/>I dont see any complaints about the variable being undefined, so it<br/>obviously exists, just not its content.<br/><br/>Can anyone think of a reason, or does anyone know the reason, why this<br/>would be occurring?<br/><br/>Let me know if any further details are needed, or if you know of a better<br/>list to post this question.<br/><br/>Thanks,<br/>Tom<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/04/msg13197.html Sun, 27 Apr 2008 07:35:13 +0000 Opening a File in its Native Application (6 messages) Hi,<br/><br/>I would like to open a file in it&#39;s native application. It doesn&#39;t have a specified extension, however, so I would need to specify the application somehow. I saw <br/><br/>system(&quot;start docname&quot;)<br/><br/>but this doesn&#39;t specify the application. <br/><br/>Thank you,<br/>Lynn<br/><br/><br/> ____________________________________________________________________________________<br/>Be a better friend, newshound, and <br/>know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ<br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/04/msg13191.html Wed, 23 Apr 2008 17:34:36 +0000 Insecure dependency in eval message (2 messages) Hi,<br/><br/>I am a Perl CGI beginner. I am trying to construct perl statements to<br/>do depending on user input, and interpret them at runtime using eval.<br/>I execute these commands by writing<br/><br/>eval $commandString;<br/><br/>where $commandString is constructed as per user input.<br/><br/>if $commandString=&quot;simpleSubroutine();&quot; my eval works well, but if<br/>$commandString=&quot;notSoSimpleSubroutine(\&quot;$string1\&quot;, \&quot;$string2\&quot;);&quot; my<br/>eval bombs with the following message:<br/><br/>Insecure dependency in eval while running with -T switch at /var/www/<br/>CGI/process.cgi line 92. Line 92 points to the line<br/>eval $commandString;<br/><br/>Any pointers on what is going on? I have read about unsafe characters,<br/>and tried the following:<br/><br/>$safeCommand=uri_escape($commandString);<br/>eval $commandString;<br/>(that does not work).<br/><br/>I have also tried substituting $string1 and $string2 with literals.<br/>I.e., I tried<br/>$commandString=&quot;notSoSimpleSubroutine(\&quot;delta\&quot;, \&quot;gamma\&quot;);&quot;<br/>and that works just fine. So I gathered that the eval could be bombing<br/>because, perhaps variables ($string1 and $string2) above are not safe?<br/>However, I need the flexibility of using $string1 and $string2.<br/><br/>Any workaround? Any help is greatly appreciated.<br/><br/>Thanks.<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/04/msg13189.html Sun, 13 Apr 2008 17:53:52 +0000 Sendmail (3 messages) my $email = populateEmail(&quot;test&quot;);<br/>print $email;<br/><br/>open(SENDMAIL, &quot;|/usr/lib/sendmail -oi -t -i&quot;) or print &quot;cannot open<br/>SENDMAIL: $!&quot;;<br/>print SENDMAIL &lt;&lt;&quot;EOF&quot;;<br/>From: &lt;deepan\@juniper.net&gt;<br/>To:${email}<br/>Subject: [SUSTAINING TICKET] Case<br/>Content-type: text/html<br/> testing..<br/>EOF<br/> close(SENDMAIL);<br/><br/><br/>When i a using the above code it results in &quot;No recipient address<br/>found in header&quot; and when i replace ${email} with &quot;dpr.17\@gmail.com&quot;<br/>ie<br/><br/>To : dpr.17\@gmail.com it works fine.<br/><br/>populateEmail function&#39;s code is available below:<br/><br/>populateEmail {<br/> if(lc($_[0]) eq &quot;test&quot;) {<br/> return (&quot;deepan.ignatius\@gmail.com&quot;);<br/> }<br/>}<br/><br/>Can anyone spot the bug?<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/04/msg13185.html Thu, 10 Apr 2008 02:53:49 +0000 how to refresh between different pages of the same script (5 messages) I have to modify a script to upload different data to a server,<br/><br/><br/>until now i did and script that ask you a question and capture the variable<br/>into a hash (see below), now, i would like to modify it and make something<br/>that allows me to ask different questions using the same script<br/><br/>how can i do this?<br/><br/>Thanks<br/><br/>#! /usr/bin/perl<br/>#use strict;<br/>use CGI::Ajax;<br/>use CGI;<br/><br/>my $q = new CGI;<br/><br/>my $concatter = sub {<br/><br/> my $buffer = $ENV{&#39;QUERY_STRING&#39;};<br/><br/> my @pairs = split( /&amp;/, $buffer );<br/><br/> foreach my $pair (@pairs) {<br/><br/> my ( $name, $value ) = split( /=/, $pair );<br/><br/> $name =~ tr/+/ /;<br/><br/> $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;<br/><br/> $value =~ tr/+/ /;<br/><br/> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack(&quot;C&quot;, hex($1))/eg;<br/><br/> $Variables{$name} = $value;<br/> }<br/><br/><br/> print &quot;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&quot;;<br/> foreach (%Variables) {print &quot;$_\n&quot;}<br/><br/> print &quot;&lt;/head&gt;&lt;/html&gt;&quot;;<br/><br/><br/> return ;<br/>};<br/><br/><br/>my $Show_Form = sub {<br/><br/> my $html = &quot;&quot;;<br/><br/>$html = &lt;&lt;EOT<br/>&lt;HTML&gt;<br/>&lt;HEAD&gt;&lt;title&gt;CGI::Ajax Multiple Return Value Example&lt;/title&gt;<br/>&lt;/HEAD&gt;<br/>&lt;BODY&gt;<br/>&lt;input type=&quot;hidden&quot; id=&quot;item&quot; size=&quot;6&quot;&gt;<br/>&lt;input type=&quot;hidden&quot; id=&quot;namedItem&quot; size=&quot;6&quot;&gt;<br/>&lt;form&gt;<br/>&lt;input type=&quot;text&quot; id=&quot;val1&quot; size=&quot;6&quot;&gt;&lt;br/&gt;<br/>&lt;br/&gt;<br/><br/>&lt;button onclick=&#39;jsFunc(formDump());return false&#39; &gt; Submit &lt;/button&gt;<br/>&lt;/form&gt;<br/>&lt;/BODY&gt;<br/>&lt;/HTML&gt;<br/>EOT<br/>;<br/><br/>return $html;<br/>};<br/><br/>my $Show_Form2 = sub {<br/><br/> my $html = &quot;&quot;;<br/><br/>$html = &lt;&lt;EOT<br/>&lt;HTML&gt;<br/>&lt;HEAD&gt;&lt;title&gt;CGI::Ajax Multiple Return Value Example&lt;/title&gt;<br/>&lt;/HEAD&gt;<br/>&lt;BODY&gt;<br/>&lt;h1&gt;form2&lt;/h1&gt;<br/>&lt;/BODY&gt;<br/>&lt;/HTML&gt;<br/>EOT<br/>;<br/><br/>return $html;<br/>};<br/><br/><br/>my $pjx = CGI::Ajax-&gt;new( &#39;jsFunc&#39; =&gt; $concatter);<br/><br/>$pjx-&gt;JSDEBUG(1);<br/><br/>$pjx-&gt;DEBUG(1);<br/>print $pjx-&gt;build_html($q,$Show_Form); # this outputs the html for the page<br/><br/><br/><br/>-- <br/>Pau Marc Mu&ntilde;oz Torres<br/><br/>Laboratori de Biologia Computacional<br/>Institut de Biotecnologia i Biomedicina Vicent<br/>Villar<br/>Universitat Autonoma de Barcelona<br/>E-08193 Bellaterra (Barcelona)<br/><br/>tel&egrave;fon: 93 5812807<br/>Email : paumarc.munoz@bioinf.uab.cat<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/04/msg13181.html Tue, 08 Apr 2008 07:59:41 +0000 Extracting TD's from a Text File (Regex Help). (4 messages) ################ TEXT FILE ##################<br/>&lt;td class=&quot;PhorumTableRowAlt thread&quot; style=&quot;padding-left: 0px&quot;&gt;<br/> <br/> &lt;a href=&quot;http://mysite.com/link/here_goes?id=239&quot;&gt;LINK&lt;/a&gt;<br/><br/> &amp;nbsp;&lt;span class=&quot;PhorumNewFlag&quot;&gt;&lt;/span&gt;&lt;/td&gt;<br/><br/> &lt;td class=&quot;PhorumTableRowAlt&quot; nowrap=&quot;nowrap&quot; width=&quot;150&quot;&gt;<br/> &lt;a href=&quot;http://mysite.com/link/here_goes?id=239&quot;&gt;LINK&lt;/a&gt; &lt;/td&gt;<br/> &lt;td class=&quot;PhorumTableRowAlt PhorumSmallFont&quot; nowrap=&quot;nowrap&quot; width=&quot;150&quot;&gt;06/11/2007 12:29AM<br/> &lt;/td&gt;<br/>&lt;/tr&gt;<br/>############################################<br/><br/>The text file contains hundreds of tds structure like above. All I need is to extract the td with class &quot;PhorumTableRowAlt thread&quot;. I have tried every possible option, but finally I am coming to you for any Regex for it? TIA.<br/><br/>HERE IS WHAT I AM DOING:<br/><br/>pen(TXT, &quot;links.txt&quot;) or die &quot;Unable to open file&quot;;<br/>my @links = &lt;TXT&gt;;<br/>close (TXT);<br/>foreach my $link(@links) {<br/>if ($link =~ m|&lt;td class=&quot;PhorumTableRow thread&quot; style=&quot;padding-left: 0px&quot;&gt;(.*?)&lt;/td&gt;|gsi) {<br/>print &quot;$1&quot;;}<br/>}<br/><br/><br/><br/>But NOTHING coming up. No results.<br/><br/>Thanks for any help.<br/><br/>Sara.<br/><br/><br/><br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/04/msg13177.html Tue, 08 Apr 2008 05:22:25 +0000 DeletePage (2 messages) Hi all,<br/> I am having a submit button and upon clicking it i am<br/>asking the user for confimation [for this i have used javascript].<br/>When the user selects yes i should be able to call another subroutine.<br/>But i am going wrong somewhere. Here&#39;s the code for your reference.<br/>Please help me to solve this. Thanks!<br/><br/><br/><br/>#!/usr/bin/perl -w<br/><br/>use strict;<br/>use CGI;<br/><br/>&amp;main();<br/>exit(0);<br/><br/>sub main {<br/> my $cmd = CGI::param(&#39;cmd&#39;);<br/><br/> &amp;mainPage() if($cmd eq &quot;&quot;);<br/> &amp;deletePage() if($cmd eq &quot;true&quot;);<br/><br/>}<br/><br/>sub mainPage {<br/><br/> print &quot;Content-type: text/html\n\n&quot;;<br/> print &quot;&lt;title&gt;Documents&lt;/title&gt;\n&quot;;<br/> print &quot;&lt;link href=style.css rel=stylesheet type=text/css&gt;\n&quot;;<br/><br/> print &lt;&lt;HTML;<br/><br/> &lt;head&gt;<br/> &lt;script type=&#39;text/javascript&#39;&gt;<br/><br/> function change()<br/> {<br/> var confirm_delete = confirm(&quot;sure?&quot;);<br/> if(confirm_delete == true)<br/> window.location = window.location.protocol + &#39;//&#39;<br/>+window.location.host + window.location.pathname + &quot;?cmd=&quot; +<br/>confirm_delete;<br/> else<br/> {<br/> alert(&quot;Delete action cancelled!&quot;);<br/> window.location.reload();<br/> }<br/> }<br/><br/> &lt;/script&gt;<br/> &lt;/head&gt;<br/>HTML<br/><br/> print &quot;&lt;body&gt;\n&quot;;<br/><br/> print &lt;&lt;HTML;<br/> &lt;form action=files.cgi method=&quot;POST&quot;&gt;<br/> &lt;input type=hidden name=cmd value=delete&gt;<br/> &lt;input type=hidden name=filedir value=up&gt;<br/> &lt;input type=hidden name=filename value=down&gt;<br/> &lt;input type=submit value=Delete onclick = change()&gt;<br/> &lt;/form&gt;<br/>HTML<br/>}<br/><br/>sub deletePage {<br/><br/> print &quot;File was deleted successfully!&lt;br&gt;&quot;;<br/><br/>}<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/03/msg13175.html Tue, 18 Mar 2008 01:56:18 +0000 Re: dinamic cgi with perl (2 messages) On Saturday March 15 2008 12:57 am, Pau Marc Munoz Torres wrote:<br/>&gt; Hi everybody<br/>&gt;<br/>&gt; i got a program that works in a bash environment, and now, i would like to<br/>&gt; make a cgi with it, the objective for this program is check the integrity<br/>&gt; of the info provided by some text files and if it finds some error ask you<br/>&gt; for some info and i would like to be able to introduce it.<br/>&gt;<br/>&gt; To solve it i was thinking on introduce a javascript code into my cgi, but<br/>&gt; i don&#39;t know how to pass the variable info between perl and javascript.<br/>&gt;<br/>&gt;<br/>&gt; could any of you tell me how to do it or give me any idea or give me a<br/>&gt; solution of how do it?<br/>&gt;<br/>&gt; thanks<br/>&gt;<br/>&gt; pau<br/>&gt; --<br/>&gt; Pau Marc Mu&Atilde;&plusmn;oz Torres<br/>&gt;<br/>&gt; Laboratori de Biologia Computacional<br/>&gt; Institut de Biotecnologia i Biomedicina Vicent<br/>&gt; Villar<br/>&gt; Universitat Autonoma de Barcelona<br/>&gt; E-08193 Bellaterra (Barcelona)<br/>&gt;<br/>&gt; tel&Atilde;&uml;fon: 93 5812807<br/>&gt; Email : paumarc.munoz@bioinf.uab.cat<br/>you could try and use AJAX to access a perl script via the CGI then have <br/>that script return a JSON formatted string to the caller java script then <br/>evaluate that string as a javascript code sniplet.<br/><br/>Greg<br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/03/msg13174.html Sat, 15 Mar 2008 14:12:45 +0000 Suggestions for a simple configuration management web application (4 messages) Hey all,<br/><br/>I am trying to find a simple, modular web based configuration<br/>application and am having a little trouble. Basically, I need<br/>something to do some simple configurations on an appliance similar to<br/>something like a laser printer. You know the little web based menu<br/>you get when you hit your local Lexmark C530dn or HP LaserJet and it<br/>allows you to change the IP address, set the printer name, and get<br/>some feedback on how many pages you&#39;ve printed? That&#39;s what I want.<br/><br/>I tried to look at webmin and possibly building my own modules, but<br/>I&#39;m based on Debian and webmin has fallen out of favor. My next<br/>thought was to write a little something, possibly based on<br/>TemplateToolkit but that seems a little excessive. I also played<br/>around with the idea of ripping the GUI out of m0n0wall and using it<br/>to base my stuff on, but that didn&#39;t seem very clean.<br/><br/>I would rather use and contribute to something that is pre-existing in<br/>the OSS world than to start my own project. My time is limited and<br/>I&#39;m not that great of a programmer. :) Anyway, it&#39;s hard to believe<br/>that no-one has ever created a simple little web app that can be<br/>extended with modules. Do you know of anything that I could use as a<br/>jumping off point?<br/><br/>Thanx!<br/> Richard<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/03/msg13169.html Tue, 11 Mar 2008 15:29:28 +0000 Undefined subroutine: if (param('admin') eq "y") (3 messages) I&#39;m using the Web Developer Server Suite - Community Edition pretty<br/>much out of the box on WindowsXP. This script worked fine on a LAMP<br/>system although I am not sure what Apache modules were loaded. I am<br/>beginning to wonder if I am missing some configuration to allow:<br/><br/>if (param(&#39;admin&#39;) eq &quot;y&quot;)<br/><br/>ERROR<br/><br/>Software error:<br/>Undefined subroutine &amp;main::param called at C:/www/vhosts/localhost/<br/>cgi-bin/stafio.pl line 33.<br/><br/>SCRIPT<br/><br/>#!C:/www/perl/bin/perl.exe<br/>use CGI::Carp qw(fatalsToBrowser);<br/># organizational In/Out board<br/><br/># configuration data<br/><br/>require &#39;C:/www/perl/lib/datapath/stafio.ph&#39;;<br/><br/># turn debugging output on and off with parameter<br/>#$debugging = (param(&#39;debug&#39;)) ? 1 : 0;<br/><br/>#print header;<br/><br/># Do refresh and css in header as is proper<br/>#print start_html(-title=&gt;&quot;Staff In/Out for $Organization&quot;,<br/>#-style=&gt;{&#39;src&#39;=&gt;&quot;C:/www/Apache22/manual/style/css/manual.css&quot;},<br/>#-head=&gt;meta({-http_equiv=&gt;&#39;refresh&#39;,-content=&gt;&#39;60&#39;})<br/>#);<br/><br/># get user information into memory<br/>%users = &amp;get_users();<br/><br/>if (param(&#39;admin&#39;) eq &quot;y&quot;)<br/>{<br/> # admin interface. add/delete users<br/> if (param(&#39;apswd&#39;))<br/> {<br/> # got a password. validate it<br/> if (param(&#39;apswd&#39;) eq $AdminPass)<br/> {<br/> # good password, check for add or delete<br/> if (param(&#39;userID&#39;))<br/> {<br/> &amp;put_a_user( param(&#39;userID&#39;),<br/> param(&#39;pswd&#39;),<br/> param(&#39;name&#39;),<br/> param(&#39;extension&#39;),<br/> param(&#39;location&#39;),<br/> param(&#39;return&#39;),<br/> param(&#39;email&#39;),<br/> param(&#39;locstring&#39;),<br/> param(&#39;aim&#39;));<br/> %users = &amp;get_users();<br/> &amp;display_inOut_board( %users );<br/> }<br/> else<br/> {<br/> @val = param(&#39;delme&#39;);<br/> foreach (@val)<br/> {<br/> $FILE = &quot;$Datapath/$_.$Ext&quot;;<br/> unlink( $FILE );<br/> }<br/> %users = &amp;get_users();<br/> &amp;display_inOut_board( %users );<br/> }<br/> }<br/> else<br/> {<br/> # report invalid administrative password<br/> print &lt;&lt;&quot;EOF&quot;<br/> &lt;H1&gt;Invalid Password&lt;/H1&gt;<br/> The password entered is incorrect. Use your browser&#39;s back<br/>function<br/> to try again.<br/>EOF<br/> }<br/> }<br/> else<br/> {<br/> # put up form to do something, including getting admin password<br/> &amp;admin( );<br/> }<br/>}<br/>else<br/>{<br/> if (param(&#39;userID&#39;))<br/> {<br/> if (param(&#39;pswd&#39;))<br/> {<br/> # we were sent a password, validate it and change status<br/> if (isValidPswd($users{param(&#39;userID&#39;)}{&#39;pswd&#39;},param(&#39;pswd&#39;)))<br/> {<br/> # change status<br/> &amp;put_a_user( param(&#39;userID&#39;),<br/> $users{param(&#39;userID&#39;)}{&#39;pswd&#39;},<br/> $users{param(&#39;userID&#39;)}{&#39;name&#39;},<br/> $users{param(&#39;userID&#39;)}{&#39;extension&#39;},<br/> param(&#39;location&#39;),<br/> param(&#39;return&#39;),<br/> $users{param(&#39;userID&#39;)}{&#39;email&#39;},<br/> param(&#39;locstring&#39;),<br/> $users{param(&#39;userID&#39;)}{&#39;aim&#39;} );<br/> %users = &amp;get_users();<br/> &amp;display_inOut_board( %users );<br/> }<br/> else<br/> {<br/> # report invalid password<br/> print &lt;&lt;&quot;EOF&quot;<br/> &lt;H1&gt;Invalid Password&lt;/H1&gt;<br/> The password entered is incorrect. Use your browser&#39;s back<br/>function<br/> to try again.<br/>EOF<br/> }<br/> }<br/> elsif (param(&#39;newpswd&#39;))<br/> {<br/> if (param(&#39;newpswd2&#39;))<br/> {<br/> # we&#39;ve got new password, confirm and rewrite<br/> if (isValidPswd($users{param(&#39;userID&#39;)}<br/>{&#39;pswd&#39;},param(&#39;oldpswd&#39;)))<br/> {<br/> # check new passwords match<br/> if (param(&#39;newpswd&#39;) eq param(&#39;newpswd2&#39;))<br/> {<br/> # rewrite user record<br/> &amp;put_a_user( param(&#39;userID&#39;),<br/> param(&#39;newpswd&#39;),<br/> param(&#39;name&#39;),<br/> param(&#39;extension&#39;),<br/> param(&#39;location&#39;),<br/> param(&#39;return&#39;),<br/> param(&#39;email&#39;),<br/> param(&#39;aim&#39;) );<br/> %users = &amp;get_users();<br/> &amp;display_inOut_board( %users );<br/> }<br/> else<br/> {<br/> # report mismatched new passwords<br/> print &lt;&lt;&quot;EOF&quot;<br/> &lt;H1&gt;Mismatched New Passwords&lt;/H1&gt;<br/> The new passwords do not match. Use your browser&#39;s back<br/>function<br/> to try again.<br/>EOF<br/> }<br/> }<br/> else<br/> {<br/> # report invalid password<br/> print &lt;&lt;&quot;EOF&quot;<br/> &lt;H1&gt;Invalid Password&lt;/H1&gt;<br/> The old password is incorrect. Use your browser&#39;s back function<br/> to try again.<br/>EOF<br/> }<br/> }<br/> else<br/> {<br/> # put up form to get a new password for the user<br/> &amp;change_password( param(&#39;userID&#39;),<br/> $users{param(&#39;userID&#39;)}{&#39;pswd&#39;},<br/> $users{param(&#39;userID&#39;)}{&#39;name&#39;},<br/> $users{param(&#39;userID&#39;)}{&#39;extension&#39;},<br/> $users{param(&#39;userID&#39;)}{&#39;location&#39;},<br/> $users{param(&#39;userID&#39;)}{&#39;return&#39;},<br/> $users{param(&#39;userID&#39;)}{&#39;email&#39;},<br/> $users{param(&#39;userID&#39;)}{&#39;aim&#39;} );<br/> }<br/> }<br/> else<br/> {<br/> # no password, just a userID, so we need to put up a form<br/> # to let user change location and return<br/> &amp;change_status(param(&#39;userID&#39;), $users{param(&#39;userID&#39;)}<br/>{&#39;email&#39;});<br/> }<br/> }<br/> else<br/> {<br/> &amp;display_inOut_board( %users );<br/> }<br/>} #end if (admin)...else<br/>print end_html;<br/><br/>exit;<br/><br/>### subroutines ###<br/><br/>sub admin<br/># administration form, add/delete users<br/>{<br/># my( ) = @_;<br/><br/> ## Add a user<br/> print start_form(-method=&gt;&quot;post&quot;, -action=&gt;&quot;stafio.pl&quot;);<br/><br/> print &lt;&lt;&quot;EOF&quot;;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;admin&quot; VALUE=&quot;y&quot;&gt;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;do&quot; VALUE=&quot;add&quot;&gt;<br/><br/> &lt;TABLE&gt;<br/> &lt;TR&gt;&lt;TH&gt;Add a User&lt;/TH&gt;&lt;TD&gt;Admin Password:&lt;INPUT TYPE=&quot;password&quot;<br/>NAME=&quot;apswd&quot; VALUE=&quot;&quot; SIZE=20 MAXLENGTH=20&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;User ID&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot; NAME=&quot;userID&quot;<br/>VALUE=&quot;$userID&quot; SIZE=25&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;User Name&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot; NAME=&quot;name&quot;<br/>VALUE=&quot;$name&quot; SIZE=25&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Phone Extension&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot;<br/>NAME=&quot;extension&quot; VALUE=&quot;$extension&quot; SIZE=10&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;AIM Address&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot;<br/>NAME=&quot;aim&quot; VALUE=&quot;$aim&quot; SIZE=25&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Email Address&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot;<br/>NAME=&quot;email&quot; VALUE=&quot;$email&quot; SIZE=25&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Password&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;password&quot;<br/>NAME=&quot;pswd&quot; VALUE=&quot;&quot; SIZE=20 MAXLENGTH=20&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Location&lt;/TD&gt;&lt;TD&gt; &lt;SELECT NAME=&quot;location&quot;&gt;<br/>EOF<br/> foreach( @Locations )<br/> {<br/> print &quot;&lt;OPTION&gt; $_\n&quot;;<br/> }<br/> print &lt;&lt;&quot;EOF&quot;;<br/> &lt;/SELECT&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Other Location Text&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot;<br/>NAME=&quot;locstring&quot; VALUE=&quot;&quot; SIZE=25&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Return by&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot;<br/>NAME=&quot;return&quot; VALUE=&quot;&quot; SIZE=10&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;/TABLE&gt;<br/> &lt;INPUT TYPE=&quot;submit&quot; NAME=&quot;submit&quot; VALUE=&quot; OK &quot;&gt;<br/> &lt;/FORM&gt;<br/>EOF<br/><br/> ## Delete a user<br/> print start_form(-method=&gt;&quot;post&quot;, -action=&gt;&quot;stafio.pl&quot;);<br/><br/> print &lt;&lt;&quot;EOF&quot;;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;admin&quot; VALUE=&quot;y&quot;&gt;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;do&quot; VALUE=&quot;del&quot;&gt;<br/><br/> &lt;TABLE&gt;<br/> &lt;TR&gt;&lt;TH&gt;Delete&lt;/TH&gt;&lt;TD&gt;Admin Password:&lt;INPUT TYPE=&quot;password&quot;<br/>NAME=&quot;apswd&quot; VALUE=&quot;&quot; SIZE=20 MAXLENGTH=20&gt;&lt;/TD&gt;&lt;/TR&gt;<br/>EOF<br/> foreach $usr ( sort keys %users )<br/> {<br/> print &lt;&lt;&quot;EOF&quot;;<br/> &lt;tr&gt;<br/> &lt;TD&gt;&lt;INPUT TYPE=CHECKBOX NAME=&quot;delme&quot; VALUE=&quot;$usr&quot;&gt;&lt;/TD&gt;&lt;TD&gt;<br/>$users{$usr}{&#39;name&#39;}&lt;/TD&gt;<br/> &lt;/tr&gt;<br/>EOF<br/> }<br/> print &lt;&lt;&quot;EOF&quot;;<br/> &lt;/TABLE&gt;<br/> &lt;INPUT TYPE=&quot;submit&quot; NAME=&quot;submit&quot; VALUE=&quot; OK &quot;&gt;<br/> &lt;/FORM&gt;<br/>EOF<br/><br/>} # end admin<br/><br/>sub change_password<br/># user gets a form to change password<br/>{<br/> my ($userID, $pswd, $name, $extension, $location, $return, $email,<br/>$aim) = @_;<br/><br/> print h1(&quot;Change Password&quot;);<br/><br/> print start_form(-method=&gt;&quot;post&quot;, -action=&gt;&quot;stafio.pl&quot;);<br/><br/> print &lt;&lt;&quot;EOF&quot;;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;userID&quot; VALUE=&quot;$userID&quot;&gt;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;name&quot; VALUE=&quot;$name&quot;&gt;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;extension&quot; VALUE=&quot;$extension&quot;&gt;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;aim&quot; VALUE=&quot;$aim&quot;&gt;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;location&quot; VALUE=&quot;$location&quot;&gt;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;return&quot; VALUE=&quot;$return&quot;&gt;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;email&quot; VALUE=&quot;$email&quot;&gt;<br/><br/> &lt;TABLE&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Old Password&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;password&quot;<br/>NAME=&quot;oldpswd&quot; VALUE=&quot;&quot; SIZE=20 MAXLENGTH=20&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;New Password&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;password&quot;<br/>NAME=&quot;newpswd&quot; VALUE=&quot;&quot; SIZE=20 MAXLENGTH=20&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Confirm Password&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;password&quot;<br/>NAME=&quot;newpswd2&quot; VALUE=&quot;&quot; SIZE=20 MAXLENGTH=20&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;/TABLE&gt;<br/> &lt;INPUT TYPE=&quot;submit&quot; NAME=&quot;submit&quot; VALUE=&quot; OK &quot;&gt;<br/> &lt;/FORM&gt;<br/>EOF<br/>} # end change_password<br/><br/>sub change_status<br/># user gets form to change location and/or return time<br/>{<br/> my ($userID, $email) = @_;<br/><br/> print h1(&quot;Change Status&quot;);<br/><br/> print &quot;&lt;a href=\&quot;stafio.pl?userID=$userID&amp;newpswd=1\&quot;&gt;Change<br/>Password&lt;/a&gt;\n&quot;;<br/><br/> print start_form(-method=&gt;&quot;post&quot;, -action=&gt;&quot;stafio.pl&quot;);<br/><br/> print &lt;&lt;&quot;EOF&quot;;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;userID&quot; VALUE=&quot;$userID&quot;&gt;<br/> &lt;INPUT TYPE=&quot;hidden&quot; NAME=&quot;email&quot; VALUE=&quot;$email&quot;&gt;<br/> &lt;TABLE&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;User&lt;/TD&gt;&lt;TD&gt;&lt;B&gt;$userID&lt;B&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Password&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;password&quot;<br/>NAME=&quot;pswd&quot; VALUE=&quot;&quot; SIZE=20 MAXLENGTH=20&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Location&lt;/TD&gt;&lt;TD&gt; &lt;SELECT NAME=&quot;location&quot;&gt;<br/>EOF<br/> foreach( @Locations )<br/> {<br/> print &quot;&lt;OPTION&gt; $_\n&quot;;<br/> }<br/> print &lt;&lt;&quot;EOF&quot;<br/> &lt;/SELECT&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Other Location Text&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot;<br/>NAME=&quot;locstring&quot; VALUE=&quot;&quot; SIZE=25&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;TR&gt;&lt;TD ALIGN=RIGHT&gt;Return by&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=&quot;text&quot;<br/>NAME=&quot;return&quot; VALUE=&quot;&quot; SIZE=10&gt;&lt;/TD&gt;&lt;/TR&gt;<br/> &lt;/TABLE&gt;<br/> &lt;INPUT TYPE=&quot;submit&quot; NAME=&quot;submit&quot; VALUE=&quot; OK &quot;&gt;<br/> &lt;/FORM&gt;<br/>EOF<br/>} # end change_status<br/><br/>sub display_inOut_board<br/># display table of user data<br/>{<br/> my %users = @_;<br/><br/><br/>#<br/># print &quot;&lt;meta http-equiv=\&quot;Refresh\&quot; content=\60\&quot;&gt;\n&quot;;<br/># print &quot;&lt;/HEAD&gt;\n&quot;;<br/>#<br/>#<br/><br/> print &quot;&lt;center&gt;\n&quot;;<br/> print h1(&quot;$Organization Staff I/O Board&quot;);<br/># print h1(&quot;$Organization&quot;),<br/># h2(&quot;In / Out Board&quot; );<br/> print &lt;&lt;&quot;EOF&quot;;<br/> &lt;table width=&quot;90%&quot;&gt;<br/> &lt;tr&gt;<br/> &lt;th&gt;Name&lt;/th&gt;<br/> &lt;th width=12&gt;Extension&lt;/th&gt;<br/> &lt;th&gt;Location&lt;/th&gt;<br/> &lt;th&gt;Returning&lt;/th&gt;<br/> &lt;th&gt;AIM&lt;/th&gt;<br/> &lt;/tr&gt;<br/>EOF<br/><br/> foreach $usr ( sort keys %users )<br/> {<br/> print &lt;&lt;&quot;EOF&quot;;<br/> &lt;tr&gt;<br/> &lt;td&gt;&lt;a href=&quot;mailto:$users{$usr}{&#39;email&#39;}&quot;&gt;$users{$usr}{&#39;name&#39;}&lt;/<br/>a&gt;&lt;/td&gt;<br/> &lt;td align=center&gt;$users{$usr}{&#39;extension&#39;}&lt;/td&gt;<br/> &lt;td&gt;&lt;a href=&quot;stafio.pl?userID=$usr&quot;&gt;$users{$usr}{&#39;location&#39;}&lt;/a&gt;&lt;/<br/>td&gt;<br/> &lt;td align=center&gt;$users{$usr}{&#39;return&#39;}&lt;/td&gt;<br/> &lt;td align=center&gt;$users{$usr}{&#39;aim&#39;}&lt;/td&gt;<br/> &lt;/tr&gt;<br/>EOF<br/> }<br/><br/>#<br/> print &quot;&lt;/table&gt;\n&quot;;<br/> print &quot;&lt;BR&gt;\n&quot;;<br/> print h2(&quot;&lt;A HREF=\&quot;http://www.xxxxxxx/\&quot;&gt;Staff directory&lt;/A&gt;\n&quot;);<br/>#<br/><br/> print &quot;&lt;/center&gt;\n&quot;;<br/>} # end display_inOut_board<br/><br/>sub get_a_user<br/># retrieve data for one user<br/>{<br/> my( $file ) = @_;<br/> my ($userID, $pswd, $name, $extension, $loc, $time, $email, $aim);<br/><br/> $FILE = &quot;$Datapath/$file&quot;;<br/> open( IN, &quot;&lt;$FILE&quot; )<br/> || &amp;try_later(1);<br/> foreach( &lt;IN&gt; )<br/> {<br/> ($userID) = ($file =~ /(.*)\.$Ext/);<br/> ($pswd, $name, $extension, $loc, $time, $email, $aim) =<br/>split( $Delim, $_ );<br/> }<br/> close( IN );<br/> return( $userID, $pswd, $name, $extension, $loc, $time, $email,<br/>$aim );<br/>} # end get_a_user<br/><br/>sub get_users<br/># get user data into a hash of hashes, keyed on userID<br/>{<br/> my( %u ) = ();<br/> my ( @files, $file, $userID, $pswd, $name, $extension, $loc, $time,<br/>$email, $aim );<br/><br/> opendir DATADIR, $Datapath<br/> || &amp;try_later(2);<br/> @files = grep /$Ext$/, readdir DATADIR;<br/> closedir DATADIR;<br/> foreach $file (@files)<br/> {<br/> ( $userID, $pswd, $name, $extension, $loc, $time, $email, $aim ) =<br/>&amp;get_a_user( $file );<br/> $u{$userID}{&#39;pswd&#39;} = $pswd;<br/> $u{$userID}{&#39;name&#39;} = $name;<br/> $u{$userID}{&#39;extension&#39;} = $extension;<br/> $u{$userID}{&#39;location&#39;} = $loc;<br/> $u{$userID}{&#39;return&#39;} = $time;<br/> $u{$userID}{&#39;email&#39;} = $email;<br/> $u{$userID}{&#39;aim&#39;} = $aim;<br/> }<br/> return( %u );<br/>} # end get_users<br/><br/>sub isValidPswd<br/># validate password against userID<br/># return 1 (true) if password is valid<br/>{<br/> my( $u, $p ) = @_;<br/> my( $return ) = 0;<br/><br/> if ($p eq $BossPass)<br/> {<br/> $return = 1;<br/> }<br/> else<br/> {<br/> $return = ($u eq $p) ? 1 : 0;<br/> }<br/> return( $return );<br/>} # end isValidPswd<br/><br/>sub put_a_user<br/># write new data for one user<br/>{<br/> my( $userID, $pswd, $name, $extension, $loc, $return, $email,<br/>$locstr, $aim ) = @_;<br/><br/> $locstr =~ tr/ / /s;<br/> $locstr = &quot;unknown&quot; unless (length( $locstr ) &gt; 1);<br/> $loc = $locstr if ($loc eq &quot;Other&quot;);<br/> $return = &quot; - &quot; unless ($return);<br/><br/> $FILE = &quot;$Datapath/$userID.$Ext&quot;;<br/> open( OUT, &quot;&gt;$FILE&quot;)<br/> || &amp;try_later(3);<br/> print OUT &quot;$pswd$Delim$name$Delim$extension$Delim$loc$Delim$return<br/>$Delim$email$Delim$aim&quot;;<br/> close( OUT );<br/>} # end put_a_user<br/><br/>sub try_later<br/># minimal error handling<br/>{<br/> local($errnum) = @_;<br/><br/> print h2(&quot;Unable to open $FILE for reading: $!&quot;) if $errnum == 1;<br/> print h2(&quot;Unable to find data files: $!&quot;) if $errnum == 2;<br/> print h2(&quot;Unable to open $FILE for writing: $!&quot;) if $errnum == 3;<br/><br/> print h2(&quot;Please try again later.&quot;);<br/><br/> print end_html;<br/> exit;<br/>} # end try_later<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/02/msg13166.html Wed, 20 Feb 2008 03:04:15 +0000 Send a file (2 messages) Hi,<br/><br/>I am trying to send a file in response to a request but am having <br/>trouble.<br/><br/>Here&#39;s what I have so far. I am not certain what the headers should <br/>be. I am not getting any more info from my error_log except Premature <br/>end of script headers.<br/><br/><br/>my $s = (stat($file))[7];<br/><br/>my $filename = $user.&#39;.csv&#39;;<br/>seek $fh,0,0;<br/>print header(-type=&gt;&quot;text/tab-separated-values&quot;,-Content_length=&gt;$s, <br/> -Content_Disposition=&gt;&quot;attachment;filename=$filename&quot;);<br/>print $fh;<br/>close($fh);<br/><br/><br/>Can anyone offer some advice?<br/>Thanx,<br/>Dp.<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/02/msg13164.html Tue, 19 Feb 2008 04:15:38 +0000 Re: Process Directory and subdirectories Recursively (4 messages) On Jan 28, 2008 6:56 AM, Mimi Cafe &lt;mimicafe@googlemail.com&gt; wrote:<br/>&gt; Hi,<br/>&gt;<br/>&gt; I am trying to process a directory and all subdirectory recursively and<br/>&gt; generate a list as the Unix command &quot;ls -R&quot; will display, but this seems not<br/>&gt; to behave as it should.<br/>&gt; My script only goes as far as processing the directory and the 1 step below<br/>&gt; not more.<br/>&gt;<br/>&gt; I have some like, but the script goes as far as 1_child and 2_child but no<br/>&gt; further:<br/>&gt; /parent/1_child/1_grant_child/././<br/>&gt; /parent/2_child/2_grant_child/././<br/>&gt;<br/>&gt; The script will finally be used on Windows OS, Unix system command cannot<br/>&gt; be used.<br/>&gt;<br/>&gt; Can anyone help?<br/><br/>I would suggest trying to use a CPAN module for this type of thing.<br/>There may be others, but look at File::Find:<br/><br/>http://search.cpan.org/search%3fmodule=File::Find<br/><br/><br/>&gt;<br/>&gt; ###############################################################<br/>&gt; #!/usr/bin/perl -w<br/>&gt;<br/>&gt;<br/>&gt; # Recursively read content of a folder and dynamically create a list on an<br/>&gt; html page.<br/>&gt;<br/>&gt; use CGI qw(:standard);<br/>&gt; #use CGI::Carp qw(warningsToBrowser fatalsToBrowser);<br/>&gt; #use warnings;<br/>&gt; use strict;<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; print header(),<br/>&gt; start_html(&quot;Documents list&quot;);<br/>&gt; print &quot;&lt;h1&gt; Documents List&lt;/h1&gt;&lt;br&gt;\n&quot;;<br/>&gt;<br/>&gt; my $source = &quot;/depot/my_directory&quot;;<br/>&gt;<br/>&gt; opendir (SOURCE, $source) or die &quot;Cannot open the source folder for reading:<br/>&gt; $!\n&quot;;<br/>&gt;<br/>&gt; my $file;<br/>&gt; while (defined($file = readdir(SOURCE))){<br/>&gt; next if $file =~ /^\.{1,2}$/;<br/>&gt; my $full_name = &quot;$source/$file&quot;;<br/>&gt; if (-d $full_name){<br/>&gt; #my $full_name = &quot;$source/$file&quot;;<br/>&gt; print qq(&lt;b&gt;$file&lt;/b&gt;&lt;br&gt;);<br/>&gt; process($full_name);<br/>&gt; }else{<br/>&gt; print qq(&lt;a href=&quot;$full_name&gt;$file&lt;/a&gt;&lt;br&gt;);<br/>&gt; }<br/>&gt; #next;<br/>&gt; }<br/>&gt; closedir (SOURCE);<br/>&gt;<br/>&gt;<br/>&gt; print end_html();<br/>&gt;<br/>&gt;<br/>&gt;<br/>&gt; # Subroutine to process subdirectory and list content.<br/>&gt;<br/>&gt; sub process{<br/>&gt;<br/>&gt; my ($path, $file, @files, $file_full_path);<br/>&gt; $path = shift;<br/>&gt; opendir (SUBDIR, $path) or die &quot;Cannot open the subfolder for reading:<br/>&gt; $!\n&quot;;<br/>&gt;<br/>&gt; @files = sort grep {!/^\.{1,2}$/} readdir(SUBDIR);<br/>&gt; closedir (SUBDIR);<br/>&gt;<br/>&gt; for (@files){<br/>&gt; $file_full_path = &quot;$path/$_&quot;;<br/>&gt;<br/>&gt; if (-d $_){<br/>&gt; print qq(&lt;b&gt;$_&lt;/b&gt;&lt;br /&gt;);<br/>&gt; process($_);<br/>&gt;<br/>&gt;<br/>&gt; }else {<br/>&gt;<br/>&gt; print qq(&lt;a href=&quot;$file_full_path&quot;&gt;$_&lt;/a&gt;&lt;br /&gt;);<br/>&gt;<br/>&gt; }<br/>&gt;<br/>&gt; }<br/>&gt;<br/>&gt;<br/>&gt; }<br/>&gt; #######################################################<br/>&gt;<br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13162.html Mon, 28 Jan 2008 06:46:02 +0000 Re: beginners-cgi Digest 23 Jan 2008 23:10:02 -0000 Issue 991 (1 message) REMOVE FROM EMAIL LIST. STOP!!<br/>----- Original Message ----- <br/>From: &lt;beginners-cgi-digest-help@perl.org&gt;<br/>To: &lt;beginners-cgi@perl.org&gt;<br/>Sent: Wednesday, January 23, 2008 5:10 PM<br/>Subject: beginners-cgi Digest 23 Jan 2008 23:10:02 -0000 Issue 991<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13157.html Thu, 24 Jan 2008 04:31:38 +0000 authorization -> session handling (1 message) Hi<br/><br/>Does anyone have any cool and helpful links / URLS for Session Handling and populating a table?<br/>I would like to build a page for authorization.<br/><br/>Kind Regards<br/>Brent Clark<br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13156.html Wed, 23 Jan 2008 05:32:06 +0000 Intermittent problems accessing MySQL data (5 messages) I have inherited a site written in perl. Recently an intermittent<br/>problem has come up and when users log into the site, they end up seeing<br/>other users data. I personally can not reproduce the problem but it has<br/>happened enough that I am sure it is more than just a fluke. Does<br/>anyone know of any recent changes in perl that could cause this kind of<br/>problem? The site is pretty old, I would guess at least 5 years or more<br/>since it was written. However the problem has only happened in the last<br/>few months. I have no control over the server and am told that updates<br/>are applied automatically.<br/><br/>BTW I haven&#39;t used perl in years so unless someone here has a pretty<br/>good idea what to look for, I will most likely be redoing it in php.<br/><br/>-- <br/>Chris W<br/>KE5GIX<br/><br/>&quot;Protect your digital freedom and privacy, eliminate DRM,<br/>learn more at http://www.defectivebydesign.org/what_is_drm&quot;<br/><br/>Ham Radio Repeater Database.<br/>http://hrrdb.com<br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13151.html Tue, 22 Jan 2008 20:11:54 +0000 Looping Dates. (7 messages) I am stuck here, I want to get list of dates in a certain range. Like: Start Date: 2007-01-03 to End Date: 2007-05-30<br/><br/>I am pointless here as what should I do in order to get all dates between start and end? Is there any for, foreach loop or other method? that will generate a list of dates:<br/><br/>2007-01-03<br/>2007-01-04<br/>2007-01-05<br/>2007-01-06<br/>2007-01-07<br/>.............. and so on to<br/>2007-05-30<br/><br/>Any ideas will be appreciated.<br/><br/>Thanks,<br/>Sara.<br/><br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13145.html Fri, 18 Jan 2008 22:39:46 +0000 Re: uploading a file with perl--->kueri: ------------4CyrMz2ZeGIClwYfFsVdcv Content-Disposition: form-data; name="level" asda ------------4CyrMz2ZeGIClwYfFsVdcv Content-Disposition: form-data; name="major" asda ------------4CyrMz2ZeGIClwYfFsVd....[ve (3 messages) Hi, Patrik.<br/><br/>You should probably be using CGI.pm. It will vastly simplify what you are<br/>doing. Then, you can read any of a dozen sites on doing file uploads using<br/>CGI; see search.cpan.org for the details of using CGI.pm.<br/><br/>Sean<br/><br/><br/>On Jan 12, 2008 5:54 PM, Patrik Hasibuan &lt;patrikh@penguin-teknologi.com&gt;<br/>wrote:<br/><br/>&gt; Dear my friends...<br/>&gt;<br/>&gt; I am still new in perl.<br/>&gt;<br/>&gt; I am writing perl-cgi application for uploading a file. I did &quot;chmod<br/>&gt; 777 ../../artikel&quot;. But I get weird displayed message:<br/>&gt; &quot;<br/>&gt; ueri: ------------4CyrMz2ZeGIClwYfFsVdcv Co........<br/>&gt; &icirc; 6&ecirc;&Icirc;]&Euml; k&scaron;f&thorn;x&icirc;&pound;&circ;&middot;&frac34; &eth;fS4M3&gt;&ordm; {&frac12;&Dagger;&lt;&Oacute;&ouml;&ugrave;&sup3;(R)&#xFFFD;&macr;3&ccedil;&yacute;G&egrave;B&ugrave;= &bdquo;&not;&Egrave;&rsaquo;&oslash;R&fnof;.....<br/>&gt; &amp;&fnof; &yuml;&fnof;&amp;m&Dagger;&icirc;&oslash;&#39;-n n&Ecirc;&ETH;J(p&Ccedil; 9&ccedil;q&icirc;&Icirc;.........<br/>&gt; &Ecirc; &uml;&sbquo;&iexcl;&Agrave;&Uuml; E&Ouml;&#xFFFD;&Acirc; z!&ordf;&tilde;Y6&#xFFFD;&not;&uacute;&Ograve;&bdquo;&acirc;0J&frac14;&quot;&ntilde;&Euml;.......<br/>&gt; [end so on. very longg.............]<br/>&gt; &quot;.<br/>&gt;<br/>&gt; And no file copied/uploaded in &#39;../../artikel&#39;. But inserting the record<br/>&gt; onto<br/>&gt; the mysql run properly.<br/>&gt;<br/>&gt; Please tell me why.....<br/>&gt;<br/>&gt; Here I have done:<br/>&gt; deartikel.cgi--&gt;cgideartikel.cgi--&gt;cgiuploadfile.cgi (&#39;--&gt;&#39; means<br/>&gt; &#39;calls&#39;).<br/>&gt; ===<br/>&gt; deartikel.cgi:<br/>&gt; ---<br/>&gt; #!/usr/bin/perl -w<br/>&gt; #use strict;<br/>&gt; use CGI qw(:standard);<br/>&gt; use CGI::Carp qw(warningsToBrowser fatalsToBrowser);<br/>&gt;<br/>&gt; print &quot;Content-type: text/html\n\n&quot;;<br/>&gt; print &quot;&lt;html&gt;&quot;;<br/>&gt; print &quot;&lt;head&gt;&quot;;<br/>&gt; print &quot;&lt;/head&gt;&quot;;<br/>&gt; print &quot;&lt;body&gt;&lt;font style=\&quot;Arial,Arial Black,Helvetica\&quot; size=1&gt;&quot;;<br/>&gt; print &quot; &lt;form method=\&quot;post\&quot; action=\&quot;cgideartikel.cgi\&quot;&gt; &quot;;<br/>&gt; print &quot;Title of file &lt;input type=\&quot;text\&quot; name=\&quot;judul\&quot; size=60<br/>&gt; autocomplete=\&quot;ON\&quot;&gt; &quot;;<br/>&gt; print &quot;&lt;input type=\&quot;submit\&quot; value=\&quot;Submit to column &#39;Articles&#39;.\&quot;&gt;<br/>&gt; &lt;input type=\&quot;reset\&quot; value=\&quot;Input lagi?\&quot;&gt;<br/>&gt; print &quot; &lt;/form&gt; &quot;;<br/>&gt; print &quot;&lt;/body&gt;&quot;;<br/>&gt; print &quot;&lt;/html&gt;&quot;;<br/>&gt; ===<br/>&gt; cgideartikel.cgi:<br/>&gt; ---<br/>&gt; #!/usr/bin/perl -w<br/>&gt; use CGI qw(:standard);<br/>&gt; use CGI::Carp qw(warningsToBrowser fatalsToBrowser);<br/>&gt; use DBI;<br/>&gt;<br/>&gt; print &quot;Content-type: text/html\n\n&quot;;<br/>&gt; print &quot;&lt;html&gt;&quot;;<br/>&gt; print &quot;&lt;head&gt;&quot;;<br/>&gt; print &quot;&lt;title&gt;&quot;;<br/>&gt; print &quot;Online Science Org - Data entry kolom karir.&quot;;<br/>&gt; print &quot;&lt;/title&gt;&quot;;<br/>&gt; print &quot;&lt;/head&gt;&quot;;<br/>&gt; print &quot;&lt;body&gt;&lt;font style=\&quot;Arial,Arial Black,Helvetica\&quot; size=1&gt;&quot;;<br/>&gt; $pjg=$ENV{&quot;CONTENT_LENGTH&quot;};<br/>&gt; read(STDIN, $kueri, $pjg);<br/>&gt; #print &quot;kueri: $kueri&lt;br&gt;&quot;;<br/>&gt; @arr_prm=split(&quot;&amp;&quot;,$kueri);<br/>&gt; foreach $myprm(@arr_prm){<br/>&gt; ($namavar,$nilaivar)=split(&quot;=&quot;,$myprm);<br/>&gt; $assprm{$namavar}=$nilaivar;<br/>&gt; }<br/>&gt; $i=0;<br/>&gt; foreach my $nv(keys %assprm){<br/>&gt; print &quot;$nv &lt;br&gt;&quot;;<br/>&gt; print &quot;$assprm{$nv} &lt;br&gt;&quot;;<br/>&gt; print &quot;i = $i &lt;br&gt;&quot;;<br/>&gt; $i++;<br/>&gt; }<br/>&gt;<br/>&gt; $judul=$assprm{&#39;judul&#39;};<br/>&gt; print &quot; &lt;form method=\&quot;post\&quot; action=\&quot;cgiuploadartikel.cgi\&quot;<br/>&gt; enctype=\&quot;multipart/form-data\&quot;&gt; &quot;;<br/>&gt; print &quot;Judul&lt;input type=\&quot;text\&quot; name=\&quot;judul\&quot; size=60<br/>&gt; autocomplete=\&quot;ON\&quot;<br/>&gt; value=\&quot;$judul\&quot; readonly&gt; &quot;;<br/>&gt; print &quot;File untuk di-upload&quot;;<br/>&gt; print &quot; &lt;input type=\&quot;file\&quot; name=\&quot;url\&quot; size=60 autocomplete=\&quot;ON\&quot;&gt; &quot;;<br/>&gt; print &quot;&lt;input type=\&quot;submit\&quot; value=\&quot;Submit to column &#39;Artikel&#39;.\&quot;&gt;<br/>&gt; &lt;input type=\&quot;reset\&quot; value=\&quot;Input lagi?\&quot;&gt;&quot;;<br/>&gt; print &quot; &lt;/form&gt; &quot;;<br/>&gt; print &quot;&lt;/body&gt;&quot;;<br/>&gt; print &quot;&lt;/html&gt;&quot;;<br/>&gt; &amp;simpan(judul);<br/>&gt;<br/>&gt; sub simpan{<br/>&gt; my $myjudul=shift;<br/>&gt; my $box=&quot;localhost&quot;;<br/>&gt; my $basisdata=&quot;mydb&quot;;<br/>&gt; my $db_user_name=&#39;root&#39;;<br/>&gt; my $db_password=&#39;mypw&#39;;<br/>&gt; my $dsn=&quot;DBI:mysql:$basisdata:$box&quot;;<br/>&gt;<br/>&gt; my $dbh = DBI-&gt;connect($dsn, $db_user_name, $db_password);<br/>&gt; my $sqlstr=qq{<br/>&gt; insert into<br/>&gt; artikel (<br/>&gt; judul,<br/>&gt; )<br/>&gt; values(<br/>&gt; &#39;$myjudul&#39;<br/>&gt; )<br/>&gt; };<br/>&gt; my $sth = $dbh-&gt;prepare($sqlstr);<br/>&gt; my $status=$sth-&gt;execute();<br/>&gt; if($status){<br/>&gt; $sth-&gt;{Commit};<br/>&gt; }else{<br/>&gt; $sth-&gt;{RollBack};<br/>&gt; }<br/>&gt; $dbh-&gt;disconnect;<br/>&gt; }<br/>&gt; ---<br/>&gt; cgiuploadfile.cgi:<br/>&gt; ---<br/>&gt; #!/usr/bin/perl -w<br/>&gt; use CGI qw(:standard);<br/>&gt; use CGI::Carp qw(warningsToBrowser fatalsToBrowser);<br/>&gt; print &quot;Content-type: text/html\n\n&quot;;<br/>&gt; print &quot;&lt;html&gt;&quot;;<br/>&gt; print &quot;&lt;head&gt;&quot;;<br/>&gt; print &quot;&lt;title&gt;&quot;;<br/>&gt; print &quot;Online Science Org - Data entry kolom karir.&quot;;<br/>&gt; print &quot;&lt;/title&gt;&quot;;<br/>&gt; print &quot;&lt;/head&gt;&quot;;<br/>&gt; print &quot;&lt;body&gt;&quot;;<br/>&gt;<br/>&gt; $pjg=$ENV{&quot;CONTENT_LENGTH&quot;};<br/>&gt; read(STDIN, $kueri, $pjg);<br/>&gt; print &quot;kueri: $kueri&lt;br&gt;&quot;;<br/>&gt; exit;<br/>&gt; @arr_prm=split(&quot;&amp;&quot;,$kueri);<br/>&gt; foreach $myprm(@arr_prm){<br/>&gt; ($namavar,$nilaivar)=split(&quot;=&quot;,$myprm);<br/>&gt; $assprm{$namavar}=$nilaivar;<br/>&gt; }<br/>&gt; $i=0;<br/>&gt; foreach my $nv(keys %assprm){<br/>&gt; print &quot;$nv &lt;br&gt;&quot;;<br/>&gt; print &quot;$assprm{$nv} &lt;br&gt;&quot;;<br/>&gt; print &quot;i = $i &lt;br&gt;&quot;;<br/>&gt; $i++;<br/>&gt; }<br/>&gt;<br/>&gt; $judul=$assprm{&#39;judul&#39;};<br/>&gt; $url=$assprm{&#39;url&#39;};<br/>&gt; print &quot; &lt;form method=\&quot;post\&quot; action=\&quot;cgiuploadartikel.cgi\&quot;<br/>&gt; enctype=\&quot;multipart/form-data\&quot;&gt; &quot;;<br/>&gt; print &quot; &lt;input type=\&quot;text\&quot; name=\&quot;judul\&quot; size=60 autocomplete=\&quot;ON\&quot;<br/>&gt; value=\&quot;$judul\&quot; readonly&gt; &quot;;<br/>&gt; print &quot;File untuk di-upload&quot;;<br/>&gt; print &quot; &lt;input type=\&quot;file\&quot; name=\&quot;url\&quot; size=60 autocomplete=\&quot;ON\&quot;<br/>&gt; readonly&gt; &quot;;<br/>&gt; print &quot;&lt;input type=\&quot;submit\&quot; value=\&quot;Submit to column &#39;Artikel&#39;.\&quot;<br/>&gt; disabled&gt;<br/>&gt; &lt;input type=\&quot;reset\&quot; value=\&quot;Input lagi?\&quot; disabled&gt;&quot;;<br/>&gt; print &quot; &lt;/form&gt; &quot;;<br/>&gt; print &quot;&lt;/td&gt;&lt;/tr&gt;&quot;;<br/>&gt;<br/>&gt; my $output_file = &quot;../../artikel/$url&quot;;<br/>&gt; my ($bytesread, $buffer);<br/>&gt; my $numbytes = 2000;<br/>&gt; open (OUTFILE, &quot;&gt;&quot;, &quot;$output_file&quot;)<br/>&gt; or die &quot;Couldn&#39;t open $output_file for writing: $!&quot;;<br/>&gt; while ($bytesread = read($url, $buffer, $numbytes)) {<br/>&gt; print OUTFILE $buffer;<br/>&gt; }<br/>&gt; close OUTFILE;<br/>&gt;<br/>&gt; print &quot;&lt;/table&gt;&quot;;<br/>&gt; print &quot;&lt;/font&gt;&lt;/body&gt;&quot;;<br/>&gt; print &quot;&lt;/html&gt;&quot;;<br/>&gt; --<br/>&gt; Patrik Hasibuan<br/>&gt; Junior Programmer<br/>&gt; http://www.penguin-teknologi.com<br/>&gt;<br/>&gt; --<br/>&gt; To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org<br/>&gt; For additional commands, e-mail: beginners-cgi-help@perl.org<br/>&gt; http://learn.perl.org/<br/>&gt;<br/>&gt;<br/>&gt;<br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13142.html Sun, 13 Jan 2008 05:38:25 +0000 Re: perl for uploading file shows weird characters. (1 message) [ please do not multi-post! ]<br/><br/>Patrik Hasibuan wrote:<br/>&gt; I am writing perl-cgi application for uploading a file. I did &quot;chmod <br/>&gt; 777 ../../artikel&quot;. But I get weird displayed message:<br/>&gt; &quot;<br/>&gt; ueri: ------------4CyrMz2ZeGIClwYfFsVdcv Co........<br/>&gt; &icirc; 6&ecirc;&Icirc;]&Euml; k&scaron;f&thorn;x&icirc;&pound;&circ;&middot;&frac34; &eth;fS4M3&gt;&ordm; {&frac12;&Dagger;&lt;&Oacute;&ouml;&ugrave;&sup3;&reg;&#xFFFD;&macr;3&ccedil;&yacute;G&egrave;B&ugrave;= &bdquo;&not;&Egrave;&rsaquo;&oslash;R&fnof;.....<br/>&gt; &amp;&fnof; &yuml;&fnof;&amp;m&Dagger;&icirc;&oslash;&#39;-n n&Ecirc;&ETH;J(p&Ccedil; 9&ccedil;q&icirc;&Icirc;.........<br/>&gt; &Ecirc; &uml;&sbquo;&iexcl;&Agrave;&Uuml; E&Ouml;&#xFFFD;&Acirc; z!&ordf;&tilde;Y6&#xFFFD;&not;&uacute;&Ograve;&bdquo;&acirc;0J&frac14;&ldquo;&ntilde;&Euml;.......<br/>&gt; [end so on. very longg.............]<br/>&gt; &quot;.<br/>&gt; <br/>&gt; And no file copied/uploaded in &#39;../../artikel&#39;. But inserting the record onto <br/>&gt; the mysql run properly.<br/>&gt; <br/>&gt; Please tell me why.....<br/>&gt; <br/>&gt; Here I have done:<br/><br/>Well, the code you posted is far too much to my taste. Please post a <br/>_small_ but complete program that illustrates the problem you are having.<br/><br/>-- <br/>Gunnar Hjalmarsson<br/>Email: http://www.gunnar.cc/cgi-bin/contact.pl<br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13141.html Sat, 12 Jan 2008 15:31:22 +0000 uploading a file with perl--->kueri: ------------4CyrMz2ZeGIClwYfFsVdcv Content-Disposition: form-data; name="level" asda ------------4CyrMz2ZeGIClwYfFsVdcv Content-Disposition: form-data; name="major" asda ------------4CyrMz2ZeGIClwYfFsVd....[very long w (1 message) Dear my friends...<br/><br/>I am still new in perl.<br/><br/>I am writing perl-cgi application for uploading a file. I did &quot;chmod <br/>777 ../../artikel&quot;. But I get weird displayed message:<br/>&quot;<br/>ueri: ------------4CyrMz2ZeGIClwYfFsVdcv Co........<br/>&Atilde;&reg; 6&Atilde;&ordf;&Atilde;&#142;]&Atilde;&#139; k&Aring;&iexcl;f&Atilde;&frac34;x&Atilde;&reg;&Acirc;&pound;&Euml;&#134;&Acirc;&middot;&Acirc;&frac34; &Atilde;&deg;fS4M3&gt;&Acirc;&ordm; {&Acirc;&frac12;&acirc;&#128;&iexcl;&lt;&Atilde;&#147;&Atilde;&para;&Atilde;&sup1;&Acirc;&sup3;&Acirc;&reg;&iuml;&iquest;&frac12;&Acirc;&macr;3&Atilde;&sect;&Atilde;&frac12;G&Atilde;&uml;B&Atilde;&sup1;= &acirc;&#128;&#158;&Acirc;&not;&Atilde;&#136;&acirc;&#128;&ordm;&Atilde;&cedil;R&AElig;&#146;.....<br/>&amp;&AElig;&#146; &Atilde;&iquest;&AElig;&#146;&amp;m&acirc;&#128;&iexcl;&Atilde;&reg;&Atilde;&cedil;&#39;-n n&Atilde;&#138;&Atilde;&#144;J(p&Atilde;&#135; 9&Atilde;&sect;q&Atilde;&reg;&Atilde;&#142;.........<br/>&Atilde;&#138; &Acirc;&uml;&acirc;&#128;&#154;&Acirc;&iexcl;&Atilde;&#128;&Atilde;&#156; E&Atilde;&#150;&iuml;&iquest;&frac12;&Atilde;&#130; z!&Acirc;&ordf;&Euml;&#156;Y6&iuml;&iquest;&frac12;&Acirc;&not;&Atilde;&ordm;&Atilde;&#146;&acirc;&#128;&#158;&Atilde;&cent;0J&Acirc;&frac14;&acirc;&#128;&#156;&Atilde;&plusmn;&Atilde;&#139;.......<br/>[end so on. very longg.............]<br/>&quot;.<br/><br/>And no file copied/uploaded in &#39;../../artikel&#39;. But inserting the record onto <br/>the mysql run properly.<br/><br/>Please tell me why.....<br/><br/>Here I have done:<br/>deartikel.cgi--&gt;cgideartikel.cgi--&gt;cgiuploadfile.cgi (&#39;--&gt;&#39; means &#39;calls&#39;).<br/>===<br/>deartikel.cgi:<br/>---<br/>#!/usr/bin/perl -w<br/>#use strict;<br/>use CGI qw(:standard);<br/>use CGI::Carp qw(warningsToBrowser fatalsToBrowser);<br/><br/>print &quot;Content-type: text/html\n\n&quot;;<br/>print &quot;&lt;html&gt;&quot;;<br/>print &quot;&lt;head&gt;&quot;;<br/>print &quot;&lt;/head&gt;&quot;;<br/>print &quot;&lt;body&gt;&lt;font style=\&quot;Arial,Arial Black,Helvetica\&quot; size=1&gt;&quot;;<br/>print &quot; &lt;form method=\&quot;post\&quot; action=\&quot;cgideartikel.cgi\&quot;&gt; &quot;;<br/>print &quot;Title of file &lt;input type=\&quot;text\&quot; name=\&quot;judul\&quot; size=60 <br/>autocomplete=\&quot;ON\&quot;&gt; &quot;;<br/>print &quot;&lt;input type=\&quot;submit\&quot; value=\&quot;Submit to column &#39;Articles&#39;.\&quot;&gt;<br/> &lt;input type=\&quot;reset\&quot; value=\&quot;Input lagi?\&quot;&gt;<br/>print &quot; &lt;/form&gt; &quot;;<br/>print &quot;&lt;/body&gt;&quot;;<br/>print &quot;&lt;/html&gt;&quot;;<br/>===<br/>cgideartikel.cgi:<br/>---<br/>#!/usr/bin/perl -w<br/>use CGI qw(:standard);<br/>use CGI::Carp qw(warningsToBrowser fatalsToBrowser);<br/>use DBI;<br/><br/>print &quot;Content-type: text/html\n\n&quot;;<br/>print &quot;&lt;html&gt;&quot;;<br/>print &quot;&lt;head&gt;&quot;;<br/>print &quot;&lt;title&gt;&quot;;<br/>print &quot;Online Science Org - Data entry kolom karir.&quot;;<br/>print &quot;&lt;/title&gt;&quot;;<br/>print &quot;&lt;/head&gt;&quot;;<br/>print &quot;&lt;body&gt;&lt;font style=\&quot;Arial,Arial Black,Helvetica\&quot; size=1&gt;&quot;;<br/>$pjg=$ENV{&quot;CONTENT_LENGTH&quot;};<br/>read(STDIN, $kueri, $pjg);<br/>#print &quot;kueri: $kueri&lt;br&gt;&quot;;<br/>@arr_prm=split(&quot;&amp;&quot;,$kueri);<br/>foreach $myprm(@arr_prm){<br/> ($namavar,$nilaivar)=split(&quot;=&quot;,$myprm);<br/> $assprm{$namavar}=$nilaivar;<br/>}<br/>$i=0;<br/>foreach my $nv(keys %assprm){<br/>print &quot;$nv &lt;br&gt;&quot;;<br/>print &quot;$assprm{$nv} &lt;br&gt;&quot;;<br/>print &quot;i = $i &lt;br&gt;&quot;;<br/>$i++;<br/>}<br/><br/>$judul=$assprm{&#39;judul&#39;};<br/>print &quot; &lt;form method=\&quot;post\&quot; action=\&quot;cgiuploadartikel.cgi\&quot; <br/>enctype=\&quot;multipart/form-data\&quot;&gt; &quot;;<br/>print &quot;Judul&lt;input type=\&quot;text\&quot; name=\&quot;judul\&quot; size=60 autocomplete=\&quot;ON\&quot; <br/>value=\&quot;$judul\&quot; readonly&gt; &quot;;<br/>print &quot;File untuk di-upload&quot;;<br/>print &quot; &lt;input type=\&quot;file\&quot; name=\&quot;url\&quot; size=60 autocomplete=\&quot;ON\&quot;&gt; &quot;;<br/>print &quot;&lt;input type=\&quot;submit\&quot; value=\&quot;Submit to column &#39;Artikel&#39;.\&quot;&gt;<br/> &lt;input type=\&quot;reset\&quot; value=\&quot;Input lagi?\&quot;&gt;&quot;;<br/>print &quot; &lt;/form&gt; &quot;;<br/>print &quot;&lt;/body&gt;&quot;;<br/>print &quot;&lt;/html&gt;&quot;;<br/>&amp;simpan(judul);<br/><br/>sub simpan{<br/>my $myjudul=shift;<br/>my $box=&quot;localhost&quot;;<br/>my $basisdata=&quot;mydb&quot;;<br/>my $db_user_name=&#39;root&#39;;<br/>my $db_password=&#39;mypw&#39;;<br/>my $dsn=&quot;DBI:mysql:$basisdata:$box&quot;;<br/><br/>my $dbh = DBI-&gt;connect($dsn, $db_user_name, $db_password);<br/>my $sqlstr=qq{<br/> insert into <br/> artikel (<br/> judul,<br/> )<br/> values(<br/> &#39;$myjudul&#39;<br/> )<br/>};<br/>my $sth = $dbh-&gt;prepare($sqlstr);<br/>my $status=$sth-&gt;execute();<br/>if($status){<br/> $sth-&gt;{Commit};<br/>}else{<br/> $sth-&gt;{RollBack};<br/>}<br/>$dbh-&gt;disconnect;<br/>}<br/>---<br/>cgiuploadfile.cgi:<br/>---<br/>#!/usr/bin/perl -w<br/>use CGI qw(:standard);<br/>use CGI::Carp qw(warningsToBrowser fatalsToBrowser);<br/>print &quot;Content-type: text/html\n\n&quot;;<br/>print &quot;&lt;html&gt;&quot;;<br/>print &quot;&lt;head&gt;&quot;;<br/>print &quot;&lt;title&gt;&quot;;<br/>print &quot;Online Science Org - Data entry kolom karir.&quot;;<br/>print &quot;&lt;/title&gt;&quot;;<br/>print &quot;&lt;/head&gt;&quot;;<br/>print &quot;&lt;body&gt;&quot;;<br/><br/>$pjg=$ENV{&quot;CONTENT_LENGTH&quot;};<br/>read(STDIN, $kueri, $pjg);<br/>print &quot;kueri: $kueri&lt;br&gt;&quot;;<br/>exit;<br/>@arr_prm=split(&quot;&amp;&quot;,$kueri);<br/>foreach $myprm(@arr_prm){<br/> ($namavar,$nilaivar)=split(&quot;=&quot;,$myprm);<br/> $assprm{$namavar}=$nilaivar;<br/>}<br/>$i=0;<br/>foreach my $nv(keys %assprm){<br/> print &quot;$nv &lt;br&gt;&quot;;<br/> print &quot;$assprm{$nv} &lt;br&gt;&quot;;<br/> print &quot;i = $i &lt;br&gt;&quot;;<br/> $i++;<br/>}<br/><br/>$judul=$assprm{&#39;judul&#39;};<br/>$url=$assprm{&#39;url&#39;};<br/>print &quot; &lt;form method=\&quot;post\&quot; action=\&quot;cgiuploadartikel.cgi\&quot; <br/>enctype=\&quot;multipart/form-data\&quot;&gt; &quot;;<br/>print &quot; &lt;input type=\&quot;text\&quot; name=\&quot;judul\&quot; size=60 autocomplete=\&quot;ON\&quot; <br/>value=\&quot;$judul\&quot; readonly&gt; &quot;;<br/>print &quot;File untuk di-upload&quot;;<br/>print &quot; &lt;input type=\&quot;file\&quot; name=\&quot;url\&quot; size=60 autocomplete=\&quot;ON\&quot; <br/>readonly&gt; &quot;;<br/>print &quot;&lt;input type=\&quot;submit\&quot; value=\&quot;Submit to column &#39;Artikel&#39;.\&quot; disabled&gt;<br/> &lt;input type=\&quot;reset\&quot; value=\&quot;Input lagi?\&quot; disabled&gt;&quot;;<br/>print &quot; &lt;/form&gt; &quot;;<br/>print &quot;&lt;/td&gt;&lt;/tr&gt;&quot;;<br/><br/>my $output_file = &quot;../../artikel/$url&quot;;<br/>my ($bytesread, $buffer);<br/>my $numbytes = 2000;<br/>open (OUTFILE, &quot;&gt;&quot;, &quot;$output_file&quot;) <br/> or die &quot;Couldn&#39;t open $output_file for writing: $!&quot;;<br/>while ($bytesread = read($url, $buffer, $numbytes)) {<br/> print OUTFILE $buffer;<br/>}<br/>close OUTFILE;<br/><br/>print &quot;&lt;/table&gt;&quot;;<br/>print &quot;&lt;/font&gt;&lt;/body&gt;&quot;;<br/>print &quot;&lt;/html&gt;&quot;;<br/>-- <br/>Patrik Hasibuan<br/>Junior Programmer<br/>http://www.penguin-teknologi.com<br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13140.html Sat, 12 Jan 2008 14:55:41 +0000 How to select from a popup_menu without clicking submit? (6 messages) Hi!<br/><br/>I wonder if there is any way in Perl CGI that you can select an item in<br/>a popup menu and execute a command WITHOUT having to click a submit<br/>button? For instance, this is what I want to do:<br/><br/>I have a popup_menu with names of several values.<br/>print $cgi-&gt;popup_menu(-name=&gt;&#39;list&#39;,<br/> -id=&gt;&#39;list&#39;,<br/> -values=&gt;[&#39;L1&#39;,&#39;L2&#39;,&#39;L3&#39;]);<br/><br/>As soon as the user selects a value I want it to be automatically<br/>printed out.<br/><br/>if ($cgi-&gt;param(&#39;list&#39;)) {<br/> print &quot;Selected value: &quot;.$cgi-&gt;param(&#39;list&#39;);<br/>}<br/><br/>This is a very basic thing if you allow a submit button, but I don&#39;t<br/>want to do that. Any ideas?<br/><br/>Thanks in advance!<br/>Marcus<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13131.html Mon, 07 Jan 2008 00:46:56 +0000 What is the function value in perl? (6 messages) Hi all, Can any body teach me how to input the function key in perl?<br/>such as &quot;Esc&quot;, F1, F2, F3, F4&quot;.......<br/>I&#39; m programming something with perl to work with IBM AS400 system,<br/>and it needs to input some key like F3, F9......<br/><br/>Thanks!!<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13129.html Fri, 04 Jan 2008 13:18:25 +0000 Perl 6 (1 message) I was browsing Perl.com and read a bit of Larry Wall&#39;s &quot;State of the <br/>Onion&quot;. In it he mentions, &quot;It has some issues, but in the long run <br/>JavaScript might actually turn out to be a decent platform for running <br/>Perl 6 on.&quot;<br/><br/>What does that mean?<br/><br/>--<br/>Bill Stephenson<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2008/01/msg13128.html Fri, 04 Jan 2008 09:55:28 +0000 CGI query and FORM (2 messages) Hi All,<br/><br/>I m creating the session in the Perl. all the functions are done in a<br/>single file. the operations are performed by the command line<br/>arguments.<br/><br/>for managing the session i m using the CGI. but when i create a CGI<br/>object then all the Input from both POST and GET methods are parsed by<br/>it. i m not able to get the varbale values using FORM. My work is the<br/>enhancemet work so if i change all the FORM varible to CGI query then<br/>its huge task. Is there any way to get the session info from the FORM<br/>Variable...<br/><br/>This comes first of all the lines in my cgi file. so it parse all the<br/>POST and GET methods..<br/>i m not able to the values from FORM varible..<br/><br/>$query = new CGI;<br/>$sid = $query-&gt;cookie(&#39;CGISESSID&#39;) || $query-&gt;param(&#39;CGISESSID&#39;) ||<br/>undef;<br/><br/>after the abouve line<br/>if ($FORM{&#39;lab&#39;} eq &quot;pager&quot;) {<br/><br/>plz help me in getting this problem. Is there any way to get session<br/>info from the FORM variable..<br/><br/>Thanks,<br/>Prakash.<br/><br/> http://www.nntp.perl.org/group/perl.beginners.cgi/2007/12/msg13126.html Thu, 13 Dec 2007 22:24:37 +0000