Re: Problem with uploader
On Tue, 2008-11-18 at 10:49 -0500, Adam Jimerson wrote: Matthew Whipple wrote: The open must have failed. You could work on getting a more descriptive error message but I'd suggest starting with the the path and permissions. Also check to make sure existing files are handled properly. Make sure the path used is relative to its environment (if the server is chrooted or anything). If the open failed then wouldn't the die kick in and at least say something in the server logs? Also how would one go around and get a more descriptive error message? For testing reasons the path is pointing to /tmp which is world readable and writable, as for the file it seems the script is looking for something other than what I want rereading my logs I found this: Sorry I glanced at the wrong open statement regarding the above advice. You may however want to use the cgi_error function to catch some potential problems with uploaded data. upload: print() on closed filehandle OUTFILE at /srv/www/cgi-bin/upload line 47, fh1myfile.html line 46. What is with the fh1 in front of the file? The CGI module creates a temporary file for the uploaded file before it is handled by your script (which would likely result in a filename like above). It may be with this implicit step that you're having problems. Check options and permissions. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Problem with uploader
On Sun, 2008-11-16 at 21:31 -0500, Adam Jimerson wrote: On Sunday 16 November 2008 9:10:19 pm you wrote: You'll want to look in the error log to see what is there. Sean All the Apache error logs says is print () on closed Filehandle OUTFILE at /srv/www/cgi-bin/upload line 46, but I do have the filehandle open in the script. The open must have failed. You could work on getting a more descriptive error message but I'd suggest starting with the the path and permissions. Also check to make sure existing files are handled properly. Make sure the path used is relative to its environment (if the server is chrooted or anything). -- We must plan for freedom, and not only for security, if for no other reason than only freedom can make security more secure. Karl Popper -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Problem with uploader
Running it locally prints out the generated HTML and it looks right and the page does open correctly on my server but there is not file in /tmp and the mail is never sent and I don't know if it is a problem with opening the OUTFILE handle because the die command doesn't kick in from what I can see. The die message would most likely be written into the server's log. A quick fix to more easily get the error messages would be using CGI::Carp, a use CGI::Carp qw(fatalsToBrowser) should show you the error on the page. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: perl-cgi and apache configuration in fedora 9
On Fri, 2008-11-14 at 22:58 +0530, venu madhav reddy wrote: Hello, please help me I am using fedora 9 plese tell me how to configure apache and perl-cgi in fedora 9 apache and perl are in built with fedora just tell me how to modify perl.conf file to run cgi progams. You most likely need to configure Apache, not perl. http://httpd.apache.org/docs I normally use the XBitHack Thanks in advance -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: using cgi.pm to create and interpret textboxes
On Tue, 2008-11-11 at 03:19 -0800, marys wrote: Hello: Can anyone tell me how to use CGI.pm's 'textfield' function to set up a form with a lot of fill-in fields and then parse them? I tried to read three values from input boxes but the output seems to be the name of the textbox and not its value. Here are two scripts: (1) a.cgi: #!/usr/bin/perl -wT use CGI::Carp qw(fatalsToBrowser); use CGI ':standard'; use strict; use diagnostics; my $z = new CGI; print $z-header; print $z-start_html; print $z-h2(Please indicate the length of each leg of the triangle:),\n; print $z-startform(-method=POST,-action=action.cgi); my @leglength; my @leg; foreach (0..2){ print $z-h2($leg[$_], ,textfield(leglength[$_])); } I would suggest for clarity you may want to either stick to the OO style or the functional style or at least have a reason for division print $z-h2($leg[$_], ,$z-textfield(leglength[$_])) print $z-submit('Submit'); print $z-end_html; _ (2) action.cgi: #!/usr/bin/perl -wT use CGI::Carp qw(fatalsToBrowser); use CGI ':standar'; use strict; use diagnostics; my $q = new CGI; my @param=param();#these are the contents from textboxes on previous page params is a hash and I don't think you want to convert it to an array (param is a method which I don't think should be accessed this way) If you do then only the odd numbers will correspond to the values (the evens being the names/keys). I'd suggest for now you continue to just access the values through the CGI object ($q-param(...)). print $q-header; print $q-start_html; my @leglenth; my @param=param(); my $z; my $a=-1; foreach(0..2){ $a+=1; $leglenth[$a] = $param[$a]; } my $numelements=scalar(@leglenth); print $q-h2(The number of elements in array [EMAIL PROTECTED] is $numelements\n); foreach (@leglenth){ print $q-h2(\$leglenth[$_] is $_ \n); } print $q-h2([EMAIL PROTECTED] is @leglenth \n); print $q-end_html; _ I illustrated the problem with just three fill-in fields, but I will need many more. The output of the print statements in the file 'action.cgi' is that each element listed has the name of the element, e.g. leg[0] , not the value filled in. I can pass the values through if I individually label each input box in the input script, but it gets very sloppy and tedious to do it that way. Does anyone know if it can be done the way I tried? Thank you in advance. Mary -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Sorting a hash
On Mon, 2008-06-02 at 11:53 -0700, Iain Adams wrote: Hello, I am trying to sort a hash of hashes. my code looks like this foreach $cnt (sort keys %{ $relations{ $uid }{ instances } }){ print OUT $cnt 1, ; } This prints out the correct numbers (the keys of the instances hash. However the sorting is a bit weird. The keys are all integers yet when sorting the keys aren't put in number order. instead the first digit is seen as the qualifier. You're sorting lexically and looking for numerically. perldoc -fsort Here is an example output: 100 1, 120 1, 121 1, 122 1, 123 1, 124 1, 125 1, 126 1, 127 1, 132 1, 133 1, 134 1, 135 1, 136 1, 137 1, 138 1, 139 1, 221 1, 222 1, 223 1, 224 1, 225 1, 226 1, 227 1, 228 1, 235 1, 236 1, 237 1, 238 1, 239 1, 240 1, 241 1, 242 1, 323 1, 324 1, 325 1, 326 1, 327 1, 328 1, 329 1, 330 1, 50 1, 51 1, 52 1, 53 1, 54 1, 55 1, 56 1, 57 1, 93 1, 94 1, 95 1, 96 1, 97 1, 98 1, 99 1, As you can see it is not in normal order. Does anyone know why this is happening and how I can fix it? Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Could not open testfile.txt: No such file or directory
On Fri, 2008-05-30 at 13:04 +0100, Mimi Cafe wrote: Still cannot see why Perl complains that Could not open file for reading. File or directory does exist. I have modified my script and now using Getopt::Long module instead of the @ARGV variable. Can someone take a look? The script is now run with command line options like this: myscript --master --compare file_name --compare another_file Are you missing a file_name in that command template? Does this work when you hard code the filenames? When you use full pathnames or fully qualified relative paths? Does this work with only a single compare option? #foreach (@compare_lists){print $_\n;} # This prints the CLI arguments correctly. # You may want to use a more visible delimiter to ensure that there's no whitespace issues. my $outputdir = DEFAULT_REPORTDIR; unless (-d $outputdir){ mkdir ($outputdir) or die could not create dir for $outputdir: $!\n; } # Read the master list and populate our array. open (MASTERFILE, , $master_list) or die Could not open $master_list for reading: $!\n; my @master_clients = MASTERFILE; close MASTERFILE; ## #print master list starts below:\n; #foreach (@master_clients){print $_\n;}exit; ## my (%inputclient,$list); # Read the other files and compare the content to the master client list. foreach $list (@compare_lists){ # Output file name set of element curerently processed. # Open file to read from. open(INPUTFH, , $list) or die Could not open $list for reading: $!\n; # Could not open file for reading. File or directory does exist. while (INPUTFH){ chomp; $inputclient{s_} = $_; } close INPUTFH; #$outputfile = NOT_IN . $outputfile; my $outputfile = $list; my (@missing_clients, %outputclient); open (OUTPUTFILE, , $outputfile) || die Could not open $outputfile: $!\n; foreach my $aditem (@master_clients){ push (@missing_clients, $aditem) unless exists $inputclient{$aditem}; } On 29/05/2008, Mimi Cafe [EMAIL PROTECTED] wrote: I am on Windows so it should not be case-sensitive. The script and all required files in one folder. I pass 3 arguments to the script (script.pl file1 file2 file3)and I can open the first file stored in $ARGV[0] as seen below: my $ad_clients = shift @ARGV; open (ADFILE, , $ad_clients) or die Could not open $ad_clients for reading: $! \n; # This works fine! my @ad_clients = ADFILE; close ADFILE; my %inputclient; foreach my $supplied (@ARGV){ open (INPUTFILE, , $supplied) or die Could not open $supplied for reading: $!\n # This does not works! Error: No such file or directory Mimi On 29/05/2008, Ken Foskey [EMAIL PROTECTED] wrote: On Thu, 2008-05-29 at 11:45 +0100, Mimi Cafe wrote: my script is in the same directory as my files, but it cannot find the file ABC.txt in open() below. foreach my $supplied (@ARGV){ # Output file name set of element currently processed. # Open file to read from. open (INPUTFILE, , $supplied) or die Could not open $supplied: $!\n; # Error: No such file or directory. } Any help Mimi for starters you might want to look at the operator: while( ) { } Will read each file on the command line in sequence, saves you thinking about it. If it is Unix it is case sensitive, is this your problem? Are you actually in the directory? `bin/myscript.pl bin/ABC.txt` -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: parsing SQL statement
On Fri, 2008-05-30 at 19:24 +0700, beast wrote: Anyone having suggestion parsing SQL statement? It should able to parse: BLA BALA BALA... VALUES( 'abcd efg',,999, 'some \STRING\ and \'STR2\' STR3' 'abcd, def, fghi' ) I'm using tr and then split by , but it will fall when seeing comma inside the single quote. I'm actually about to look into a SQL parsing solution myself. There appear to be several modules on CPAN which should be at least a good place to start. Thanks. --budhi -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: learning perl 3rd vs 4th
On Sun, 2008-05-25 at 10:07 -0700, AndrewMcHorney wrote: Hello I have been reading files with the following command: @source_lines = (SOURCE_FILE); You'd want to use $source_line = SOURCE_FILE to get a single record at a time from the handle This has worked until I started reading some very large files. Is there a better way to read files? The files I am trying to read now are about 300 megabytes in size. The bad news is that the spec has no carriage returns or line feeds. perldoc perlvar - Check the section on the input record seperator We have no control over the spec. I need to replace a few characters in the file. Andrew If you need more precise control also look into the IO Modules -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Perl beginner seeks help
On Tue, 2008-05-20 at 22:30 -0700, Mr. low level newb of stupidity ;) wrote: hello, I am a, well, not a beginner per say, but rather still a learner of Perl. I guess you could call me a beginner. anyway, I need some help with my robot. it is not really Perl help, but you guys could help with the code, too. I am making a talking robot like A.L.I.C.E., a robot designed by a guy named Richard s. Wallace, and I am having trouble deciding what to make him know. he knows basic stuff, and the coding is somewhat fine, but I was wondering if you guys could help me out here. he knows how to respond to his and hellos, also more interesting stuff like his birthday and to understand when you say something like 'I feel like crap' or something, but he is still kinda dumb. any advice on how to improve him with knowledge would be appreciated. I think ALICE or one of the related projects uses a markup language (something along the lines of AIML) which facilitates storage and retrieval of information (and I'd guess things like pattern matching). You may want to start there and then incorporate that into your Perl. P.S. the code for what to say and what to say it to is regular expressions. tell me if you have a better method. e.g.elsif($reply =~ /\bwhat\b/ and $reply =~ /\btime\b/){ printI surely dont know the time.; talk(); } talk is the subroutine that asks for input. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: question regarding how to launch perl script on remote machine
On Mon, 2008-05-19 at 21:55 +0800, Jeff Peng wrote: On Mon, May 19, 2008 at 11:22 AM, Richard Lee [EMAIL PROTECTED] wrote: I have thought of writing a simple shell script which launchs a (from SERVERK)ssh session into linux machines using user name with initial script to run a perl script and logs off.. Is this possible? I don't think so. This will run the script on that remote linux host, not the current solaris host. It sounded as though he wanted to run the script on the Linux machine, not the server...perhaps remotely storing login information which could be retrieved from the server's environment before initiating the SSH connection. -- Jeff Peng - [EMAIL PROTECTED] Professional Squid supports in China http://www.ChinaSquid.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: question regarding how to launch perl script on remote machine
On Mon, 2008-05-19 at 22:08 +0800, Jeff Peng wrote: On Mon, May 19, 2008 at 10:01 PM, Matthew Whipple [EMAIL PROTECTED] wrote: It sounded as though he wanted to run the script on the Linux machine, not the server... That was maybe not correct. Given the case that he say something like this in his script: open $pwd, /etc/passwd or die $!; This will open the linux's password file, not the solaris's. That would depend upon which side that command was executed. Keep in mind that he had mentioned a script that would iniate the SSH connection from the Solaris computer and could retrieve data from that computer which could then be passed over the connection. I unfortunately no longer have the original message and don't have time to find it, but I had noticed that one of the problem modules he was having was DBI so I was supposing he was looking to store login information in a DB. In that case he would be able to gather login information on the SERVERK computer before initiating the SSH connection and passing the information to a script which would handle any functionality not presently supported on SERVERK (not to be confused with permission). The only person to answer this is the OP, and he may not if the alternative module installation prefix works for him. If that was really he wanted originally, then using Net::SSH::Expect has no problems. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: IDE for Perl in Linux
Dr.Ruud wrote: Rodrigo Tavares schreef: Anybody knows a simple and good IDE Perl for Linux ? http://e-p-i-c.sourceforge.net/ I'd been using gvim but have recently decided to invest in getting familiar with the eclipse framework (which that link would be part of) since the extensibility and feature set certainly promise to make it a worthwhile investment. I'd say basic familiarity with vi is a strong recommendation regardless of your editor of choice. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: sort without ignoring hyphens
LC_ALL=C sort echo.txt [EMAIL PROTECTED] wrote: On Mar 29, 3:19 pm, [EMAIL PROTECTED] (John W. Krahn) wrote: [EMAIL PROTECTED] wrote: When I do string comparisons in perl the strings seem to ignore the embedded hyphens. I want to sort strings assuming the 'dictionary' order of the chars is ASCII order: hypen, 0-9, A-Z. It appears linux sort also has the problem (LC_ALL is blank). Any ideas? I want to avoid a brute force char by char sort if possible. Please provide an *example* of your data, what it would look like if sorted properly, and what it actually looks like after being sorted. John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall Given my data: (echo.txt) 21A 22A 2-4A 2-2A 23A 2-3A 08E 08F 08G 08GA 08H 08-J I want perl (and linux sort) to see its order as: 08-J 08E 08F 08G 08GA 08H 2-2A 2-3A 2-4A 21A 22A 23A However (on my system): 1) linux sort: sort echo.txt produces the undesired result: 08E 08F 08G 08GA 08H 08-J 21A 22A 2-2A 23A 2-3A 2-4A 2) linux sort with -n: sort -n echo.txt produces the undesired result: 2-2A 2-3A 2-4A 08E 08F 08G 08GA 08H 08-J 21A 22A 23A 3) perl's sort produces the DESIRED result perl -le'@x = qw[21A 22A 2-4A 2-2A 23A 2-3A 08E 08F 08G 08GA 08H 08- J]; print for sort @x' 08-J 08E 08F 08G 08GA 08H 2-2A 2-3A 2-4A 21A 22A 23A So, how do I write a perl script to use in place of linux sort since perl's sort produces the desired results? I want perlsort to accept input from STDIN or a filename as an argv. I don't care about any command line options since perl seems to do exactly what I desire. (I thought perl's comparisons were wrong because I used files sorted by linux sort, my mistake.) My files are significantly larger than physical memory. Any help is appreciated. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: readdir formulated badly? gives wrong count
[EMAIL PROTECTED] wrote: Jeff Pang [EMAIL PROTECTED] writes: On Dec 3, 2007 12:51 PM, [EMAIL PROTECTED] wrote: Jeff Pang [EMAIL PROTECTED] writes: mhh? It won't print a newline, it even won't print anything. b/c @ar is empty, for(...) doesn't go into it, 'print' won't be happened. Yeah your right... (what was I thinking...) but my point was that it seems perl should say something about this. It seams at least as significant as trying to use an undeclared var. which value was undeclared? the $_ one? this is a built-in variable in perl, it doesn't need to be declared. anyway, you didn't use an undeclared value, so perl won't warn it. No, no, I didn't make myself clear. I'm saying running into a for loop array that has no value seems to me to be at least as significant as running into a variable that is undeclared. But the undeclared var will invoke a warning while the empty AR in a for loop will not. But someone has already answered that Larry Wall and all the perl devel people have run into many places were choice had to be made about issuing warning The empty for loop didn't make the cut. The for loop is a conditional loop, a derivative of the simpler do/while loops. The syntax makes it a bit harder to recognize it as such, particularly when used in the foreach type of test loop rather than the long format. It is therefore more comparable to a conditional that is never true than an undeclared variable. That's misleading in this case, though, since it would often be true, it's more comparable to a standard conditional which I can't imagine you'd expect an error from when it tests false. The flow of the program through conditionals and control structures is a complex and variable enough process that for a computer to accurately warn about it's misuse would likely require that the computer actually understand what you're doing to do. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: readdir formulated badly? gives wrong count
Rob Dixon wrote: Matthew Whipple wrote: The for loop won't execute if it has nothing through which to iterate. On my system the for won't execute with an empty list, but will once when the array is undefined. Changing the above to 'if (defined(@DirContent)) {' would be a bit clearer. Now what would you mean by an array being undefined? If you write @a = undef; That's what I had done, my mistake. I don't use it but I didn't know it was wrong and was speculating that it may be used as a return value from some functions (apparently just poorly written ones). you have assigned the single-element list (undef) to @a, which I wouldn't call being undefined. To empty an array you must write undef @a; or @a = () Even then it's stretching it a bit to say that the array is 'undefined', but at least there's nothing in it! HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: readdir formulated badly? gives wrong count
Rob Dixon wrote: Matthew Whipple wrote: The for loop won't execute if it has nothing through which to iterate. On my system the for won't execute with an empty list, but will once when the array is undefined. Changing the above to 'if (defined(@DirContent)) {' would be a bit clearer. Now what would you mean by an array being undefined? If you write @a = undef; you have assigned the single-element list (undef) to @a, which I wouldn't call being undefined. To empty an array you must write undef @a; or @a = () Even then it's stretching it a bit to say that the array is 'undefined', but at least there's nothing in it! Actually, after testing perl behavior again today, it's not even doing what I had said it did. I don't know what I did yesterday. I must have mixed up the right and the wrong way enough to make me think it worked. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: premature end of header script error
Ankur wrote: Hi, I am receiving the following error : Premature end of script headers when running my CGI script using a web browser. Instead if I execute the script manually at the shell, it executes successfully. Actually, the script needs to fetch a lot of data from the database. I couldn't find any related reference for this error description on the web, though there are a lot of other references. Any idea? Ankur Jain I think this error can also be the result of the web server not seeing the file as a script (check the location and/or extension of the script against the server configuration, alternately you could use the X bit hack if the web server is Apache). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: How can I sort files by timestamp without slurping?
icarus wrote: Thanks Rob and Martin for your inputs. I found a solution to my problem. I'm posting it here for whoever might need it. I'm sure there's a faster solution out there but this will do just fine. I had to put the files in an array. :( The reason is that you cannot sort a scalar [ or scalar context such as reading a dir using while (MYDIR) ] , it has to be an array. A scalar is fundamentally a single value. Sorting a single value is not particularly useful (I can't think of any alternate orderings aside from the one value first (or last if you're a pessimist)). Sorting a list of values is far more useful...arrays certainly also help but you could also keep things outside of arrays and purely in list context though it would likely involve a lot more typing and/or control structures. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: readdir formulated badly? gives wrong count
[EMAIL PROTECTED] wrote: Thanks for taking time to respong and go clear thru the script bit by bit. kens [EMAIL PROTECTED] writes: [...] # The following lines are your friend use strict; use warnings; I've seen that before but didn't understand why. The `warnings' part is clear enough but doesn't the -w flag do something similar? But why `strict'? http://www.perlmonks.org/?node=use%20strict%20warnings%20and%20diagnostics%20or%20die if(!$ARGV[1]){ usage(); print Too few arguments.. exiting\n; exit; } if($ARGV[2]){ usage(); print Too many arguments... exiting\n; exit;} use Cwd; my $Cwd = getcwd; use File::Copy; Define variables in the smallest scope Plus only define variables you use, otherwise it can get confusing my ($HiNum, $Copied, $TrgDir, @DirContent, $Cnt, $Line); $TrgDir = shift; $HiNum = 0; $Copied = 0; Is there something there, I don't use? I'm not seeing which one. [...] To declare in smallest scope: my @DirContent = grep { /^[0-9]/ } readdir($DIR); @DirContent = grep { /^[0-9]/ } readdir(DIR); Not to be obtuse but why is declaring in smallest scope important here? I know that is commonly offered as advice but I don't think I have seen any explanation as to why. This script is a helper script, so why is declaring variables like: my $var = value in the main part of the script a bad thing? That already limits the scope to this script which itself seems unnecessary. Like I could have just said: $var = value in the main part and been ok, I used `my' for the unlikely event I someday write something that references this script like a function to some other script by slurping it. I don't know enough perl to see why I need to make that declaration inside a function or internal loop or other more limited scope. That's not Perl, that's programming. It's good practice which, in addition to keeping things more organized, helps to eliminate problems down the road and optimize memory consumption. This test add nothing. The for loop will fail if there is no content if ($DirContent[0]){ Checking to make sure there are in fact numbered files already in TrgDir. As often as not it is a newly created and empty directory. If there aren't numbered files alread in it then no need for the for loop. So testing for value of $DirContent[0]) was supposed to bypass the for loop if it were empty of value. The for loop won't execute if it has nothing through which to iterate. On my system the for won't execute with an empty list, but will once when the array is undefined. Changing the above to 'if (defined(@DirContent)) {' would be a bit clearer. for(@DirContent){ Do these files only contain numbers? Yes. Note the argument to grep earlier /^[0-9]/. I guess that should have been /^[0-9]+/ but the directories to be copied from are populated by NNTP which always uses numbering. ## If we already have numbered files, Start our counter with ## the highest one if($HiNum){ $Cnt = $HiNum; } Then the above test (using the result of the for loop if not bypassed) is supposed to decide if we need to increase Cnt so as not to clobber any existing files. If HiNum is still zero then there weren't any in the TrgDir and no need to bump the Cnt up to protect them. while(){ chomp; $Cnt++ ; ## The first if clause here is unnecessary now... to be removed if($TrgDir){ ## Add the correct path if our line doesn't start with '/' Use different delimiters if searching for a slash Is that faster or somehow better than escaping the slash? if(!/^\//){ $Line = $Cwd ./. $_; [...] ## Report how many files were copied print $Copied Files copied to:\n $TrgDir\n\n; print .CountTrgDir().\n; should be closedir($DIR); close(DIR); The main problem, I believe, is that you are using a stale directory handle. closedir (in main) and opendir here. Ha... and that was the problem... turns out it doesn't need to be moved. Once the typeo is corrected to closedir(DIR); it works, with no reopen. [...] use File::Basename; sub usage { # use this line to get the name of your script # perldoc File::Basename my ( $myscript ) = fileparse( $0, ); [...] Usage: \`$myscript TARGETDIRECTORY SOURCEFILE' Somehow in the course of many edits these lines up near the top were lost. I insert them in most of my homeboy scripts for use in the usage function: my $myscript; ($myscript = $0) =~ s:^.*/::; Is it still better to pull in a whole new module (`use File::Basename;') to do that? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: help in if - else loop in perl
Sayed, Irfan (Irfan) wrote: Hi All, I am getting error while running following script.Error is due to improper if else loop and curly braces. Can you please guide me in placing the braces in right position and doing proper if..else looping My requirement is that I want to quit as soon as if condition fails.Please guide Whitespace is your friend. If you indent blocks it makes it much easier to figure out how the braces match up. I haven't actually looked too much at the code, but as already mentioned elses should only be at the end of conditionals.Also if you're trying to just use else to quit, it's normally more concise to negate the conditional test and exit there. Along the lines of: if ($menu_item != 1) { quit() }; (or the block-less inverted if when you're comfortable using it...it looks as though you should focus on the long way for now). if ($menu_item == 1) { $pvob=`$CT lsvob -s | grep apc`; chomp($pvob); my @proj=`$CT lsproj -invob $pvob | cut -d -f3`; [EMAIL PROTECTED]; print The projects are.\n\n; my $i=1; foreach my $line(@proj) { print \t . $i++ . . $line\n; } print Your Choice :\t; chomp($choice = STDIN); if ($choice $len) { print Your choice: $proj[$choice-1]\n; chomp($pro=$proj[$choice-1]); chomp($proj1=$pro . @ . $pvob); #print $proj1\n; my $int_str=`$CT desc -fmt %[istream]p project:$proj1`; } else { quit(); } elsif ($int_str eq ) { print This project does not have Integration stream , so quiting.\n; exit; } else{ print Integration Stream:$int_str\n; dev_strm(); } } else { quit(); } Regards Irfan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Regex Help
Omega -1911 wrote: which isn't an equivalent to yours - it simply makes sure that the record contains 'Powerball:' and at least one digit - but I'm sure it is adequate. My own solution didn't even do this much checking, since I read the OP as saying that all irrelevant data records had been removed. I appreciate the help as I am understanding the examples, but when I ran Dr. Rudd's example, I had weird data in the common array (Notice the number 440): I'd guess the first example didn't include the conditional checking the data format and there were some 440 HTTP errors while retrieving the data (obviously hinging on whether that applies to the data source, especially since it was initially specified as a web page rather than a web site). common : 120, 10, 07, 440, 6, 120, 7, 07, 440, 22, 120, 3, 07, 440, 1, 120, 31, 07, 440, 6, 120, 27, 07, 440, 13, 120, 24, 07, 440, 10, 120, 20, 07, 440, 10, 120, 17, 07, 440, 14, 120, 13, 07, 440, 21, 120, 10, 07, 440, 12, 120, 6, 07, 440, 8, 120, 3, 07, 440, 2, 120, 29, 07, 440, 31, 120, 26, 07, 440, 25, 120, 22, 07, 440, 4, 120, 19, 07, 440, 20, 120, 15, 07, 440, 13, 120, 12, 07, 440, 5, 120, 8, 07, 440, 7, 120, 5, 07, 440, 11, 120, 1, 07, 440, 12, 120, 29, 07, 440, 13, 120, 25, 07, 440, 2, 120, 22, 07, 440, 12, 120, 18, 07, 440, 12, 120, 15, 07, 440, 19, 120, 11, 07, 440, 1, 120, 8, 07, 440, 9, 120, 4, 07, 440, 2, 120, 1, 07, 440, 9, 120, 28, 07, 440, 15, 120, 25, 07, 440, 28, 120, 21, 07, 440, 14, 120, 18, 07, 440, 3, 120, 14, 07, 440, 1, 120, 11, 07, 440, 8, 120, 7, 07, 440, 15, 120, 4, 07, 440, 1, 120, 30, 07, 440, 24, 120, 27, 07, 440, 9, 120, 23, 07, 440, 14, 120, 20, 07, 440, 23, 120, 16, 07, 440, 4, 120, 13, 07, 440, 10, 120, 9, 07, 440, 7, 120, 6, 07, 440, 5, 120, 2, 07, 440, 2, 120, 30, 07, 440, 7, 120, 26, 07, 440, 1, 120, 23, 07, 440, 3, 120, 19, 07, 440, 3, 120, 16, 07, 440, 6, 120, 12, 07, 440, 30, 120, 9, 07, 440, 2, 120, 5, 07, 440, 13, 120, 2, 07, 440, 1, 120, 28, 07, 440, 16, 120, 25, 07, 440, 12, 120, 21, 07, 440, 22, 120, 18, 07, 440, 6, 120, 14, 07, 440, 12, 120, 11, 07, 440, 6, 120, 7, 07, 440, 2, 120, 4, 07, 440, 19, 120, 31, 07, 440, 2, 120, 28, 07, 440, 6, 120, 24, 07, 440, 10, 120, 21, 07, 440, 16, 120, 17, 07, 440, 7, 120, 14, 07, 440, 4, 120, 10, 07, 440, 14, 120, 7, 07, 440, 13, 120, 3, 07, 440, 1, 120, 28, 07, 440, 13, 120, 24, 07, 440, 36, 120, 21, 07, 440, 2, 120, 17, 07, 440, 1, 120, 14, 07, 440, 3, 120, 10, 07, 440, 2, 120, 7, 07, 440, 4, 120, 3, 07, 440, 12, 120, 31, 07, 440, 2, 120, 27, 07, 440, 10, 120, 24, 07, 440, 9, 120, 20, 07, 440, 1, 120, 17, 07, 440, 16, 120, 13, 07, 440, 1, 120, 10, 07, 440, 36, 120, 6, 07, 440, 1, 120, 3, 07, 440, 10, 120, 30, 06, 440, 9, 120, 27, 06, 440, 14, 120, 23, 06, 440, 8, 120, 20, 06, 440, 1, 120, 16, 06, 440, 5, 120, 13, 06, 440, 19, 120, 9, 06, 440, 19, 120, 6, 06, 440, 7, 120, 2, 06, 440, 17, 120, 29, 06, 440, 2, 120, 25, 06, 440, 5, 120, 22, 06, 440, 22, 120, 18, 06, 440, 1, 120, 15, 06, 440, 11, 120, 11, 06, 440, 35 powerball : 22, 29, 31, 16, 25, 11, 11, 15, 30, 16, 30, 4, 33, 27, 9, 25, 16, 24, 12, 20, 19, 16, 8, 37, 15, 22, 10, 16, 23, 16, 19, 35, 30, 9, 21, 20, 21, 2, 38, 11, 15, 31, 8, 13, 10, 9, 22, 23, 5, 11, 19, 7, 44, 13, 21, 8, 22, 13, 26, 10, 21, 15, 28, 30, 5, 20, 38, 24, 17, 27, 18, 16, 5, 20, 38, 8, 15, 26, 11, 22, 13, 15, 19, 19, 5, 35, 21, 42, 24, 12, 23, 16, 27, 6, 17, 32, 22, 34, 34, 8, 18, 32, 8, 28, 38 BUT, when I run his other example (see below), everything worked as well as the other examples you all supplied: while (DATA) { if (my @numbers = /(\d+), (\d+), (\d+), (\d+), (\d+), Powerball: (\d+)/) { push @common, @numbers[0..4]; push @powerball, $numbers[5]; } else { ... } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: One sprintf() initializations problem
jiangfan wrote: Hi, What is wrong with this statement? my $time = sprintf( 0x%08x, `date +%s` ); I got Use of uninitialized value in sprintf at /opt/MoteWorks/tos/../make/ scripts/ident_flags line 15. Thanks. Jiangfan Works for me. Check to ensure that date +%s is returning what you expect from the command line. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to get source of of web page which is hosted on the server (which I dont have access).
Siva Prasad wrote: HI Gurus, I am opening a web page using win32::IEAutomation and clicking each link on the page and reading data.(This page has 177 links). The above processes occupy more memory, Make sure that you're not trying to read all 177 links (especially if you're descending further down those links) at a time and that memory is freed or reused upon each return to the top page. I'd probably also look for some recursive wget style app to get the source first since that's quite a bit of network traffic. After some time the page is unable to load and the script gives me READY STATE error. I have used WaitforDone(); but still no luck. I tried LWP::Simple and LWP::UserAgent to read the content, But the it throws me *“unable to get the source of the page”.* * * I don’t have access to the server on which pages are hosted. Is there any other way to read the source of the page from the server on which I don’t have a account? Thanks, PP -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Hash Variables
sivasakthi wrote: On Mon, 2007-10-29 at 17:06 +0530, Kaushal Shriyan wrote: #!/usr/bin/perl -w %states = ( California,Sacramento, Wisconsin,Madison, New York, Albany); print Capital of California is . $states{California} . \n\n; I did not understand the statement $states{California} in the above print statement of the code I know the the dot is a concatenation operator and \n is a newline character Hi Kaushal, %states is a hash array California is a key value $states{California} means the value of hash($states) key(California) is Sacramento More information : # perldoc -q hash I'd recommend `perldoc perldata`. For this particular instance in a nutshell...you can initialize a hash as a list of keys followed by their values (which is I believe how they are stored...the answer to that is likely in the above reference topic). Therefore, each *even* indexed hash item (starting with 0) becomes a key, and accessing that key by name (such as as $states{California}) will return the following item. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: help on ip addr
lists user wrote: Hello, I want to do the things below: a) get all binded IPs on a redhat linux os.there are maybe more than one IP,like eth0,eth1,eth0:1 etc. b) for each IP,I need to know if it's a private network address (like 192.168.0.1) or a public network address. for the first problem I can read something from /etc/sysconfig/network-script/ifcfg-eth*, or code with @ips = `/sbin/ifconfig` and use regex to capture the IPs.But I don't think these are the best ways. I don't like to use any CPAN module,b/c I'm not admin user,don't have privileges to install those modules. To save you from re-inventing wheels... You don't need admin access to install most modules, just put them somewhere where you can script can access them and use lib. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: umask
sam wrote: Hello everyone! This is my first time posting anywhere about perl, so be gentle. Let me start off with my script: #!/usr/local/bin/perl #Author: Sam Ganim 10/26/07 print What Lesson are you on? ; chop($lesson = STDIN); print How many exercises are there? ; chop($exercises = STDIN); #print What is the date today?(MM/DD/YY) ; #chop($date = STDIN); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year += 1900; $year = sprintf(%02d, $year % 100); $date = ++$mon ./ .$mday ./ .$year; umask 0022; It appears as though this umask function serves to only block against particular permissions rather than allowing for setting full permissions. Since the x bit generally wouldn't be a default (at least on a regular file), it's not being affected. Look into the default permissions of the underlying directory, or the mode options of the mkdir or syspoen Perl functions. while ($exercises 0) { open EXERCISE, exercise .$lesson ._ .$exercises ..pl; print EXERCISE #!/usr/local/bin/perl\n#Author: Sam Ganim .$date .\n#perltutor Lesson .$lesson .Exercise .$exercises .\n; $exercises = --$exercises; } The problem I'm having is that the permissions on the files being created are 644 and not 755. I know it has something to do with octals but I'm not sure what else. Any help either solving the problem or steering me in the right direction would be greatly appreciated. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Another noobie question about perl on Windows - perl running in background
Ayesha wrote: Hi all Thanks to all who replied to my question yesterday. I am using perl- express IDE to write a small perl code. Sometimes the code runs for a long time (infinite loop logical error), I close the editor but realize that the computer is suddenly running slow. So I have to go to task manager and close perl.exe (eating 99% of CPU at that time). I wanted to know is there any break execution when using perl-express, and on Unix (since I use both types of OS). Thanks Ayesha Closing the editor doesn't sound like a good start since the editor and the running script would be 2 distinct but related processes. There should be a break option somewhere near the option that you use to execute the script (maybe a debug menu). In Unix the standard Ctrl-C interrupt should work. In either case if the script isn't being responsive (which may be likely if there's bad control logic in it) it may ignore interrupt signals in which case use process manager in Windows (as you did), or a kill command in Unix. The best way to handle this situation is to make sure you don't get into them...one of the reasons they are so frowned upon (and you shouldn't just accept intermittent infinite loops) is because once they get going there may be no nice solution to stop them. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Parsing Bounced Emails
Nigel Peck wrote: Hi all, Just hoping someone might have some advice on what to use to parse bounced emails and tell me what type of bounces they are, if they are bounces at all. I tried... Mail::DeliveryStatus::BounceParser... it doesn't work bbounce.com... they don't exist, they just take your money and there's nobody there to actually provide access to the software (or keep it up to date, no doubt) I'm ont the only one who's found out the hard way: http://www.epigroove.com/posts/69/review_of_bbounce_stay_away_far_away BounceStudio.. too expensive for me It this an example of a bounce response that you're having problems parsing? Anyone got any other suggestions? Thanks in advance. Nigel -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: qx string
Sayed, Irfan (Irfan) wrote: Hi All, I am executing following line in my perl script. chomp(@files = qx(cleartool desc -fmt %[versions]p\n activity:$ENV{CLEARCASE_ACTIVITY})); But i am getting following error when i execute the script. sh: cleartool desc -fmt %[versions]p: not found sh: activity:: not found These errors are caused by sh not knowing what to do with the commands (no command etc. found). The first one would be because it is looking for a command that is that whole string (including arguments) rather than the most likely intended cleartool to which the arguments will be passed. This would indeed be caused by the double quotes. As per my understanding, double quotes inside the qx is causing the prob. Please guide how to resolve this. I would start with creating some temporary variables to clean up the code and ensure proper interpolation for debugging (make sure, in particular, that nested quotes are properly escaped). Create one for the command which optionally includes the path to the command (unless it's a command which is expected to be in $PATH), and then a second which has the arguments and then pass those variables to qx without having to worry about quoting. Regards Irfan. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: problem runing code | strange Error
Juan B wrote: Ok I did it and know I get another error :-( here goes the error: Died at /usr/lib/perl5/site_perl/5.8.8/Mail/Mailer.pm line 284. I don't have that module and therefore have no idea what line 284 is or to what it applies, but here are a couple suggestions. this is the code: use strict; use warnings; use Mail::Mailer; my @lines = (); open (INFO, /var/log/messages) or die $!; while (my $line = INFO) { if ($line =~ /IDS/) { push @lines,$line; } } close INFO; if (@lines) { my $mailer = Mail::Mailer-new(smtp, 10.83.27.71); You may not want to call the constructor directly and rather let the underlying system handle it with a my $mailer = new Mail::Mailer(...) $mailer-open({ 'From' = 'Syslog [EMAIL PROTECTED]', 'To' = 'gabriela pinado [EMAIL PROTECTED]', 'Subject' = 'PiX Detected Attack' }); print $mailer @lines; You're treating this array as a scalar...you're likely to get an e-mail which contains nothing but an integer. $mailer-close or die can't close mailer: $!; } ~ please assist! thanks very much ! Juan __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: How do I replace a part of huge text file
the_train_man wrote: On Oct 22, 10:32 am, [EMAIL PROTECTED] (Dr.Ruud) wrote: [EMAIL PROTECTED] schreef: I would like to replace a part of a really big (4GB) text file. And the contents that I want to change is really a small but continuous portion. Could some one please help me with the best way I can do this in perl? Is the replacement guaranteed to be the same size as the original? -- Affijn, Ruud Gewoon is een tijger. Thanks for your suggestion. No, the resulting file may be different in file length. To be more specific, Consider the file contents as: A B C D E F G H and I want to replace the lines 2-4 which may result in a file being A X Y Z D E F G H the problem that I am facing is the time it takes to write out the line 5 to end of file in cases where the file size run into GBs. Is there a way I can cat the contents from D to H to the modified top portion? Thanks, If you're on a *NIX then initially use split. Modify the relevant file, and then you can just use cat old_end new_start. Otherwise there are similar utilities for other platforms (I think hjsplit should work for windows). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: PArsing tables of web page directly on the web.
Prabu Ayyappan wrote: Hi Siva, Leave the perl script and first try the url in your browser. If it works fine means then the code will get you the HTML contecnt of that page. Thanks and Regards, Prabu.M.A If you end up able to reach the URL from a browser and somehow not from the script (worked for me) and this isn't a process that needs to be repeated, you could also just save the generated HTML page from within your browser and then parse the local copy from your script (use a file:// URI). If it's a process that is repeated then you may want to try narrowing the problem down to a more specific step. - Original Message From: Siva Prasad [EMAIL PROTECTED] To: beginners@perl.org Sent: Wednesday, October 24, 2007 11:18:21 AM Subject: PArsing tables of web page directly on the web. Hi Gurus, I wanted to parse a PHP page which is on web. I don’t have access to server where the PHP page is hosted. So I wanted to get source of that particular page and then parse the source file. Here is the code: ---Code use LWP::UserAgent ; $ua = new LWP::UserAgent ; $ua-agent(Mozilla/4.0) ; # Play with their minds $req = new HTTP::Request 'GET', 'http://www.jimmyr.com:80/free_education.php' ; $req-header('Accept' = 'text/html') ; $res = $ua-request($req) ; if($res-is_success){ print $res-content ; } else { print Error: . $res-code . . $res-message ; } -Code But When I run the above code I am getting the following error. Error: 500 Can't connect to www.jimmyr.com:80 (connect: Unknown error). Is there any alternate way that I can directly parse tables and contents of the tables on the webpage directly? Thanks in Advance, Siva __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: How do I properly use global variables?
Jeff Pang wrote: On 10/23/07, monk [EMAIL PROTECTED] wrote: I'm having problems accessing a variable outside its subroutine. I've tried several combinations too long to write here. Maybe I just can't see the forest for the trees. But I'm lost. I need your wisdom. I'd like my program below to change $status to zero to exit the loop. meaning...$ perl test.pl --start it prints out indefinitely hello world But if $ perl test.pl --stop it gets out of the loop exiting the program. And if you want to keep the notation similar to that above you'd need the second instance of the script (with the --stop), to send the signal to the process of the first instance (generally by storing the pid in a file and then sending the signal as below if the pid is still running). Hi, When script is running,how can you re-run it with another argument to make it stop? The general way to let a running program stop is to send a signal. Let me modify your code to, use strict; use warnings; our $status = 1; $SIG{TERM} = $SIG{INT} = sub {$status = 0}; start(); sub start { while ($status){ print hello world!\n; sleep 1; } print out of loop. Will exit now\n; exit 0; } __END__ When you run it,you can send SIGINT or SIGTERM to let it exit gracefully. Given the process id is 1234,under unix you can say, $ kill -s 2 1234 The script would print out of loop. Will exit now and exit. (-s 2 means sending SIGINT,see `man 7 signal` for details). The most important change for the code above is that we re-defined singal handlers: $SIG{TERM} = $SIG{INT} = sub {$status = 0}; When the script receive SIGTERM or SIGINT,it set the global $status to 0,so the loop condition become false,the program exit. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: String processing
Mark Wagner wrote: I'm working on a program to process Wikipedia pages. Wikipedia pages can contain templates of the form: {{template name |key = value |key2 = value2 |... }} Any value may in turn be a template, with essentially no limit to the level of nesting. Given a key = value pair, how would I go about retrieving the entire template from the page? In C, I'd use strstr() to find the key = value pair, walk my way back up the string until I found an unmatched {{ as the beginning of the template, and walk down the string until I found an unmatched }} as the end. How would I do this in Perl? Are you looking for the way to implement the outlined algorithm in Perl, or suggestions on other ways to process the data? By processing the data as far as the question goes, you're looking to create a hash for each template? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to insert rows into database from array/hash using DBI
[EMAIL PROTECTED] wrote: I'm trying to grab data from an MS-Access log file and put it into a fast, read-only database. (I'm thinking SQL Lite at this point.) Make sure that's it's only read-only after it's written to. Depending on what you're doing with the data it may be easiest and fastest to use a format that Access can work with and then dump directly to that file with something like a SELECT...INTO... statement and a linked table in Access. The code below is working. Now I need to put the identical data and structure into an SQL Lite table. Any suggestions on where to look for examples? (or if you want to write one, that's fine too.) I own the book Programming the Perl DBI, but I haven't found anything that addresses this. use warnings; use strict; use DBI; use DBD::ODBC; use DBD::SQLite; my $DSN = 'driver=Microsoft Access Driver (*.mdb);dbq=C:\temp \adt2_in.mdb'; my $dbh1 = DBI-connect(dbi:ODBC:$DSN,,) or die $DBI::errstr\n; $dbh1-{LongReadLen} = 2000; $dbh1-{LongTruncOk} = 1; my $sth1 = $dbh1-prepare(select message_index, message_no, message_event, time_stamp, data from log); $sth1-execute(); my @stash; while (my $hash_ref = $sth1-fetchrow_hashref()) { push @stash, { %$hash_ref }; } $dbh1-disconnect(); my $itemp = 1; foreach my $hash_ref (@stash) { print Details of row $itemp: ; print \n\n; foreach my $key (keys %{$hash_ref}) { print ($key \t $hash_ref-{$key} \n); } $itemp++; } Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: (OT) Re: sourcing one perl file from another
Chas. Owens wrote: On 10/22/07, Jenda Krynicky [EMAIL PROTECTED] wrote: snip I wonder ... what language does this meaning of the verb to source come from??? I know I've seen the word used like this a few times alerady, but it still sounds completely off. I mean I could understand use, include, call, but source??? snip It is also a verb in Korn Shell and BASH that means to run a file as part of the existing interpreter (instead of spawning a new interpreter): source ~/.db.prod.env also written as . ~/.db.prod.env * http://wordnet.princeton.edu/perl/webwn?s=source It is also is a stand-alone command to interpret Tcl scripts. I'd guess Tcl was the original source of source and was adopted by BASH and other shells afterwards. I don't know anything about Tcl but maybe it has a group of functions along the lines of file-type file-name. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: (OT) Re: sourcing one perl file from another
Matthew Whipple wrote: Chas. Owens wrote: On 10/22/07, Jenda Krynicky [EMAIL PROTECTED] wrote: snip I wonder ... what language does this meaning of the verb to source come from??? I know I've seen the word used like this a few times alerady, but it still sounds completely off. I mean I could understand use, include, call, but source??? snip It is also a verb in Korn Shell and BASH that means to run a file as part of the existing interpreter (instead of spawning a new interpreter): source ~/.db.prod.env also written as . ~/.db.prod.env * http://wordnet.princeton.edu/perl/webwn?s=source It is also is a stand-alone command to interpret Tcl scripts. Actually it's a built-in (proving my below mentioned Tcl ignorance). I'd guess Tcl was the original source of source and was adopted by BASH and other shells afterwards. I don't know anything about Tcl but maybe it has a group of functions along the lines of file-type file-name. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: (OT) Re: sourcing one perl file from another
Lawrence Statton wrote: It is also is a stand-alone command to interpret Tcl scripts. I'd guess Tcl was the original source of source and was adopted by BASH and other shells afterwards. I don't know anything about Tcl but maybe it has a group of functions along the lines of file-type file-name. I'd find that remarkably difficult to believe, since I was using source in /bin/sh about eight years before the first release of Tcl. It looks as though it was introduced in csh. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: ftp in ascii mode
Gunnar Hjalmarsson wrote: Gunnar Hjalmarsson wrote: Net::FTP uses ascii mode by default, which means that the line endings were converted also when you transferred the file back to your local machine. Consequently, those files should not be identical. Correction: They _should_ be identical. Sorry! No, I can't tell what got wrong. Did you study the files closer? I'd diff the 2 files to find out what exactly was changed. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Printing size of array unitializes array?
Matthew Whipple wrote: yitzle wrote: What are you trying to accomplish? What is @files? Did you define it somewhere? Or is it a Perl global var I don't know of? The below is speculation since these questions need to be answered. In addition to what is @files I'd add what is $Tmp? On 10/19/07, Joseph L. Casale [EMAIL PROTECTED] wrote: I had the following code: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; my $Tmp = ++$#files; print FILEOUT moretext = $Tmp\n; When I add the 3rd line, it initializes the files array and I can't use it after? Why is that? I actually guessed the code to be trying to go one way but am now changing my guess. Don't say initialize when you don't mean it, that implies that the variable previously contained no value. I now have: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; print FILEOUT moretext = . @files . \n; And not only does that work, it also shows the real size of the array? I'm confused :)? Thanks! jlc If you access an array as a scalar it returns the length of the array. In this case it's the only mention of the array so the actual purpose is enigmatic at the least. I'm guessing you want to print the array. If you're looking for the last element then you could use $file($#files), umm...$files[$#files] if you're looking for the whole thing then either for through it or join it. perldoc -fjoin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Printing size of array unitializes array?
Joseph L. Casale wrote: Sorry, it is an array I used above this block of code. jlc That could have easily been guessed (that's one of the few options). The question is what's in it and what are you trying to do with it. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of yitzle Sent: October-19-07 11:16 AM To: Joseph L. Casale Cc: beginners@perl.org Subject: Re: Printing size of array unitializes array? What are you trying to accomplish? What is @files? Did you define it somewhere? Or is it a Perl global var I don't know of? On 10/19/07, Joseph L. Casale [EMAIL PROTECTED] wrote: I had the following code: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; my $Tmp = ++$#files; print FILEOUT moretext = $Tmp\n; When I add the 3rd line, it initializes the files array and I can't use it after? Why is that? I now have: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; print FILEOUT moretext = . @files . \n; And not only does that work, it also shows the real size of the array? I'm confused :)? Thanks! jlc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Printing size of array unitializes array?
yitzle wrote: What are you trying to accomplish? What is @files? Did you define it somewhere? Or is it a Perl global var I don't know of? The below is speculation since these questions need to be answered. In addition to what is @files I'd add what is $Tmp? On 10/19/07, Joseph L. Casale [EMAIL PROTECTED] wrote: I had the following code: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; my $Tmp = ++$#files; print FILEOUT moretext = $Tmp\n; When I add the 3rd line, it initializes the files array and I can't use it after? Why is that? I actually guessed the code to be trying to go one way but am now changing my guess. Don't say initialize when you don't mean it, that implies that the variable previously contained no value. I now have: open (FILEOUT, $OutDir/info) or die $!; print FILEOUT text = abc\n; print FILEOUT moretext = . @files . \n; And not only does that work, it also shows the real size of the array? I'm confused :)? Thanks! jlc If you access an array as a scalar it returns the length of the array. In this case it's the only mention of the array so the actual purpose is enigmatic at the least. I'm guessing you want to print the array. If you're looking for the last element then you could use $file($#files), if you're looking for the whole thing then either for through it or join it. perldoc -fjoin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Configuring Apache::DBI in Apache2
Subhash Chandran wrote: Hi Can anyone help me to configure Apache::DBI to the Apache2 server. System config: OS Windows XP Perl 5.8.8 Apache 2.2.4 mod_perl: 2.0.3 Apache::DBI 1.06 I was able to make mod_perl and now the server is mod_perl enabled. But as per the README in Apache::DBI if the httpd.conf is set as below PerlModule Apache::DBI the server doesnt start. I get the following in the error.log [error] Can't load Perl module Apache::DBI for server abc:80, exiting.. Has anyone faced the same issue before. Please suggest Thanks Subhash Make sure that the module is in a proper path. Can you load similar modules? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing line return from variable
Paul wrote: I am assigned the output of a function to a variable. my$variable = (function); print $variable\n; The output is: text 0 So I try this: chop my$variable = (function); print $variable\n; The output is: text *** this is blank space output * So it get's rid of the 0, but outputs a new line. I try double chopping with same results. How can I finally get rid of it, I just want the text output. Ugh. Try chop followed by chomp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: printing elements of an arrays of references
Pedro Soto wrote: Dear all, I am trying to make a matrix out of a file (row-columns) using perl. In particular I would like to print the first row of an array of arrays which contains the headings of the file. I tried to do it but I can't print it. If used $AoA[0], I get the reference to the array.How can I deference it? Thanks in advance, P #! usr/local/bin/perl use warnings; use strict; my @AoA= (); open(IN,genotypes_piece) || die I can not open file\n; my @temp =(); while (defined (my $line = IN)) { @temp = split/\s+/,$line; push(@AoA, [EMAIL PROTECTED]); } for (my $x = 11; $x =$#temp; $x++) { for (my $y = 1; $y = $#AoA ; $y ++) { print At X=$x, Y=$y is, $AoA[$y][$x], \n; } } Your problem doesn't appear to be dereferencing but your for loops. You seem to have a typo of $x = 11 and more importantly array indexes are zero based. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing line return from variable
[EMAIL PROTECTED] wrote: On Thu, October 18, 2007 9:39 am, Matthew Whipple wrote: Paul wrote: I am assigned the output of a function to a variable. my$variable = (function); print $variable\n; The output is: text 0 So I try this: chop my$variable = (function); print $variable\n; The output is: text *** this is blank space output * So it get's rid of the 0, but outputs a new line. I try double chopping with same results. How can I finally get rid of it, I just want the text output. Ugh. Try chop followed by chomp It doesn't work. For some reason, this always seems to be the hardest thing for me in perl. Ugh. Can you post the appropriate code? Depending on what the function is used for you could potentially change the return value there. You could also check to make sure that it is in fact a new line character in case it somehow ended up as something odd that is behaving that way. Something like ord(substr($variable, 1)) after chop (and chomp). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Search for IP address and delete from file
mv $TMP_FILE $FILE_NAME Be careful, the 192.168.0.0 can also match a line with 192.168.010 in it. See also the -F option of grep. -- Affijn, Ruud Gewoon is een tijger. Good point, bad example (although natural continuation of previous discussion). Most programs won't output leading 0's in IP addresses (and then it likely wouldn't match any since it would be 192.168.000.000), but there are many other possibilities of any number along the lines of [1-25]\d. Including a following delimiter of some kind would be another option to qualify. I actually misinterpreted the mentioned problem and thought it was another one...now you get 2 to watch for though. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Search for IP address and delete from file
On Fri, 2007-10-19 at 01:55 +0200, Dr.Ruud wrote: yitzle schreef: If you are on a Linux machine, it might just be easier to use the grep command with a shell script. FILE_NAME=./log TMP_FILE=./tmp IP_TO_REMOVE=192.168.0.0|192.168.0.255 COUNT=`grep $IP_TO_REMOVE $FILE_NAME | wc -l` echo The IPs occur $COUNT times grep -v $IP_TO_REMOVE $FILE_NAME $TMP_FILE mv $TMP_FILE $FILE_NAME Be careful, the 192.168.0.0 can also match a line with 192.168.010 in it. See also the -F option of grep. -- Affijn, Ruud Gewoon is een tijger. Good point, bad example (although natural continuation of previous discussion). Most programs won't output leading 0's in IP addresses (and then it likely wouldn't match any since it would be 192.168.000.000), but there are many other possibilities of any number along the lines of [1-25]\d. Including a following delimiter of some kind would be another option to qualify. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Reading files for values
Joseph L. Casale wrote: I have to search for text strings in files and then do something with the line that matches in one scenario and in another I need to store the contents of the following n lines. In the first requirement I think I have it beat, but I am lost on the second. I thought I might be able to search for the line I need and store its line number as n, then read the next n+[1...4] lines and store them. How does one accomplish that, or is there a better approach? Thanks! jlc If you're doing a line by line check anyway and not storing that many consecutive lines then you could use a flag type of counter that is set when the line matches and decrements after each read line. pseudocode: my $to_store = 4; my $left = 0; if (line matches) { $left = $to_store; } elsif ($left 0) { push @store, $line; $left--; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Search for IP address and delete from file
yitzle wrote: Take a look at the grep function http://perldoc.perl.org/functions/grep.html Also of potential use is the qr// quote operator: http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators This lets you do: my $ip_search = qr/$ip_string/; my @lines_with_ip = grep /$ip_search/, @raw_data; # or is that grep $ip_search, @raw_data; ? He's looking for the lines that don't have the IP addresses so it would be my @lines_without_ip = grep !/$ip_search/, @raw_data; Using this method you could iterate through all of the IP's you want removed, something along the lines of... my @newdata = FH; my @ips_to_remove = (192.168.0.0, 192.168.0.255); foreach my $ip (@ips_to_remove) { @newdata = grep !/$ip/, @newdata; } Then output the resulting array into a new file. Now you got an array with only lines that got the ip. my $i = 0; foreach @lines_with_ip { print $_; $i++; } print The IP was found $i times\n; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Search for IP address and delete from file
Matthew Whipple wrote: yitzle wrote: Take a look at the grep function http://perldoc.perl.org/functions/grep.html Also of potential use is the qr// quote operator: http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators This lets you do: my $ip_search = qr/$ip_string/; my @lines_with_ip = grep /$ip_search/, @raw_data; # or is that grep $ip_search, @raw_data; ? He's looking for the lines that don't have the IP addresses so it would be my @lines_without_ip = grep !/$ip_search/, @raw_data; Using this method you could iterate through all of the IP's you want removed, something along the lines of... my @newdata = FH; my @ips_to_remove = (192.168.0.0, 192.168.0.255); foreach my $ip (@ips_to_remove) { @newdata = grep !/$ip/, @newdata; } I was debating whether to even send that last but but it seemed to serve some purpose or other to me (an association with on the fly command line grep)...but it would probably be faster to type and to run if rather than creating an array you just stuck with the single test and entered the IP addresses into a | delimited scalar (i.e 192.168.0.0|192.168.0.255). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Beginner Reg.Expression Question
Jenda Krynicky wrote: Thanks for the \d info, I did not know they were silly enough to include some additional unicode characters in \d, I expected those to be only in the [[:IsNumber:]]. It's really sily as there really are characters that match /^\d$/, yet $char+0 issues a Argument ... isn't numeric in addition (+) warning. And if I look at the characters that match \d it seems to include greek letters! Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery Greek characters doesn't seem that surprising since I think many of them have been adopted to represent mathematical constants. If you cover enough branches of applied math, however, you could probably throw in a good amount of the roman alphabet also (I'm speculating), so that easily gets tricky. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Searching for records in 15000 lines.
Jenda Krynicky wrote: From: [EMAIL PROTECTED] Searching for records in 15000 lines. Have a list of hostnames in a text file. Wanted to take the lines matching the hostnames in csv file. must use sub routines or is there any module for this? host.txt adms0922 adms0943 adms0782 temp.csv 12312,adms0782,10.10.50.53,Application,,,12.3 I want to print all the matching values of the Thanks Manoj I bet there is no module because it's too simple. 1) read the host.txt and stuff the hostnames into a hash 2) read the csv (Text::CSV_XS, DBI+DBD::CSV) and process only lines whose hostname exists() in the hash. If you're going to use DBI you should also be able to just SELECT...WHERE... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Controlling Firefox via Perl
Felix Mater wrote: I've seen a programm written in Java that, on demand, opens an url in a firefox window, or, if that already exists, opens the url in a new tab. See the new-tab command line option for or part of the question. I'm not sure of the behavior but it should just open a new window if there isn't a running instance. http://kb.mozillazine.org/Command_line_arguments Can this also be done from perl, is there a module that can control firefox? TIA Felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: OT: Problem Distributing my Perl Program
I wonder if your friend would be able to download the file if it had an extension of .txt or something as opposed to an archive extension. (Perhaps the AV doesn't even read into the file at all, and only unintelligently looks at the extension). Steve I'd pick a binary extension if you're going that route to minimize the chances of line end mangling. You could probably pick a nice benign graphics format. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Beginner Reg.Expression Question
Dr.Ruud wrote: Well, don't underestimate version number logic. Version numbers can also be like 1.23.045_21. Yes, v-strings are deprecated, but supporting version number logic isn't. Again: see version.pm. (the C-version is 6k, the Perl version is 11k) I'm not underestimating version logic, if anything the exact opposite. I consider the storage simple enough that it doesn't warrant its own data type (especially since Perl can handle the job above the hood) but the treatment potentially complex and different enough (or at least the common uses of said data numerous enough)that it should have at least it's own module if not it's own tree (to allow various different adaptations for versioning schemes)...again version.pm. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: copy site contents into pdf file.
Do you want to create one large PDF? First you need to think about the problem as more of a sequential ordering of information since PDF's don't have hyperlinks. Is this a stripped down example or are you really only dealing with a handful of webpages? Also, is this static data you're dealing with or is it script output which is likely to change? It's questionable how much of this task, if anything, should be done with Perl. Siva Prasad wrote: Hi Gurus, I need to copy the contents of the website and make a pdf file. Please check below for detailed explanation. Link1 Link2 If we click on the main link Link1 we get sub links Sublink1 Sublink2 So I have to click on Main link1 copy the content to pdf file and the click on the all the sub links and copy the content into pdf file. How to achieve this. Thanks, Siva -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Split question
There's a comma in the example data provided. Most of the CSV's I've dealt with also quote values which were strings. If this is the case, an ugly solution would be to use something along the lines of ',' as the delimiter, take into account any possible fields which aren't quoted (it should be entire fields and not record specific) and then retrieve the proper index. You'd be much better off using regex or a CSV module however. yitzle wrote: On 10/12/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: One of the column in csv file is Fri, Oct 12 10:32 AM. I am trying ti split the csv file for checking a column value. when spliting I wanted to take Fri, Oct 12 10:32 AM as a single value. How can I use split? Thanks Manoj If the CVS uses a comma, you would split on the comma: split /:/, $line; As Tom said, if you only want the, say, 4rd field, you can use a RegEx: $value = $1 if ( $line =~ /^(?:[^,]*,){3}([^,]*),/ ); Unfortunately, this gets messed up if a comma is anywhere present in any of the fields, or if a field is more than one line (though I have no idea if that's possible). There is a CVS module you may want to search for on CPAN. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Beginner Reg.Expression Question
Sorry I prefer messages where the point is easily visible rather than having to scroll down to the bottom of a thread of things that people have read several times over and don't see the need to place simple concepts in context (particularly when sufficient context is left afterward). My response was actually due to my lack of knowledge about Perl's v-strings and therefore I viewed your treatment from a more logical perspective. Now that I am aware of v-strings I consider them a convenient kluge which is highly unnecessary considering Perl's powerful text processing and something which theoretically fits into the Perl culture but strays away from the modular ideal and therefore should be (and apparently will be) removed from native support. This was about 'double digits', more than about anything else. The Matthew Whipple who doesn't know about how to properly mix his reply with the text he replies on, also doesn't know about Perl characters. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Need advise on sending .eml attachment
What is the sample code of what you are using? Are you using one of the Send methods? I would recommend in this case not using Mail::Sender and instead using something like Email::Send (with Email::Send::SMTP). Mail::Sender is more geared for the generation of mail messages and the required headers and encoding whereas Email::Send is for transferring an already generated message (such as in your case). Yes !! That's exactly my question is what would be a simply way to resent directly. Through a new mail with attachment ? or copy the source as content between DATA and CRLF.CRLF ? Thank you very much, Panda-X -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: basic regex question
The primary problem would be that you're match seems a bit backwards. Try if ($line =~ m/$file/) which will cut through any extra formatting output by dir. Jim wrote: Hi Everyone, I am trying to match file subdir names from a back tic generated list. I never find anything and there are files in the directory with a correct name. but if i make up a list to use as filenames it works as i expect ... any insight greatly appreciated thanks Jim #!/usr/bin/perl use strict; use warnings; my @files = qw (filename1 filename2 filename3 filename4); #my @dir = qw (file filenaml filename filename2); my @dir = `dir`; foreach my $file (@files) { foreach my $line (@dir) { if ($file =~ m/$line/) { print \nfound one\n; } print file - $file ; print line - $line\n; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: dyndns perl iptable
I'm not sure if I understand your problem exactly but it sounds as though you want to use dyndns to resolve client IP's so that you can allow them through your firewall for SSH connections. If this is correct than the dyndns and iptables are on separate machines and the question is misleading. You'd want a script that resolves the client hostname (the dyndns is somewhat irrelevant aside from the inability to use static data) and modifies the rules. This could either be on a timer or hooked in somewhere (such as a firewall rule). Unless you're planning on writing this yourself, however, I don't think this is the right forum. onlineviewer wrote: Hello, Does anyone have a working dyndns update script which can also update iptables with the new address it gets for the clients that will be connecting to the server...Basically i have a few clients (running the dyndns updater software) that connect to the server via ssh, so i would need the server to get the clients current addresses and update iptables with that info. Thanks, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Perl Scalars
Perl references (like the Perl language itself) are higher level than their C counterparts. Pointers expose the memory address wheres references (to my knowledge and at least not normally) do not. This opens the door to pointer arithmetic and some of the black magic possible with pointers (including the kind that can wreak havoc on your system). Perl takes memory management largely out of the hands of the developer (and provides a more contained environment) in which things like automatic vivification are essentially necessary (or at least a painless solution that fits into the Perl MO). It essentially provides an additional layer between things like references and the perl instance which is handling them. P.S. Other than the fact that your grammar can you a bit of fixing, your email did help me as far as teaching me that Perl does something called autovivifying with pointers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Ftp to GDG dataset
Can you upload the file manually? If you can't then that's obviously the problem. If you can then make sure that all of the settings are the same in the Perl script (the pwd, port/passive, the exact base name suffix). Johnson, Reginald (GTI) wrote: I am trying to ftp files to GDG dataset on a mainframe. Whenever I try this my put fails with failed Requested action not taken: GDG name conversion failed #!/usr/bin/perl use File::Copy cp; use Net::FTP; @serverlist =qw{tsmpa1 tsmte1 tsmdb1 tsmob1 tsmob2 tsmbk1}; $today=(`/bin/date +%m%d%Y`); chomp($today); $logfile=/home/johnsre/actlog_$today; print today is $today\n; if ( -e $logfile) { unlink $logfile; } #end if open(OUTFILE, +, $logfile ) or die open of $logfile failed:$!; foreach $sname (@serverlist) { print sname=$sname\n; cp(/opt/tivoli/tsm/server/$sname/dsmaccnt.log, \*OUTFILE); } #end foreach close(OUTFILE); $ftp = Net::FTP-new(mainframe.xx.com, Debug =1) or die Cannot connet to teleplex.ml.com: $@; $ftp-login(id, password) or die Cannot login, $ftp-message; $ftp-ascii; $ftp-put($logfile ,SM.SCS.ADSM.LINUX.ACCTLOG(+1) ) or die put of $logfile failed , $ftp-message; $ftp-quit; This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Need advise on sending .eml attachment
I'll leave Jenda to answer whether it's a good use of his module. I'd say if this works for your situation then it works (if there aren't any problems with the users whose mail you are forwarding and their mail clients). I'd still advocate the resending of the original message. I would suggest if you send the messages as attachments that you don't forge the From address to be the original sender. It seems like good netiquette to not impersonate, and if you leave it as an address you have access to you'd be notified of bounces or other potential issues (in addition to avoiding any potential security problems with the SMTP server). You can add a Reply-To header with the original address to make life easier on the mail recipient, and then also include the original sender's address either in the subject or somewhere else convenient (possibly in the From header as the descriptive name and not the address). I'm guessing the SMTP server isn't actually localhost? Panda-X wrote: Hello again Jenda and Matthew, 2007/10/11, Jenda Krynicky [EMAIL PROTECTED]: From: Panda-X [EMAIL PROTECTED] Hi Jenda... Are you the author of Mail::Sender ?? I like it very much, that's very handy, as well as Config::IniHash. Yeah, that's me. Thanks :-) Thanks for give me a reply, and I hope my problem can be fixed in the Mail::Sender way. I doubt it. The emails most likely already have all the headers and boundaries and the attachments are encoded etc etc etc. So you do not need Mail::Sender ... you actually can't use it as it insists on generating the headers and boundaries itself. Net::SMTP looks like a more likely candidate. I finally figure it out, but I just don't know if I am doing it in proper way. I mean I get done for what I want now, but I don't know if I am using it safely or if some situation I'll unable to attach the .eml file in proper... Please advise. Here's my code : my $M = new Mail::Sender ({ smtp = 'localhost', }) ; $M - OpenMultipart( { to = $userMailAccount, from = $oriSender, subject = \(Rollback) - $oriSubject }) ; $M - Part ( { ctype = text/html , disposition = 'inline' , encoding = '7bit', msg = Please open attachment to read the original content }) ; $M - EndPart(); $M - Attach ( { disposition = inline, encoding = 7bit,file = $rawfile # $rawfile is the .eml file I firstly get() from server }); $M - Close; Thank in advise =) Panda-X -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Need advise on sending .eml attachment
Panda-X wrote: Hi Matthew, Thanks for you help ! =) 2007/10/10, Matthew Whipple [EMAIL PROTECTED]: Yes, that's a one mail file, and it's actually the source code for an email, plain text. Not the mail box. There's actually little difference between a piece of mail and a mailbox (essentially multiple pieces of mail), but that's off-topic. E-mail is something you may want to look into if you've taken on the roll of somewhat of a mail administrator though (especially since it flies in the face of .eml extensions). I don't know much quick reference, but www.imc.org may be a good place to start. I was only asking to ensure that multiple e-mails weren't being processed incorrectly. data in a standard mbox format or maildir setup (one or the other would better suit the particular volume and rollback frequency you're dealing Hmm... I am working on a Win32 platform, and I am talking to a remote Mail server, I can't take control to the mail server or touch the folders. You don't need to touch the folders, nor would you want to, I was just referring to leaving the processed e-mail untouched so it could be resent directly. The only thing to watch for if you're using a remote mail server is to ensure that the mail is delivered the second time rather than filtered out again. I don't understand... what's piping back?! I am sorry that I don't familiar on pipes. I was using pipe in the more generic sense of just sending the data back to the module. In this case it would be somewhat inaccurate as it would be more input rather than any inter-process communication...should have used feed it (nice ambiguous term). I don't modify the data, my only task is somewhat to put back the .eml ( mail content ) to the original recipient. Anymore clues ? If you're processing valid e-mails (which they should be if they were delivered in the first place), and the data isn't modified (check the module settings), then the e-mail should be able to be submitted directly to an SMTP (or local MTA though that doesn't seemingly apply here) capable module (good ones should support handling of pre-generated e-mail messages). If you find yourself sending a lot of e-mails back a local delivery type of solution would work better (e-mail isn't really supposed to go backwards), but that's beyond this mailing list. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Perl Scalars
It may be easier to understand outside of computer context and delving into pointers/references/memory addresses. I'm sure there are some good tried and true analogies that I can't think of so I'll try to come of up with one that fits well into computers without getting too far from reality or too esoteric an aspect of reality (ans still relatively flat so it's closer to a scalar than a class). Suppose you are counting coins and placing them in containers that you use for specific uses...one for laundry ($laundry_tin) and one for toll charges ($toll_tin). You start off with 10 dollars (or currency of your choice) and divide it evenly, so now $laundry_tin = 5.00 and $toll_tin = $laundry_tin. You assigned the _value_ of one to the other so they both contain 5.00, but they both contain their own 5.00 of coins. A couple days later you do a load of laundry and $laundry_tin is down to 4.50. $toll_tin is still at 5.00 (you didn't touch that tin so it wouldn't change). You could make them equal again, assign them equal but it doesn't happen automatically. Now to extend this for the concept's sake (though the bit above is the important part for your question). Suppose that you realize that you aren't paying that many tolls so you decide to share that money between tolls and snacks. You could assign $snack_tin to $toll_tin by _reference_ which would mean that $snack_tin and $toll_tin are the same tin, sharing the same set of money. If you take out money for snacks, you lose the money for tolls (so you can't fill your face if you need to go somewhere). They are different names to access the amount of change (value) in the same tin (address). The note is saying that Perl does scalar assignment the first way unless you tell it otherwise. $a = $b doesn't mean that $a is the same as $b, it means it gets the value of $b. If you want to tell it otherwise perldoc perlreftut would probably be the place to start. Kaushal Shriyan wrote: Hi, I am referring to http://www.gnulamp.com/perlscalars.html $a = $b; # Assign $b to $a Note that when Perl assigns a value with *$a = $b* it makes a copy of $b and then assigns that to $a. Therefore the next time you change $b it will not alter $a. I did not understand the Note:- Can some one make me understand this statement with examples and also what i understand from the below statements( I have added in the comments), is it correct. $a += $b; #is it $a = $a + $b; $a -= $b;#is it $a = $a - $b; $a .= $b;#is it $a = $a . $b; Thanks again Thanks and Regards Kaushal -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Need advise on sending .eml attachment
I'm not sure what exactly qualifies as an .eml file, and a quick look appears as though it's somewhat an MS Outlook format and therefore it's questionable whether the data is being modified or not (my strongest association is the Outlook RTF issues several years back). I'm thinking that regardless the .eml file is intended for a single e-mail and not a mailbox, and I'm not sure how you're using it. I'd suggest storing the data in a standard mbox format or maildir setup (one or the other would better suit the particular volume and rollback frequency you're dealing with). Neither one will actually modify the e-mail itself, however, which should allow you to send the mail by just piping it back into Mail::Sender without attaching it. If you did want to attach it any problems caused by modified data would be eliminated and then any other problems would likely be solved by becoming more familiar with e-mail and MIME formatting. Panda-X wrote: Hi list, quite new to be here. I just wondering if Perl have some quite suitable module to do this. I have wrote a spam filter for my office, which use Net::POP3 to get mails and delete() mails that don't want, the 'got()' mails is however saved at the other place, for 2 reasons, further study on the spam pattern and for rollback. My problem is on the roll back part. I stored the mail in a .eml file, however, I don't know how to put it back to user per request. I try to create a new mail, and attach the .eml file with Mail::Sender, however, the attach.eml file become raw text in the content of the email. 3 questions : 1. Is that Mail::Sender able to fit my task ? 2. should I consider to modify the .eml file is \r\n for each line ? 3. Any module is exactly design for this ? Any clues is highly appreciate =) Thank you very much ! Panda-X -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Bubble sort...
Work inside out. If the inner loop is working properly, then there should be some difference after the initial pass and you won't be left with nothing or infinity (unless that's the trouble loop, but the proper inner loop is easy enough to see..). [EMAIL PROTECTED] wrote: I'm having problems trying to figure out 'bubble sort'. I'm working on assignment for a class and I have to do the following: Use the following code as a starting point for the next lab. #!/usr/bin/perl @array = (5,3,2,1,4); ## include your code here ## foreach $elem (@array){ print $elem; } Use two loops and an if statement to sort the contents of the array so that the number go from lowest to highest. (This is actually a very inefficient way to sort an array.) HINT: One loop should progress through the array comparing and swapping adjacent elements (if necessary). The second loop is used to make sure this happens multiple times based on the size of the array. I can't for the life of me get this to work. I either hit an infinite loop or I get nothing. Thoughts? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Beginner Reg.Expression Question
This wouldn't scale past double digits. If you're going to separate it out you may as well break the minor revisions into it's own variable and then concatenate/format on output...that would also be more easily used with a code management system's built in revision tracking (though this could also be easily used with regex also). Dr.Ruud wrote: Tatiana Lloret Iglesias schreef: What regular expression do I need to convert Version: 1.2.3 to Version: 1.2.4 ? I.e. my pattern is Version: number.number.number and from that i need Version: number.number.number+1 After the : i can have a space or not... Why use a regex? perl -wle ' $v = 2.1.1; printf %vd\n, $v; substr $v, -1, 1, chr ord(substr $v, -1, 1) + 1; printf %vd\n, $v ' See also version.pm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: How to insert data onto an existing XML file
Jenda Krynicky wrote: On 2 Oct 2007 at 10:54, Matthew Whipple wrote: You can't really strictly append to a well-formed XML without breaking the syntax. You need the properly closed top level element at the very least, in addition to whatever nesting may be going on. An ugly solution would be to chop off the end of whatever file you're dealing with and then recreate it (assuming you know what the end of the file looks like). If you only have to bend backwards because the bright omnipotent creators of the XML standard thought it would be fun to force you to and the whole end-of-the-file that you need to chop off is a /roottag then it's actually the best solution. No matter what would the XML purists love you believe. A better solution would be to read the previous file and generate a new XML document. Which may be fine for small enough files, but is simply crazy for anything longer. Parse and rewrite something to insert something in the middle is something that can't be helped, but reparsing and recreating everything for APPEND? If you're dealing with long enough XML files that recreating them isn't efficient enough for your needs, then your primary source of information shouldn't be this mailing list. The requirement of a root tag in XML is ... yet another lovely misfeature of the format. XML apparently just isn't for you. The closing root tag, if nothing else, ensures that the document is whole and simplifies the parsing and data format integrity which are large concerns of XML. If the structure of the format seems counter-intuitive to what you're doing then use something else and optionally export XML for features you may be interested in. It doesn't fit everywhere. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: How to insert data onto an existing XML file
You can't really strictly append to a well-formed XML without breaking the syntax. You need the properly closed top level element at the very least, in addition to whatever nesting may be going on. An ugly solution would be to chop off the end of whatever file you're dealing with and then recreate it (assuming you know what the end of the file looks like). A better solution would be to read the previous file and generate a new XML document. Probably the best solution (assuming the file is big enough or the operation intricate enough to merit it) would be to write some wrapper functions for your specific XML scheme which will ensure that the document syntax is what is expected, and then insert the elements in the proper location (most likely using another module in place of or in addition to XML::Writer). Steven Sim wrote: Gurus; Sorry if this is not the proper forum. I've successfully written a Perl script to create a specific XML file. The problem comes when I attempt to run the script again and append XML entries onto the XML file. Using XML::Writer, I am unable to perform a proper append. (The append IO is successful but it breaks the XML syntax.) Could some guru here share the logic of appending data onto an existing XML file using XML::Writer? (Using it to create a brand new XML file is easy. It's the appending that is really giving me a headache). Warmest Regards Steven Sim Fujitsu Asia Pte. Ltd. _ This e-mail is confidential and may also be privileged. If you are not the intended recipient, please notify us immediately. You should not copy or use it for any purpose, nor disclose its contents to any other person. Opinions, conclusions and other information in this message that do not relate to the official business of my firm shall be understood as neither given nor endorsed by it. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Displaying a Link on A Web PAge with image/png header.
You probably wouldn't want to add the link to an image/png since that probably shouldn't work as it's not something png's should be doing. You'll want to output an html page and embed the image directly within the page source if you can't output a temporary file. Look into the data: URI type which should allow you to encode the image data and serve it as standard HTML. jeevs wrote: Hi Forum!!! I want to plot a graph on a web page. I am using the GD::Graph module and can successfully plot the graph. The graph is displayed on the web page with the following code. ... ... print content-type: image/$graph_format\n\n; my $img_obj = $graph-plot([EMAIL PROTECTED])-$graph_format(); binmode STDOUT; print $img_obj; ... ... But now i need to give a link to the user to move to other page on the same page where the graph is displayed. This is tedious for me since I am not supposed to write to the server. Otherwise i could have written a image file and instead of using image headers, I wud have used the text/html header and the img tag to display the graph. Please guide me how can I provide the link to the another page. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: win32 serial port
You are using 2 constructors that may be stepping on each others toes. Opening the port with new may lock the port from being tied later. What is in the $configfile, since it appears as though most of the configuration is done in the script (although that configuration would probably be undone by the loading of the file)? I'd say drop the tie constructor for now and use write_method to ensure that you have proper access to the port. [EMAIL PROTECTED] wrote: Hello , am using win32::serialport module to communicate with my serial port device, this is my code use Win32::SerialPort; my $serial_port; my $return; my $quiet = 1; $serial_port = Win32::SerialPort-new ($port,1) die Can't open serial port $port: $^E\n unless ($serial_port); my $configFile= 'ER400TRS.conf'; print LOG configuration file: $configFile\n; print $configFile; my $baud = $serial_port-baudrate(4800); my $par = $serial_port-parity(even); my $rint=$serial_port-read_interval; my $data=$serial_port-databits(7); my $stop=$serial_port-stopbits(1); my $hshake=$serial_port-handshake; my $rconst=$serial_port-read_const_time(100); my $rchar=$serial_port-read_char_time(5); my $wconst=$serial_port-write_const_time(100); my $wchar=$serial_port-write_char_time(5); my ($rbuf, $wbuf)= $serial_port-buffers; $serial_port = tie (*FOO, 'Win32::SerialPort', $configFile) || die Can't tie: $^E\n;## TIEHANDLE ## $serial_port-close || die \n close problem with $port\n; undef $serial_port; the code works fine i can write my data to the buffer but when am try to use file handle to tie with config file am getting the error access denied can't tiecan any suggest me ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Strange error
Some suggestions: rewrite ':standard'; as qw/:standard/; use warnings; check the web server error log for more verbose debugging information It would be a lot easier to diagnose if you know what file or directory isn't being found/accessed. Caronte wrote: Hi everybody. I'm learning Perl and CGI programming using MAMP as web- server on OSX and I can't use the standard CGI module. Look at this (very) simple script: #!/usr/local/bin/perl use CGI ':standard'; print header(); print start_html(); for $i (param()) { print b, $i, /b: , param($i), br\n; } print end_html(); It should shows a blank page; on the contrary it outputs the following error: 500 Server Error [Mon Sep 24 21:00:38 2007] [error] [client ::1] (2)No such file or directory: exec of '/Applications/MAMP/cgi-bin/backatcha-cgi' failed [Mon Sep 24 21:00:38 2007] [error] [client ::1] Premature end of script headers: backatcha-cgi It works from the command line, anyway. Scripts without cgi modules works instead. Thanks for any help -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: database insert algorithm
I haven't dealt with MS databases in several years but some of this stuff will likely still apply. First a couple notes on the underlying databases, if you're running Access be sure to compact the database after the insert particularly if this is going to be a repeated process, in addition to the gained performance there may be a file size limitation and the file can swell incredibly during a large insert If you're running MS SQL then make sure that the cluster index on the table isn't set up in a way that the insert will require a lot of rearranging of data. If you can take the table off line during the insert the best solution would be to use Perl to dump the data into a standard format (if it isn't already) and use the databases native importing tools. If you are going to be inserting with the DB online then depending on the quantity of data and how much the DB is accessed, then record locking during inserts/updates can create a serious lag. My suggested solution for this scenario would be to create long INSERT statements which will add multiple rows at a time...most SQL databases support some form of this with something along the lines of multiple sets of values in parentheses but the specific command format varies. You can tailor the number of lines to suit your need, balancing the extra speed of the fewer, larger database transactions with momentarily freeing up the system. The smaller inserts can also cause problems if they're not getting processed by the DB fast enough and end up backed up. I think MS SQL at least also allows for the setting of precedence for certain SQL statements or processes, and creating a stored procedure may provide an additional performance boost. Luke wrote: Hello, I am looking for a proper, fastest and most reasonable way to insert data from pretty big file (~1,000,000 lines) to database. I am using Win32::ODBC (ActiveState Perl) module to connect with Access/MSSQL database and inserting line after line. I was wondering if there is a better way to do it... Maybe create hash with part of data (maybe all of it - what are the limitations ?) What is other way to do it instead 'INSERT INTO...' statement after reading each line ? Thanks for any help in advance... Luke -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Mysql database not being updated
You have two $host variables, the one passed as the parameter will be overwritten by the SOX function which returns the DB host name used for connection. In the Update query that would remain constant for whatever database you connected to. I'm guessing the problem is that you want separate variables for the remote host and the database host. If that's not the case and the code is written as intended the problem is most likely still the SQL WHERE predicate, and you may want to try doing a SELECT to ensure that records are being returned, perhaps also returning the variable passed as a literal so it can be directly compared to the database field. kapil.V wrote: Hi, I used the code: sub set_min{ $host = shift; $date = shift; print The host is $host and the date is $date\nIn the function set_min\n; $host = SOX::get_db_host(); $user = SOX::get_db_user(); $passwd = SOX::get_db_passwd(); $db = DBI- connect ( $host, $user, $passwd, {'AutoCommit' = 0, 'PrintError' = (not $debug), 'RaiseError' = $debug } ); my $insert_query = qq{ UPDATE hosts SET last_checked = '$date' WHERE hostname = '$host'; }; $sth = $db - prepare($insert_query) or die Could not prepare the statement: .$db - errstr;; $sth - execute or die Could not execute query\n; $sth - finish; $db - commit(); $db - disconnect(); } The code runs without any warnings/errors, but the database is not touched. What is wrong? Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: mod perl
It appears as though the user method only returns a value after successful authentication while you're trying to get it before. George wrote: Hello All, I'm having a problem with modperl and I can't figure out if it's my stupiditry or modperls'. I'd love somebody with some modperl foo to give me a hand. First, the config: rembox# cat /etc/redhat-release Red Hat Enterprise Linux ES release 4 (Nahant Update 4) rembox# rpm -qa | egrep 'http|mod_perl' httpd-2.0.52-32.3.ent httpd-devel-2.0.52-32.3.ent mod_perl-1.99_16-4.5 httpd-suexec-2.0.52-32.3.ent rembox# cat /etc/httpd/conf.d/perl.conf | egrep -v ^# LoadModule perl_module modules/mod_perl.so Alias /perlremedy /opt/arsperl/scripts/htdocs/ PerlModule ModPerl::Registry PerlSwitches -I/opt/arsperl/scripts/htdocs/sec/ PerlModule Apache::compat Directory /opt/arsperl/scripts/htdocs/*.pl SetHandler perl-script PerlResponseHandler ModPerl::Registry Options ExecCGI PerlOptions +ParseHeaders /Directory Directory /opt/arsperl/scripts/htdocs/sec/ SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlAuthenHandler My::AuthTest Options ExecCGI PerlOptions +ParseHeaders +GlobalRequest AuthType Basic AuthName Remedy access Require valid-user /Directory Location /perl-status SetHandler perl-script PerlResponseHandler Apache::Status Order deny,allow Deny from all Allow from .your-domain.com /Location Here's the contents of My::AuthTest: package My::AuthTest; use Data::Dumper; use Apache::Access; use Apache::Const -compile = qw(OK DECLINED HTTP_UNAUTHORIZED); use strict; sub handler { my $r = shift ; open (FOO, /tmp/foo.george); # get the client-supplied credentials my $username = $r-user; my ($status, $password) = $r-get_basic_auth_pw; print FOO Dumper($username); print FOO Dumper($password); print FOO Dumper($status); close FOO; # only continue if Apache says everything is OK return $status unless $status == Apache::OK; # Until we figure how to get the username, lets just return OK. return Apache::OK; } 1; That handler lets the auth through so it's somewhat working. The problem is $username is undef so I can't actually test a login or anything. If I try get access to it from a script that's run after the auth (ie, the actual request), then it's not blank and I can see the username. I've also tried $r-connection-user; I've read a whole bunch of the docs, but what seems to be provided by RedHat bears to reference to what's on the interweb. Can somebody tell me what I'm missing? Cheers! George -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Process ID
untie or unlink? You had used unlink previously which closed and deleted a temporary file while close only closes the file which would be the proper way to terminate a pipe such as used in the solution. Somu wrote: Great! Thanks.. How about using untie instead of close? Can i know , phat is the difference between the two? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: How to test for 0
defined() Zachary Shay wrote: Is there a way to test for values where zero is valid? For instance: %a_Hash; $a_hash{user_id} = 0; $a_hash{user_name} = root if ($a_hash{user_id}); print $a_hash{user_id} if ($a_hash{user_id}); print $a_hash{user_name} if ($a_hash{user_name}); Sometimes the user_id can be undef. As a result, if there is no user_id...I don't concern myself with trying to assign a user_name. The problem is that I believe the zero is being interpreted as false. Is there a way to test these values so that only undef will return as false? Thanks, Zach -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Process ID
perldoc -funtie or more thoroughly perldoc perltie untie is the way to go if you're dealing with a tied variable...if you're not then it won't do anything (or at least it shouldn't). The perltie doc will also hint at the greater range of tie'ing available above database hashes. Somu wrote: I meant untie $process ; instead of the close function. In the docs, it says untie is better than close. Why is it so? I only use untie while closing perl database hashes.. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/