Free hosting for CGI?
Perl BG Group-(PBG) all people in Bulgarian Perl Forum-(BPF) is needed for free hosting on Linux or Unix server to put professional perl cgi script in /cgi-bin directory for open source project. We want to provide How-to documentation whit SQL-connecting shareware pipes for all Linux users. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Openning Files Names with Embedded Spaces
Rob Dixon [EMAIL PROTECTED] wrote: Jeff wrote: I am using Active Perl under Windoze 98. I am trying to open a file that has embedded spaces. I tried escaping the spaces as well, and that didn't work either. #! perl -w $file = c:\\win\\start menu\\programs\\system\\tbs montego\\_visit turtle beach web site.lnk; print file = $file\n; open(F, $file) or warn cannot open $file (continuing): $!\n; $file =~ s/ /\\ /g; print file = $file\n; open(F, $file) or die cannot open $file: $!\n; close(F); produces: file = c:\win\start menu\programs\system\tbs montego\_visit turtle beach web site.lnk cannot open c:\win\start menu\programs\system\tbs montego\_visit turtle beach web site.lnk (continuing): No such file or directory file = c:\win\start\ menu\programs\system\tbs\ montego\_visit\ turtle\ beach\ web\ site.lnk cannot open c:\win\start\ menu\programs\system\tbs\ montego\_visit\ turtle\ beach\ web\ site.lnk: No such file or directory The file _does_ exist and works fine if I use DOS 8.3 short names. Any suggestions? Hi Jeff. I agree with Tim, you've most likely got the filename slightly wrong. And by the way it's a lot safer and more readable to use single quotes unless you really need to interpolate variables or add control characters to a string. Try this short program so that you can see what Perl can see. It keeps shortening the path until an opendir succeeds and then dumps the directory. Then you can cut and paste the file names directly back into your code. use strict; use warnings; my $file = 'C:\win\start menu\programs\system\tbs montego\_visit turtle beach web site.lnk'; my $dir = $file; my $dh; ($dir) = $dir =~ /(.+)\\/ or die until opendir $dh, $dir; print dir = $dir\n; print map $_\n, readdir $dh; Just one thing: I presume your windows directory really is C:\win and not C:\WINDOWS? I hope this helps somehow, The program worked, and returned a directory listing in that directory. Basically, the problem I am still having is that I have a list of LNK files that I want to open. So when I use this statement: open(F, $f) or die cannot open file $f: $!\n; the spaces get confused somehow. The 'win' directory is correct back in the days of Windows 3.1, disk space was a premium, so I applied a tip I read once to use 'win' instead of 'windows' to minimize disk space since windows was used in so many places. I am opening the LNK files to dump some information, specifically, what the short cut key is (Win32::Shortcut has some short falls). __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Stupid Question
John W. Krahn wrote: Jason Dusek wrote: Hi Perl Beginners, Hello, Let's say I have a hash of hashes. And I want to use it over and over again, so I need to reinitialize it often. I suppose I could go through each key in the hash of hashes, and go through each key in the little hashes and use delete on each of them. But isn't there some elegant way? Does Perl have a nuke() operator? If you want to clear out the hash completely then: %hash = (); Will remove all the keys and values from the hash. This will also work with a hash of hashes. Or if you need to reinitialize it you can just assign the key/value pairs to the hash: %hash = ( newkey1 = 'newval1', newkey2 = 'newval2' ); Which will assign the new list, replacing anything that was in there before. John Thanks, John, That indeed is one of the conveniences that makes one truly appreciate the beauty of Perl reference-counting, anonymous data structures, and the use of references. Makes cleanups fast and easy. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Openning Files Names with Embedded Spaces
Tim Johnson [EMAIL PROTECTED] wrote: Granted, I'm on XP, but I can't seem to reproduce your error. I created a file at the path specified and it works perfectly. Are you sure that you have the exact filename and that you have access to it? (I guess it's windows 98, so you pretty much have access to everything...) Try pasting the printed out version of the file at the Run... prompt and see if you can open it. You may have to put double-quotes around it when you do this. The following code works for me: # use strict; use warnings; my $file = c:\\win\\start menu\\programs\\system\\tbs montego\\_visit turtle beach web site.lnk; print file = \$file\\n; open(F, $file) or warn cannot open $file (continuing): $!\n; while(F){ print; } close(F); # Of course, .lnk files are not text files, so if you really want to manipulate the link, you should use Win32::Shortcut. The above code you sent me gave me the same error: file = c:\win\start menu\programs\system\tbs montego\_visit turtle beach web site.lnk cannot open c:\win\start menu\programs\system\tbs montego\_visit turtle beach web site.lnk (continuing): No such file or directory readline() on closed filehandle F at x1.pl line 7. Also, the Win32::Shortcut has some short-comings, basically, it cannot break down the modifier codes for shortcuts, so I wrote my own. Thanks, Jeff __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Stupid Question
Jason Dusek wrote: Hi Everyone, On Friday, November 28, 2003, at 08:51 PM, drieux wrote: a. how did you initialize it to begin with and why not simple re-use that solution The hash consists of filenames, line numbers and strings. $HASH{$file}{$line} = line of code from some file. So the script goes along scouring the present directory for all instances of files of type '*.foo' and when it comes to one, it searches every last line of it for the pattern /\bfoo\b/ and if (and only if) there is a foo in the file, the it puts the name of the file in the hash, and then puts the number of each line containing /\bfoo\b/ in the hash under the file's name, and then puts the line of code containing /\bfoo\b/ under the line number. Then it prints out the hash and tells me what directory it was in when it did all this. So this is all fine well and good. But let us say that I wish to rewrite the script so that it scours many directories in sequence, and then tells me what it did in each one. There is only one thing that needs to be changed - each time it comes to a new directory, it should wipe the hash. Then each directories report will not be contaminated by the previous report. If I were to simply use the way I had initialized the hash in the first place, I would get a very long report for the last directory, most of which would be about files in other directories! So I need to nuke the hash each time I go through the loop. - Jason Hi Jason, What you have here is a scoping issue. The hash for the current directory should be declared inside the recursive function that does your scouring work. There is no issue then of cleaing up messes from unrelated, even if parallel, parts of your program. If you are designing your code properly, this issue simply doesn't exist. A variable scoped iside a function dies when that function exits. Even if the function calls itself, the variable within each call is discrete. Within the function below, the @$children array is much less complex than your find results hash, but the principle applies equally. There is a multidimensional hash or two involved in this function also, but these are parameters intended to work from a shared structure, so they don't speak to the problem. sub load_threaded_messages_to_tree { my ($threads, $paths, $message_list, $basepath, $for_path, $depth) = @_; my $children = [sort {$a = $b} keys %$threads]; foreach my $child (@$children) { my $path = $basepath ? $basepath . .$child : $child; my $details = get_message_info($child); add_threaded_message_to_tree($path, $details, $message_list, $child, $for_path); load_threaded_messages_to_tree($threads-{$child}, $paths, $message_list, $path, $for_path, $depth + 1); } return if not $basepath; if (@$children 0) { $message_list-setmode($basepath, 'close'); $message_list-close($basepath); } else { $message_list-setmode($basepath, 'none'); } } What you should note here is that $children exists each time this function calls itself. Each time it is a new reference to an independent anonymous array. When each call returns the variable inside the called function disappears, and its memory is freed. As long as no reference to that array is exported from the function, the garbage collection takes care of itself. This aint C, with its tricky Oops, I forgot to free() my malloc() bugs. Do be careful when exporting references, though. You can accumulate wasted memory bykeeping references to unused data structures in scope. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
holy ravenous bugblatter beast of traal!
volks, has anyone else bumped heads with the 5.8.1 perlio layer where the old school tie chomp(my $line = STDIN); now pops out if a sig handler is called on a signal, such as SIG_CHLD??? I just did the upgrade and got bitten with that silly demo code about doing command line arguments. Since right before the upgrade the code did what I expected it to do under 5.6.1 and then afterwards it was popping out of it and whining about a chomp on an un-initialized variable, yada-yada-yada... So that command line demo code has come around to be usefuler than merely the expected intellectual amusement. http://www.wetware.com/drieux/pbl/Sys/gen_sym_big_dog.txt ciao drieux --- cf: http://www.wetware.com/drieux/PR/blog2/Code/200311.html#id3152907788 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: holy ravenous bugblatter beast of traal!
On Fri, Nov 28, 2003 at 11:49:25PM -0800, drieux wrote: has anyone else bumped heads with the 5.8.1 perlio layer where the old school tie chomp(my $line = STDIN); now pops out if a sig handler is called on a signal, such as SIG_CHLD??? This looks like the new safe signals feature (under-documented and by-no-means-backwards-compatible, but turned on by default) that was introduced in 5.8.0. Your code used to work because this: $SIG{CHLD} = \foo; Called sigaction() with the SA_RESTART flag, so somewhere deep under the hood of my $line = STDIN, the read() system call would continue if it got interrupted by a SIGCHLD. Nowadays, in order to deliver deferred signals promptly, the SA_RESTART flag isn't being used and so read() will fail when interrupted. But your code should still work, since the perlio layer checks for EINTR and retries the interrupted syscall manually. Maybe this is a quirk of the OS X Perl configuration? Your code works for me on Linux (5.8.0 and 5.8.1) but not OS X (10.2.6/5.8.0). -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Viewing logs on other computers.
Although it's not quite the same thing, I wrote a pretty simple Perl script to keep track of disk space usage on a number of file servers. Because df needed to be run as root (access to /proc wasnm't allowed for underprivileged users) I setuided it to root. If I were you I would chgrp the /var/log to logviewer, or something like that. Then I would SetGID the script so it would run as the group (logviewer). Then you could read/parse/whatever the logs and use FTP, email, or something similar to send the log files to your main box. -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
problems with regular expressions
I have a regular expression that looks like: $foo =~ s[class.*?=.*?'.*?'][]sgi; The problem I run into is that if the following is presented to match: table class='foo'tr class='baz'td class='bar' The regular expression will match: class='foo'tr class='baz'td class='bar' And I'll get: table Is there any way I can tell the .*? to match as well as .? Thanks in advance, Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problems with regular expressions
On Nov 29, 2003, at 1:15 PM, Dan Anderson wrote: I have a regular expression that looks like: $foo =~ s[class.*?=.*?'.*?'][]sgi; We're just looking for spaces with most of those .*?s, right? Why don't we say that. And between quotes we're looking for non-quote characters, right? s/class\s*=\s*'[^']*'//sgi The problem I run into is that if the following is presented to match: table class='foo'tr class='baz'td class='bar' The regular expression will match: class='foo'tr class='baz'td class='bar' And I'll get: table Is there any way I can tell the .*? to match as well as .? I don't understand this part of the question. What are you wanting to match, instead of the above? And of course, I should mention the many excellent HTML parsing modules on the CPAN, that work on many more cases than you're own quick and dirty approach. Do you have a good reason for not using them? James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problems with regular expressions
On Nov 29, 2003, at 11:35 AM, James Edward Gray II wrote: On Nov 29, 2003, at 1:15 PM, Dan Anderson wrote: I have a regular expression that looks like: $foo =~ s[class.*?=.*?'.*?'][]sgi; We're just looking for spaces with most of those .*?s, right? Why don't we say that. And between quotes we're looking for non-quote characters, right? s/class\s*=\s*'[^']*'//sgi greedy RegEx's are a good thing, except when they are TOO greedy! Your RegEx is very Strong, but it is short by a leading \s* my $foo = q{table class='foo'tr class='baz'td class='bar'}; print First foo: $foo\n; $foo =~ s/\s*class\s*=\s*'[^']*'//sgi; print Second foo: $foo\n; so that one does not wind up with table tr td with your CORRECT use of the [^']* - the anything but ' match. Folks need to remember to clear the 'white space' between the token and the attribute list! Which is an ugly we all do... ciao drieux -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Openning Files Names with Embedded Spaces
Jeff Westman wrote: Tim Johnson [EMAIL PROTECTED] wrote: Granted, I'm on XP, but I can't seem to reproduce your error. I created a file at the path specified and it works perfectly. Are you sure that you have the exact filename and that you have access to it? (I guess it's windows 98, so you pretty much have access to everything...) Try pasting the printed out version of the file at the Run... prompt and see if you can open it. You may have to put double-quotes around it when you do this. The following code works for me: # use strict; use warnings; my $file = c:\\win\\start menu\\programs\\system\\tbs montego\\_visit turtle beach web site.lnk; print file = \$file\\n; open(F, $file) or warn cannot open $file (continuing): $!\n; while(F){ print; } close(F); # Of course, .lnk files are not text files, so if you really want to manipulate the link, you should use Win32::Shortcut. The above code you sent me gave me the same error: file = c:\win\start menu\programs\system\tbs montego\_visit turtle beach web site.lnk cannot open c:\win\start menu\programs\system\tbs montego\_visit turtle beach web site.lnk (continuing): No such file or directory readline() on closed filehandle F at x1.pl line 7. Also, the Win32::Shortcut has some short-comings, basically, it cannot break down the modifier codes for shortcuts, so I wrote my own. Thanks, Jeff Just in case there is a possiblity of misspelling, my suggestion for any long, hard-coded path in Windows would be to: 1. Make sure that the address bar is showing in Windows Ecplorer, and that your options are set to show the full path 2. Select the directory/file you are looking for and copy the location. Don't know if this will help, or if there is any sort of s[elling error involved. I do know that at least Perl 5.8 ActiveState, is quite adept at handling long filenames: Greetings! E:\d_drive\perlStuffperl -w open IN, 'C:\Documents and Settings\rjnewton\Desktop\test_reg.reg' or die Could not open: $!; print for (IN); close IN; ^Z HKEY_LOCAL_MACHINE\\SOFTWARE\\R. J. Newton [EMAIL PROTECTED] HKEY_LOCAL_MACHINE\\SOFTWARE\\R. J. Newton IdeaWorks\\TestReg\\Success\\is sweet Greetings! E:\d_drive\perlStuffperl -w open IN, 'C:\Documents and Settings\rjnewton\Desktop\Windows Media Player' or di e Could not open: $!; print for (IN); close IN; ^Z Could not open: No such file or directory at - line 1. Greetings! E:\d_drive\perlStuffperl -w open IN, 'C:\Documents and Settings\rjnewton\Desktop\Windows Media Player.lnk' o r die Could not open: $!; print for (IN); close IN; ^Z L ?¶? ? FÅ P? ?d??li??? ?Wñ}í?? ? ? £ ¶ ?P?O? ?:i?ó +00¥? #C:\ 1ä% 1 b.?¶1 Program Files PROGRA~1 , 1 b.?¶0 Windows Media Playe r WINDOW~2 ? 2 ? î-p? wmplayer.exea ? ? ? - ` ? ? x\? ?C:\Program Files\Windows Media Player\wmplayer.exe J P l a y s y o u r d i g i t a l m e d i a i n c l u d i n g m u s i c , v i d e o s , C D s , a n d I n t e r n e t R a d i o . 8 . . \ . . \ . . \ P r o g r a m F i l e s \ W i n d o w s M e d i a P l a y e r \ w m p l a y e r . e x e ? ? á R ` ? áX joseph_home ??â:0yBM½?C??~§e?3??L??ó? P?C ĺ??â:0yBM½?C??~§e?3??L??ó? P?Cĺ I'd say chek your spelling. All of the above were done using the method I described. The only hack I had to apply was to add the still-hidden .lnk extension [it's one of a small set that is hidden even when standard extensions are shown. I'll track down the Registry setting later.] Remember KISS. Apply minimal hacking, you should get good results. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Stupid Question
Joseph wrote: John W. Krahn wrote: Jason Dusek wrote: Hi Perl Beginners, Hello, Let's say I have a hash of hashes. And I want to use it over and over again, so I need to reinitialize it often. I suppose I could go through each key in the hash of hashes, and go through each key in the little hashes and use delete on each of them. But isn't there some elegant way? Does Perl have a nuke() operator? If you want to clear out the hash completely then: %hash = (); Will remove all the keys and values from the hash. This will also work with a hash of hashes. Or if you need to reinitialize it you can just assign the key/value pairs to the hash: %hash = ( newkey1 = 'newval1', newkey2 = 'newval2' ); Which will assign the new list, replacing anything that was in there before. John Thanks, John, That indeed is one of the conveniences that makes one truly appreciate the beauty of Perl reference-counting, anonymous data structures, and the use of references. Makes cleanups fast and easy. Hi Joseph. I agree with your point, but there's no reference counting involved here (unless the hash values were themselves references). Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: problems with regular expressions
Dan Anderson wrote: I have a regular expression that looks like: $foo =~ s[class.*?=.*?'.*?'][]sgi; The problem I run into is that if the following is presented to match: table class='foo'tr class='baz'td class='bar' The regular expression will match: class='foo'tr class='baz'td class='bar' And I'll get: table Is there any way I can tell the .*? to match as well as .? Thanks in advance, Dan What is it that you are trying to achieve? Using real, rather than generalized, examples, will help a lot. It sounds sort of like you are trying to strip extraneous tags. What are the standards by which you decide which are extraneous? Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Stupid Question
Rob Dixon wrote: Joseph wrote: %hash = (); Hi Joseph. I agree with your point, but there's no reference counting involved here (unless the hash values were themselves references). Rob I'll be darned, you're right. I just noticed, as I was about to argue the contrary, that hash was declared statically with %. I so rarely do this, especially if I'm intending to build a mutlidimensional structure, that I assumed the base variable was a reference to an anonymous hash. Even so, I think that the internal hashes are kept alive by the refeences to them within the structure., and therefore are freed when the hash elements referring to them no longer exist. If I'm missing something here, let me know. Clearly if his structure is working as a multidimesional one, then it has to be held together through references, because we know the flattening that takes place when any whole structure inserted into an array or hash. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Stupid Question
On Nov 29, 2003, at 12:29 PM, Rob Dixon wrote: [..] I agree with your point, but there's no reference counting involved here (unless the hash values were themselves references). Rob I think that is a part of the issue that folks need to also be thinking about when they are putting together HoH and the like. As a general rule simple things are simple the problem of course is that Perl can let one get complex Real Quickly. As most folks notice, we keep seeing the general how do I create dynamic variables from this list of things I read from some file, so that I can do and we have to remind them, that while it is possible to smack in the no strict 'refs'; to work around the 'kvetching' there are good reasons to avoid bad ju-ju that comes down that lane. The same is unfortunately involved in the whole 'reference count' mechanism that perl uses for memory management. So while hashes, and hash references are core to perl's slickness, they are not 'free' and folks need to do some basic design work about what type of data structures are they using, what are their scoping issues, and are they 'hacking' themselves into a corner either by trying to be TOO Cleaver, or Too 'able to extend' and... all the same vices that plague 'real coders' programming in 'RealCodingLanguages' on RealOS's... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Stupid Question
Rob Dixon wrote: Joseph wrote: John W. Krahn wrote: If you want to clear out the hash completely then: %hash = (); Will remove all the keys and values from the hash. This will also work with a hash of hashes. Or if you need to reinitialize it you can just assign the key/value pairs to the hash: %hash = ( newkey1 = 'newval1', newkey2 = 'newval2' ); Which will assign the new list, replacing anything that was in there before. That indeed is one of the conveniences that makes one truly appreciate the beauty of Perl reference-counting, anonymous data structures, and the use of references. Makes cleanups fast and easy. I agree with your point, but there's no reference counting involved here (unless the hash values were themselves references). AFAIK all variables have a reference count. $ perl -e' use Devel::Peek; $c = 1;Dump $c; our $d = 2;Dump $d; my $e = 3;Dump $e; @f = 4;Dump @f; %g = ( 5, 6 ); Dump %g; ' SV = IV(0x8100f30) at 0x810a968 REFCNT = 1 FLAGS = (IOK,pIOK,IsUV) UV = 1 SV = IV(0x8100f34) at 0x810a8b4 REFCNT = 1 FLAGS = (IOK,pIOK,IsUV) UV = 2 SV = IV(0x8100f38) at 0x810da98 REFCNT = 1 FLAGS = (PADBUSY,PADMY,IOK,pIOK,IsUV) UV = 3 SV = IV(0x8100f3c) at 0x80f47a0 REFCNT = 1 FLAGS = (IOK,pIOK,IsUV) UV = 4 SV = PV(0x80f4a6c) at 0x80f46b0 REFCNT = 1 FLAGS = (TEMP,POK,pPOK) PV = 0x8104030 5\0 CUR = 1 LEN = 2 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
scalars lists
If I have a scalar variable that itslef is a list of names, for example $names = 'john, jack, albert, timmy; is it possible, and if so how can it be done to separate the individual names from the list in their scalar form in order to create a new list of sorted names. thanks for any suggestions. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: scalars lists
On Nov 30, 2003, at 1:45 AM, B. Rothstein wrote: If I have a scalar variable that itslef is a list of names, for example $names = 'john, jack, albert, timmy; is it possible, and if so how can it be done to separate the individual names from the list in their scalar form in order to create a new list of sorted names. thanks for any suggestions. my @names = sort split /, ?/, $names; G'Night and good luck. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]