perl module to prevent auto registration scripts
Hello all, I am writing a web based registration module. I want to prevent people writing automated scripts ( like using lwp ) and auto register Something like what yahoo does , put a number in a jpg image and ask the user to fill in the number , which ( I think ?) a program can not do Any pointers to a CPAN module I can use Thanks Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
text modify
Hi, I have some data column based data I want to modify a bit. 0065 663 517 046 0 1485 0065 663 517 046 3 1500 0065 663 517 046 5 1882 0120 620 515 919 0 1485 0120 620 515 919 6 1816 0120 620 515 919 8 2136 I would like to add a counter to column 5 to fill out the gaps in between e.g. 0 and 10 - but doing so without changing the other columns values until column 4 itself changes values My result would look like: 0065 663 517 046 0 1485 0065 663 517 046 1 1485 0065 663 517 046 2 1485 0065 663 517 046 3 1500 0065 663 517 046 4 1500 0065 663 517 046 5 1882 0120 620 515 919 0 1485 0120 620 515 919 1 1485 0120 620 515 919 2 1485 0120 620 515 919 3 1485 0120 620 515 919 4 1485 0120 620 515 919 5 1485 0120 620 515 919 6 1816 0120 620 515 919 7 1816 0120 620 515 919 8 1485 My initial idea was to compare (in a while loop) the value in column 4 with the previous line. However, I cannot figure out how to save the "comparing" variable. Any ideas how to get started on this? Thanks Cheers, Jakob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl interface
- Original Message - From: "yomna el-tawil" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, November 09, 2003 6:14 PM Subject: Perl interface >..If anyone heard about BioPerl, is > it more efficient to use it instead of PERL to make > pattern matching for the genetic code? > Thank you for being concerened and please somebody > reply sn :) > Thank you all BioPerl is a collection of module to manage biological sequences, annotation, parse the output of the standard programs used in this field and so on. You can find very useful, in your situation, its management of very large sequences with a very fine system of IO. In general pattern matching is not different between PERL and BioPerl, but with a better IO you can use BioPerl to manage sequences, some biological toolkit like EMBOSS (www.emboss.org) in order to analize your sequences and then parsing the outputs with BioPerl that have a lot of parser. In this way you remain into the higher standard of biological community and you have no to worry about memory usage, dimension of file and so on. Take a look at: http://www.bioperl.org/Core/Latest/bptutorial.html and then if you want more http://doc.bioperl.org/ Remo _ Remo Sanges - Ph.D. Student BioGeM - IGB Gene Expression & Sequencing Core Lab Via Pietro Castellino 111 80131 Naples - Italy Tel:+390816132303 - Fax:+390816132262 [EMAIL PROTECTED] - [EMAIL PROTECTED] _ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: text modify
<[EMAIL PROTECTED]> wrote: > > I have some data column based data I want to modify a bit. > > 0065 663 517 046 0 1485 > 0065 663 517 046 3 1500 > 0065 663 517 046 5 1882 > 0120 620 515 919 0 1485 > 0120 620 515 919 6 1816 > 0120 620 515 919 8 2136 > > I would like to add a counter to column 5 to fill out the gaps > in between e.g. 0 and 10 - but doing so without changing the > other columns values until column 4 itself changes values > > My result would look like: > 0065 663 517 046 0 1485 > 0065 663 517 046 1 1485 > 0065 663 517 046 2 1485 > 0065 663 517 046 3 1500 > 0065 663 517 046 4 1500 > 0065 663 517 046 5 1882 > 0120 620 515 919 0 1485 > 0120 620 515 919 1 1485 > 0120 620 515 919 2 1485 > 0120 620 515 919 3 1485 > 0120 620 515 919 4 1485 > 0120 620 515 919 5 1485 > 0120 620 515 919 6 1816 > 0120 620 515 919 7 1816 > 0120 620 515 919 8 1485 > > My initial idea was to compare (in a while loop) the value in > column 4 with the previous line. However, I cannot figure out > how to save the "comparing" variable. > > Any ideas how to get started on this? > Thanks I think the program below will do what you want. Cheers, Rob use strict; use warnings; my @last_data; while () { my @data = split; if (@last_data and $last_data[3] == $data[3]) { while (++$last_data[4] < $data[4]) { printf "%04d %03d %03d %03d %2d %04d\n", @last_data; } } printf "%04d %03d %03d %03d %2d %04d\n", @data; @last_data = @data; } __DATA__ 0065 663 517 046 0 1485 0065 663 517 046 3 1500 0065 663 517 046 5 1882 0120 620 515 919 0 1485 0120 620 515 919 6 1816 0120 620 515 919 8 2136 **OUTPUT** 0065 663 517 046 0 1485 0065 663 517 046 1 1485 0065 663 517 046 2 1485 0065 663 517 046 3 1500 0065 663 517 046 4 1500 0065 663 517 046 5 1882 0120 620 515 919 0 1485 0120 620 515 919 1 1485 0120 620 515 919 2 1485 0120 620 515 919 3 1485 0120 620 515 919 4 1485 0120 620 515 919 5 1485 0120 620 515 919 6 1816 0120 620 515 919 7 1816 0120 620 515 919 8 2136 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Module Object and sub module function
R. Joseph Newton wrote: > > Dan Muey wrote: > > > > > > > Basically I use the ParentName's $obj inside my functions > > and they are expecting it as the first arg. > > > > $obj->MyModule::function($arg); would be the coolest way > > (leaving my functions as sub function instead of sub > > NameSpace::Evil::function) > > > > Is this possible or am I just batty!? > > > > Absolutely on the mark! Bravo! > > Then catch it in the function with: > my $self = shift; [snip] Do you mean what you say Joseph? $obj->MyModule::function($arg) Whether MyModule is the base class or the subclass it goes against all principles of inheritance. $obj knows its own class, and a call to $obj->function() will pick the correct definitian of function() according to that class. Fully qualifying the function identifier makes nonsense of calling it via an object. Or am I missing something? Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How best to grab SQL table names?
Dan Anderson wrote: > > I've got a script that goes through SQL files and returns an array of > table names. To find table names I use: > > while ($_ = ) { > if ($_ =~ m/CREATE.*TABLE/) { > $_ = $'; > while (not ($_ =~ m/)//)) { # match last parenthesis >$_ .= ; > } > my $table_name = $`; > $table_name = tr/ \t\n\r//d; > return $table_name; > } > } > > My Programming Perl book says not to use $' $` and $&. Is there a > better way to do this? Hi Dan. Your code won't compile, so I'm guessing hard at what you're trying to do. The best way to present a problem to the group is in plain English, not in the form of non-funtional Perl that we have to backtrack to understand what you meant. I think you're trying to scan an SQL 'CREATE TABLE' statement, and grab the name of the table and all of the field specifications. Or something like that. This isn't hard even without the 'forbidden' $' $` and $& but, even though my belief is that people who avoid them are phobic, they don't help here at all! Explain your problem more clearly, with an example of your data, and we'll be able to help. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is it Possible: Caching Perl Compilations
Dan Anderson wrote: > > Is it possible to cache Perl compilations on a web server so that it > runs faster? Hi Dan. It depends why you're compiling at run time. Something like my $sub = eval 'sub { 9 + 9 }'; print $sub->(), "\n"; will stay compiled as long as you have $sub as a reference. Obviously you can build the 'eval'ed string how you like before it's compiled. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl module to prevent auto registration scripts
On Sunday, Nov 9, 2003, at 23:25 US/Pacific, Ramprasad A Padmanabhan wrote: [..] I am writing a web based registration module. I want to prevent people writing automated scripts ( like using lwp ) and auto register [..] The recent discussion about how Google has attempted to control access to it's site has shown that this is really not as easy as it sounds. IF one checks for the 'browser type', then the person using lwp will need to 'spoof' an acceptable $ua->agent($correct_type); prior to calling your web-site. You could try the 'check to see if one can set a cookie' but that would be problematic, since again the coder with lwp could deal with that problem. In essence you are trying to solve the turing test by establishing that the thing you are 'talking with' is actually a human and not an automaton. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: perl module to prevent auto registration scripts
Can't you add one of those image words that you have to type in. Also why do this. A website provides content. Its not any of the providers business how I view it or what I do with it afterwards. Paul -Original Message- From: drieux [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 11:53 AM To: begin begin Subject: Re: perl module to prevent auto registration scripts On Sunday, Nov 9, 2003, at 23:25 US/Pacific, Ramprasad A Padmanabhan wrote: [..] >I am writing a web based registration module. I want to prevent > people writing automated scripts ( like using lwp ) and auto register [..] The recent discussion about how Google has attempted to control access to it's site has shown that this is really not as easy as it sounds. IF one checks for the 'browser type', then the person using lwp will need to 'spoof' an acceptable $ua->agent($correct_type); prior to calling your web-site. You could try the 'check to see if one can set a cookie' but that would be problematic, since again the coder with lwp could deal with that problem. In essence you are trying to solve the turing test by establishing that the thing you are 'talking with' is actually a human and not an automaton. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How best to grab SQL table names?
On Sunday, Nov 9, 2003, at 16:32 US/Pacific, Dan Anderson wrote: [..] while ($_ = ) { if ($_ =~ m/CREATE.*TABLE/) { $_ = $'; while (not ($_ =~ m/)//)) { # match last parenthesis $_ .= ; } my $table_name = $`; $table_name = tr/ \t\n\r//d; return $table_name; } } My Programming Perl book says not to use $' $` and $&. Is there a better way to do this? well a bit of it has to do with how the Perl Regular Expression Engine works, the other part has to do with making your code a bit more readable, and maintainable. The use of the $' and $` as the "perldoc perlvar" pages will tell you imposes a considerable performance penalty. right, a bit of clean up of the code: while () { # it will set the line to $_ by default # cut off everything BEFORE our 'pattern' if ( s/.*CREATE.*TABLE//) { chomp; # remove any 'newline tokens' my $line = $_ ; # save off what we have # read until we have come to the closing paren while ( $line !~ m/\)/ ) { $_ = ; chomp; $line .= $_; } # we will either have seen that last paren, or it did not exist ( my $table_name = $line ) =~ s/.*\)//; $table_name = tr/ \t\n\r//d; return $table_name; } # found opening line }# end while loop being a bit of a tight translation. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Died on open command
Hello all, I'm starting to learn perl to convert files between different bioinformatics programs. I'm aware of bioperl but want to learn some basic perl before using those modules. 1) The script is in the same directory as the input folder, so open should be able to find it. 2) The open input folder part works because I get a I get a list of the files. 3) The whole program worked on a single file, but died when I tried to convert it to handle a whole directory as input. 4) I'm developing on a Windows machine, so I think setting file permissions are unnecessary, right? Here's the code snippet: use warnings; use strict; my @files = (); my $folder = 'input'; # Open the input folder unless (opendir(FOLDER, $folder)) { print "Cannot open folder $folder!\n\n"; exit; } #read the contents of the folder (files and subfolders) @files = readdir(FOLDER); #Close the folder print "\n\n Here are the files in the folder\n"; #print out the filenames, one per line print join( "\n", @files), "\n"; closedir(FOLDER); foreach my $seqfilename (@files){ [EMAIL PROTECTED] = @_; $seqfilename = ''; open (TXTFILE,"<$seqfilename") or die $!; close TXTFILE; my @seqelements = ; ...goes on from here I know the conversion routine works, because it worked when I specified a single file. Thanks for your help in advance, Ganesh -- Ganesh Shankar [EMAIL PROTECTED] -- http://www.fastmail.fm - A fast, anti-spam email service. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl module to prevent auto registration scripts
On Monday, Nov 10, 2003, at 08:59 US/Pacific, Paul Kraus wrote: [..] Also why do this. A website provides content. Its not any of the providers business how I view it or what I do with it afterwards. I am not the person to answer the 'why' for doing silly things, there is probably someone in the 'legal' and/or 'marketting' department who comes up with the 'hey what if we did...' sets of requirements. There is also the problem with 'copyright laws' and that 'fair use' is one thing, but beyond that, one has embarked upon merely plagarism and 'theft of intellectual property'. The Yahoo image trick has the complication for some of my optically challenged friends, in that they can not always pick out the 'number' if the 'hue shifts' are not smack dab in the middle of their limited RGB processing. Those folks do not 'dress badly' because they are 'fashion challenged' they do so because they can not tell that certain hues in the visual spectrum, are, well GARISH TOGETHER on planet earth. { probably on their home planet the atmosphere protects them from this problem, since the light refracted from their sun does not provide the full range as we get here. but should we be prejudiced against the non-terran? I mean, how would we look in their native atmosphere? The question what is the colour of the sky in your world? is not merely a pejorative you know. } ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
Ganesh Shankar wrote: > > Hello all, Hello, > I'm starting to learn perl to convert files between different > bioinformatics programs. I'm aware of bioperl but want to learn some > basic perl before using those modules. > > 1) The script is in the same directory as the input folder, so open > should be able to find it. > > 2) The open input folder part works because I get a I get a list of the > files. > > 3) The whole program worked on a single file, but died when I tried to > convert it to handle a whole directory as input. > > 4) I'm developing on a Windows machine, so I think setting file > permissions are unnecessary, right? This problem is described is explained in the documentation for the readdir function. perldoc -f readdir [snip] If you're planning to filetest the return values out of a `readdir', you'd better prepend the directory in question. Otherwise, because we didn't `chdir' there, it would have been testing the wrong file. > Here's the code snippet: > > use warnings; > use strict; > > my @files = (); > my $folder = 'input'; > # Open the input folder > unless (opendir(FOLDER, $folder)) { > print "Cannot open folder $folder!\n\n"; > exit; > } > > #read the contents of the folder (files and subfolders) > @files = readdir(FOLDER); > > #Close the folder > print "\n\n Here are the files in the folder\n"; > #print out the filenames, one per line > print join( "\n", @files), "\n"; > closedir(FOLDER); > > foreach my $seqfilename (@files){ > [EMAIL PROTECTED] = @_; > $seqfilename = ''; > open (TXTFILE,"<$seqfilename") or die $!; open (TXTFILE,"<$folder/$seqfilename") or die $!; > close TXTFILE; > > my @seqelements = ; > > ...goes on from here > I know the conversion routine works, because it worked > when I specified a single file. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
On Monday, Nov 10, 2003, at 09:30 US/Pacific, John W. Krahn wrote: Ganesh Shankar wrote: [..] 4) I'm developing on a Windows machine, so I think setting file permissions are unnecessary, right? This problem is described is explained in the documentation for the readdir function. perldoc -f readdir [snip] If you're planning to filetest the return values out of a `readdir', you'd better prepend the directory in question. Otherwise, because we didn't `chdir' there, it would have been testing the wrong file. [..] foreach my $seqfilename (@files){ [EMAIL PROTECTED] = @_; $seqfilename = ''; open (TXTFILE,"<$seqfilename") or die $!; open (TXTFILE,"<$folder/$seqfilename") or die $!; john, I agree with your basic solution, but since he will be doing his development in Windows, shouldn't that be 'file system neutral'? hence not using the unix separator "/" between the directory component and the filename component? Hence that the OP should do the chdir($folder); since he has already established that the directory existed when collecting up the list of files for 'input', and this should be done prior to doing the foreach my $seqfilename (@files){ open (TXTFILE,"<$seqfilename") or die $!; ... } so that the code will 'work' on more OS's. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Died on open command
> I agree with your basic solution, but since he will > be doing his development in Windows, shouldn't that > be 'file system neutral'? hence not using the unix > separator "/" between the directory component and the filename > component? In a move to simplify porting of scripts (and save the sanity of Windows Perl coders), ActiveState made it so that the "/" path separator works on Windows too, and is converted internally. We don't have to think about it. And it's easier than trying to remember to escape backslashes, too. :-) So the solution proposed will work fine on Unix, Windows, MacOSX, etc. Just FYI. J-S _ Jean-Sébastien Guay -- Conseiller technique - Administration -- (514) 522-9800 #4840 -- [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
Guay jean-Sébastien wrote: > > > I agree with your basic solution, but since he will > > be doing his development in Windows, shouldn't that > > be 'file system neutral'? hence not using the unix > > separator "/" between the directory component and the filename > > component? > > In a move to simplify porting of scripts (and save the sanity of Windows > Perl coders), ActiveState made it so that the "/" path separator works on > Windows too, and is converted internally. We don't have to think about it. > And it's easier than trying to remember to escape backslashes, too. :-) > > So the solution proposed will work fine on Unix, Windows, MacOSX, etc. > > Just FYI. It has nothing to do with what ActiveState did or didn't do. The DOS/Windows command interpreter (command.com/cmd.exe) uses '\' as the path separator however the operating system itself is able to use '/' as the path separator. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Adding a printer remotely
Hello, Does anyone know how to add a printer in Perl remotely on a NT 4 system? I have been googling for a while and found some info about WSH and cscript, but it doesn't work on NT. (or I haven't figured it out yet). Please advise any possibilities that you might have. Ned Cunningham POS Systems Development Monro Muffler Brake 200 Holleder Parkway Rochester, NY 14615 (585) 647-6400 ext. 310 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
On Monday, Nov 10, 2003, at 10:17 US/Pacific, Guay Jean-Sébastien wrote: [..] I agree with your basic solution, but since he will be doing his development in Windows, shouldn't that be 'file system neutral'? hence not using the unix separator "/" between the directory component and the filename component? In a move to simplify porting of scripts (and save the sanity of Windows Perl coders), ActiveState made it so that the "/" path separator works on Windows too, and is converted internally. We don't have to think about it. And it's easier than trying to remember to escape backslashes, too. :-) Props for doing the Right Thing! This will clearly help moi as I dodder around from OS to OS, and whine about 'the good old days' 8-) Which version of Perl from ActiveState did this show up in? ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Died on open command
> It has nothing to do with what ActiveState did or didn't do. The > DOS/Windows command interpreter (command.com/cmd.exe) uses '\' as the > path separator however the operating system itself is able to use '/' as > the path separator. Sorry, I just tried it on my machine here (NT4), and doing cd winnt/system32 from the C: directory gets me into the C:\winnt directory, whereas doing cd winnt\system32 gets me into the C:\winnt\system32 directory, as it should. I tried it before I sent the mail. Now perhaps the cmd.exe for Win2000 and up does what you describe. But since opening a file with slashes in its path works in perl even on my machine, where using slashes at the prompt doesn't work, I would say ActiveState had something to do with it. Perhaps they just ironed out some of the differences between the versions of cmd.exe... Anyways, it's irrelevant, it works, so let's just use it, regardless of who's to blame (err, thank). J-S _ Jean-Sébastien Guay -- Conseiller technique - Administration -- (514) 522-9800 #4840 -- [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Died on open command
> It has nothing to do with what ActiveState did or didn't do. The > DOS/Windows command interpreter (command.com/cmd.exe) uses '\' as the > path separator however the operating system itself is able to use '/' as > the path separator. Err, just noticed I shouldn't have read so quick... Still, since cmd.exe goes to great lengths to prevent us from using the slash, forcing the backslash onto us, I thank ActiveState for not going the same way. :-) Thanks for rectifying things. J-S _ Jean-Sébastien Guay -- Conseiller technique - Administration -- (514) 522-9800 #4840 -- [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
On Nov 10, 2003, at 12:39 PM, Guay Jean-Sébastien wrote: It has nothing to do with what ActiveState did or didn't do. The DOS/Windows command interpreter (command.com/cmd.exe) uses '\' as the path separator however the operating system itself is able to use '/' as the path separator. Sorry, I just tried it on my machine here (NT4), and doing cd winnt/system32 from the C: directory gets me into the C:\winnt directory, whereas doing cd winnt\system32 That's exactly what John said. ;) The command interpreter, what you are using above, is dumb and doesn't know the difference. The OS does though and since Perl talks to the OS itself, it works as expected. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Died on open command
> Which version of Perl from ActiveState did this show up in? Well, seems ActiveState didn't really have to do anything after all, according to John W. Krahn. As far as I remember, it's always been like that in ActiveState Perl. But as I said, I still find it great that they didn't do anything to go against what ends up being a great benefit for us multiplatform Perl coders. :-) J-S _ Jean-Sébastien Guay -- Conseiller technique - Administration -- (514) 522-9800 #4840 -- [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
[EMAIL PROTECTED] wrote: It has nothing to do with what ActiveState did or didn't do. The DOS/Windows command interpreter (command.com/cmd.exe) uses '\' as the path separator however the operating system itself is able to use '/' as the path separator. Sorry, I just tried it on my machine here (NT4), and doing cd winnt/system32 from the C: directory gets me into the C:\winnt directory, whereas doing cd winnt\system32 gets me into the C:\winnt\system32 directory, as it should. I tried it before I sent the mail. Now perhaps the cmd.exe for Win2000 and up does what you describe. But since opening a file with slashes in its path works in perl even on my machine, where using slashes at the prompt doesn't work, I would say ActiveState had something to do with it. Perhaps they just ironed out some of the differences between the versions of cmd.exe... Anyways, it's irrelevant, it works, so let's just use it, regardless of who's to blame (err, thank). J-S _ Jean-Sébastien Guay -- Conseiller technique - Administration -- (514) 522-9800 #4840 -- [EMAIL PROTECTED] Just tried on my WindowsXP box. I had to enclose the path in double quotes. But once I did that, Windows did the right thing, dir "\temp" dir "/temp" both give me the temp directory listing. Using single quotes or backticks does not work. Chuck
RE: Died on open command
> That's exactly what John said. ;) I realized that 5 seconds after I sent the mail... <:-( -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Died on open command
> -Original Message- > From: Guay Jean-Sébastien > [mailto:[EMAIL PROTECTED] > Sent: Monday, November 10, 2003 10:43 AM > To: 'John W. Krahn'; 'Perl-Beginners' > Subject: RE: Died on open command > > > > It has nothing to do with what ActiveState did or didn't do. The > > DOS/Windows command interpreter (command.com/cmd.exe) uses > '\' as the > > path separator however the operating system itself is able > to use '/' as > > the path separator. > > Err, just noticed I shouldn't have read so quick... > > Still, since cmd.exe goes to great lengths to prevent us from > using the > slash, forcing the backslash onto us, I thank ActiveState for > not going the > same way. :-) > > Thanks for rectifying things. > Well, cmd.exe just has a different meaning for /. cmd uses / to pass in options, instead of -, and spaces between the command and options is, well, optional. So, the command: cd winnt/system32 means cd to winnt and pass the option "system32" to the cd command, which does nothing. But, to override this behavior, use quotes around the directory name: C:\>cd "winnt/system32" C:\WINNT\system32> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
> > On Monday, Nov 10, 2003, at 10:17 US/Pacific, Guay Jean-Sébastien wrote: > [..] > >> I agree with your basic solution, but since he will > >> be doing his development in Windows, shouldn't that > >> be 'file system neutral'? hence not using the unix > >> separator "/" between the directory component and the filename > >> component? > > > > In a move to simplify porting of scripts (and save the sanity > > of Windows Perl coders), ActiveState made it so that the "/" path > > separator works on Windows too, and is converted internally. > > We don't have to think about it. And it's easier than trying to > > remember to escape backslashes, too. :-) > > Props for doing the Right Thing! > > This will clearly help moi as I dodder around from > OS to OS, and whine about 'the good old days' 8-) > > Which version of Perl from ActiveState did this show up in? > > ciao > drieux > This is where I very quickly run across the stage yelling "File::Spec->catfile" and then just as abruptly as I entered, exit stage left... http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Adding a printer remotely
I Don't understand what you mean... Are you asking how to attach to a printer that is on your network? Is the printer have its own ip address ? Or is it shared on a windows machine on that network. \\111.111.111.111 to attach to the ip assigned printer \\machine\sharename(akaprintername) to attach to the printer on a windows machine. Not sure how you would do it in perl but it shouldn't be to hard using the supplied info. That's assuming I understand you correctly. Describe what you want to do and then let us decide on what's relevant as far as info goes :) Paul Kraus -Original Message- From: Ned Cunningham [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 1:39 PM To: [EMAIL PROTECTED] Subject: Adding a printer remotely Hello, Does anyone know how to add a printer in Perl remotely on a NT 4 system? I have been googling for a while and found some info about WSH and cscript, but it doesn't work on NT. (or I haven't figured it out yet). Please advise any possibilities that you might have. Ned Cunningham POS Systems Development Monro Muffler Brake 200 Holleder Parkway Rochester, NY 14615 (585) 647-6400 ext. 310 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Adding a printer remotely
Ok, I have 500 remote locations. They consist of 2 networked nt 4 sp6 workstations. Remotely, that is by sending a CD or by a polling program, I need to add a printer. Both WK2 and XP has this functionality, however NT does not, (or at least I havent found it). I found a reference to using the WSH in Perl, but not examples. TIA Ned Cunningham POS Systems Development Monro Muffler Brake 200 Holleder Parkway Rochester, NY 14615 (585) 647-6400 ext. 310 [EMAIL PROTECTED] -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 2:33 PM To: Ned Cunningham; [EMAIL PROTECTED] Subject:RE: Adding a printer remotely I Don't understand what you mean... Are you asking how to attach to a printer that is on your network? Is the printer have its own IP address ? Or is it shared on a windows machine on that network. \\111.111.111.111 to attach to the IP assigned printer \\machine\sharename(akaprintername) to attach to the printer on a windows machine. Not sure how you would do it in perl but it shouldn't be to hard using the supplied info. That's assuming I understand you correctly. Describe what you want to do and then let us decide on what's relevant as far as info goes :) Paul Kraus -Original Message- From: Ned Cunningham [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 1:39 PM To: [EMAIL PROTECTED] Subject: Adding a printer remotely Hello, Does anyone know how to add a printer in Perl remotely on a NT 4 system? I have been googling for a while and found some info about WSH and cscript, but it doesn't work on NT. (or I haven't figured it out yet). Please advise any possibilities that you might have. Ned Cunningham POS Systems Development Monro Muffler Brake 200 Holleder Parkway Rochester, NY 14615 (585) 647-6400 ext. 310 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Adding a printer remotely
> -Original Message- > From: Ned Cunningham [mailto:[EMAIL PROTECTED] > Sent: Monday, November 10, 2003 12:07 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: Adding a printer remotely > > > Ok, > > I have 500 remote locations. They consist of 2 networked nt > 4 sp6 workstations. > > Remotely, that is by sending a CD or by a polling program, I > need to add a printer. > > Both WK2 and XP has this functionality, however NT does not, > (or at least I havent found it). I done some things like this with policies and with startup batch jobs. Just need to know if the printer is a network printer, or a printer connected locally at each remote location, possibly different printer models. I'm wondering if this will have a perl solution, maybe not. -Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
Guay jean-Sébastien wrote: > > > Which version of Perl from ActiveState did this show up in? > > Well, seems ActiveState didn't really have to do anything after all, > according to John W. Krahn. As far as I remember, it's always been like that > in ActiveState Perl. IIRC the ability to use / instead of \ has been available since DOS 3.0. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Peculiar problem using LWP::UserAgent
I ran into peculiar problem using LWP::UserAgent. I receive a 501 - Not yet implemented error when I connect to a web-server using the User-Agent. This happens when I pass in the Hostname and Portnumber as parameters in my function. However, if I hard-code the Server-name and port number it seems to work fine. I've included the piece of causing the problem below. Does anyone have suggestion why this is happening? my ( $Host, $Port ) = @_; my $url = "$Host:$Port"; #Does not work #my $url = "http://servername:80";#This works require LWP::UserAgent; my $ua = LWP::UserAgent->new(env_proxy => 0, keep_alive => 0, timeout => 30, ); $response = $ua->get( $url ); Thanks in Advance, Rajesh Dorairajan
Playing with Numbers
Hi all, i'm trying to figure out how to test if a number is five digits and if not add zero/s in front to make it 5 digits. Any ideas? Examples: 444 = 00444 4120 = 04120 23 = 00023 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Playing with Numbers
> -Original Message- > From: SilverFox [mailto:[EMAIL PROTECTED] > Sent: Monday, November 10, 2003 1:14 PM > To: [EMAIL PROTECTED] > Subject: Playing with Numbers > > > Hi all, i'm trying to figure out how to test if a number is > five digits and > if not add zero/s in front to make it 5 digits. Any ideas? > > Examples: > > 444 = 00444 > 4120 = 04120 > 23 = 00023 > What if the number is greater than 5 digits? For the input you provide, this works: my $five_digit_number = sprintf "%05d", $original_number; If the number is 5 or more digits, then just the original number is returned. -Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Playing with Numbers
my $integer = 432; my $string = sprintf("%05d", $integer); Yay! J-S -Message d'origine- De: SilverFox [mailto:[EMAIL PROTECTED] Date: 10 novembre, 2003 16:14 À: [EMAIL PROTECTED] Objet: Playing with Numbers Hi all, i'm trying to figure out how to test if a number is five digits and if not add zero/s in front to make it 5 digits. Any ideas? Examples: 444 = 00444 4120 = 04120 23 = 00023 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Representing a Database as XML
Does anyone know of a good module to use to represent a database (or SQL statements) as XML? I'm trying to throw together something that will work with different databases. I want to create a "translator" that will change from the XML to database specific SQL. Thanks in advance, Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
More died on open command (from 55103)
Hello all, I tried modifying the open command ar suggested and got the enclosed errors. Also, I'm working with Activestate Activeperl 5.6 on a Windows 2000. Also, from the syntax of the readdir example, the test is to the left of the readdir command. Does this mean I should place my file processing block to the left of the readdir command. That would be one ugly statement. Thanks for all the help. -Ganesh snippet: use warnings; use strict; my @files = (); my $folder = 'input'; # Open the input folder unless (opendir(FOLDER, $folder)) { print "Cannot open folder $folder!\n\n"; exit; } #read the contents of the folder (files and subfolders) chdir($folder); #added this line after failing with open commands below. print "Switching to folder $folder!\n\n"; # It's going to the correct folder @files = readdir(FOLDER); #Close the folder print "\n\n Here are the files in the folder\n"; #print out the filenames, one per line print join( "\n", @files), "\n";# Prints out correct filenames closedir(FOLDER); foreach my $seqfilename (@files){ $seqfilename = ''; open (TXTFILE,"<$seqfilename") or die $!; #dies on this line.Replace with open (TXTFILE,"<$folder/$seqfilename") or die $!; #Invalid argument at this line. Replace with open (TXTFILE,"<$folder\$seqfilename") or die $!; #No such file or directory error at this line close TXTFILE; my @seqelements = ; ...goes on from here I know the conversion routine works, because it worked when I specified a single file -- Ganesh Shankar [EMAIL PROTECTED] -- http://www.fastmail.fm - Or how I learned to stop worrying and love email again -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
drieux wrote: > john, > > I agree with your basic solution, but since he will > be doing his development in Windows, shouldn't that > be 'file system neutral'? hence not using the unix > separator "/" between the directory component and the filename > component? Nope. Not at all. System transparency means not having to concern yourself with the system or its quirks, which is what Perl provides in re file access. Not because the '/' separator is 'nix, but because it is more standard for file systems in general, inclucing URLs and URIs. Perl will translate per system under the surface. Where you do have to take note of Windows delimiters is in shelling out. That is one of the many related reasons why people advise against shelling out for functionality. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
Guay Jean-Sébastien wrote: > > It has nothing to do with what ActiveState did or didn't do. The > > DOS/Windows command interpreter (command.com/cmd.exe) uses '\' as the > > path separator however the operating system itself is able to use '/' as > > the path separator. > > Sorry, I just tried it on my machine here (NT4), and doing > > cd winnt/system32 That is a Perl statement?!! Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
Chuck Fox wrote: > Just tried on my WindowsXP box. I had to enclose the path in double > quotes. But once I did that, Windows did the right thing, > > dir "\temp" > dir "/temp" > > both give me the temp directory listing. Using single quotes or > backticks does not work. > > Chuck I'll be darned! 'tworks! On W2K, too. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
On Nov 10, 2003, at 4:19 PM, R. Joseph Newton wrote: Nope. Not at all. System transparency means not having to concern yourself with the system or its quirks, which is what Perl provides in re file access. Not because the '/' separator is 'nix, but because it is more standard for file systems in general, inclucing URLs and URIs. Perl will translate per system under the surface. I'm not aware of Perl doing any translation of '/'. Someone please correct me if I'm wrong though. I believe this is why the the File::Spec modules are standard. '/' works on the majority of systems these days, but if you want true portability, I believe you want the earlier mentioned catfile(). James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Module Object and sub module function
Rob Dixon wrote: > R. Joseph Newton wrote: > > > > Dan Muey wrote: > > > > > > > > > > > Basically I use the ParentName's $obj inside my functions > > > and they are expecting it as the first arg. > > > > > > $obj->MyModule::function($arg); would be the coolest way > > > (leaving my functions as sub function instead of sub > > > NameSpace::Evil::function) > > > > > > Is this possible or am I just batty!? > > > > > > > Absolutely on the mark! Bravo! > > > > Then catch it in the function with: > > my $self = shift; > > [snip] > > Do you mean what you say Joseph? > > $obj->MyModule::function($arg) > > Whether MyModule is the base class or the subclass it goes > against all principles of inheritance. $obj knows its own > class, and a call to $obj->function() will pick the correct > definitian of function() according to that class. Fully > qualifying the function identifier makes nonsense of calling > it via an object. > > Or am I missing something? > > Cheers, > > Rob No-o-o-o, I was missing something--the package name still hanging onto the function name. Sorry, I sometimes just don't see what I would never think of looking for. All I saw was the object pointing to its method. Shoulda looked closer before I clapped. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
James Edward Gray II wrote: > On Nov 10, 2003, at 4:19 PM, R. Joseph Newton wrote: > > > Nope. Not at all. System transparency means not having to concern > > yourself with the system or its quirks, which is what Perl provides in > > re > > file access. Not because the '/' separator is 'nix, but because it is > > more standard for file systems in general, inclucing URLs and URIs. > > Perl > > will translate per system under the surface. > > I'm not aware of Perl doing any translation of '/'. Someone please > correct me if I'm wrong though. I believe this is why the the > File::Spec modules are standard. '/' works on the majority of systems > these days, but if you want true portability, I believe you want the > earlier mentioned catfile(). > > James Look down the thread, and you will find correction from others, also. I can tell you that I have generated tousands of files in folders reached by relative paths, and all I have had to offer Perl was '/'s. It has been working for some time, and quite handsomely. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
On Nov 10, 2003, at 4:47 PM, R. Joseph Newton wrote: Look down the thread, and you will find correction from others, also. I can tell you that I have generated tousands of files in folders reached by relative paths, and all I have had to offer Perl was '/'s. It has been working for some time, and quite handsomely. Let me guess, on UNIX flavors, Windows, Mac OS X and/or Linux, right? All of these OSes understand '/'. This is no Perl magic. Again, they bundle the File::Spec modules for a reason, I would bet. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Peculiar problem using LWP::UserAgent
Rajesh Dorairajan wrote: > I ran into peculiar problem using LWP::UserAgent. I receive a 501 - Not > yet implemented error when I connect to a web-server using the User-Agent. > This happens when I pass in the Hostname and Portnumber as parameters in > my function. However, if I hard-code the Server-name and port number it > seems to work fine. I've included the piece of causing the problem below. > Does anyone have suggestion why this is happening? > > > my ( $Host, $Port ) = @_; > my $url = "$Host:$Port"; #Does not work > #my $url = "http://servername:80";#This works > > require LWP::UserAgent; > my $ua = LWP::UserAgent->new(env_proxy => 0, > keep_alive => 0, > timeout => 30, > ); > > $response = $ua->get( $url ); > are you sure you construct the right path? for example: #!/usr/bin/perl -w use strict; use LWP::UserAgent; sub print_page{ my($host,$port) = @_; my $url = $host; $url .= ":$port" if($port); my $ua = LWP::UserAgent->new(env_proxy => 0, keep_alive => 0, timeout=> 30); my $r = $ua->request(HTTP::Request->new(GET => $url)); print $r->content if($r->is_success); print $r->code,': ',$r->status_line unless($r->is_success); print "\n"; } print_page('http://google.com');#-- works fine print_page('http://google.com',80); #-- works fine print_page('google.com'); #-- 400: URL must be absolute print_page('google.com',80);#-- 501: Protocol not supported __END__ you are most likely seeing the last one. make sure you specify the protocol. david -- $_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$"; map{~$_&1&&{$,<<=1,[EMAIL PROTECTED]||3])=>~}}0..s~.~~g-1;*_=*#, goto=>print+eval -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
On Monday, Nov 10, 2003, at 11:03 US/Pacific, Wiggins d Anconia wrote: [..] This is where I very quickly run across the stage yelling "File::Spec->catfile" and then just as abruptly as I entered, exit stage left... Wiggins we were having a Lovely Ideological Struggle between the Forces of WhomEver and their Opposition!!! You really should NOT be complicating the process with this Old School Tie Aproach of perldoc File::Spec hence the sort of insti-auto-majik code re-usability across the various OS's, including VMS and 'mac classic' and OS2 and At which point I think that Ideologically I would be forced to assert the part john started with but require the canonical foreach my $seqfilename (@files) { my $file = File::Spec->catfile($folder, $seqfilename); open(TXTFILE, "<$file") or die "a horrid death here because: $!\n"; } But I would like to thank those who have shared which side of the line the "\" v. "/" issues are on the Win32 side. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: More died on open command (from 55103)
Ganesh Shankar wrote: > > Hello all, Hello, > I tried modifying the open command ar suggested and got the enclosed > errors. Also, I'm working with Activestate Activeperl 5.6 on a Windows > 2000. Also, from the syntax of the readdir example, the test is to the > left of the readdir command. Does this mean I should place my file > processing block to the left of the readdir command. That would be one > ugly statement. > > [snip] > > use warnings; > use strict; > > my @files = (); > my $folder = 'input'; > # Open the input folder > unless (opendir(FOLDER, $folder)) { > print "Cannot open folder $folder!\n\n"; > exit; > } > > #read the contents of the folder (files and subfolders) > > chdir($folder); #added this line after failing with open commands below. > > print "Switching to folder $folder!\n\n"; # It's going to the correct > folder > > @files = readdir(FOLDER); > > #Close the folder > > print "\n\n Here are the files in the folder\n"; > #print out the filenames, one per line > print join( "\n", @files), "\n";# Prints out correct filenames > > closedir(FOLDER); > > foreach my $seqfilename (@files){ > > $seqfilename = ''; > open (TXTFILE,"<$seqfilename") or die $!; #dies on this line.Replace with This won't work because it is trying to open $seqfilename in the current directory. > open (TXTFILE,"<$folder/$seqfilename") or die $!; #Invalid argument at this > line. Replace with Windows apparently sends an EINVAL ("Invalid argument") when there are certain non-printable characters in the file name! (Who knew?) http://mail.python.org/pipermail/python-list/2002-March/090323.html > open (TXTFILE,"<$folder\$seqfilename") or die $!; #No such file or directory > error at this line This won't work because the backslash will escape the dollar sign. If you want the backslash character in a double quoted string you will have to escape it (precede it with a backslash.) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Peculiar problem using LWP::UserAgent
On Monday, Nov 10, 2003, at 13:16 US/Pacific, Rajesh Dorairajan wrote: [..] my ( $Host, $Port ) = @_; my $url = "$Host:$Port"; #Does not work #my $url = "http://servername:80";#This works require LWP::UserAgent; my $ua = LWP::UserAgent->new(env_proxy => 0, keep_alive => 0, timeout => 30, ); $response = $ua->get( $url ); [..] since you are planning to use the LWP user agent, and, you want to look at ONLY the 'host_port' top most connection, then why not think about it in terms of my ($host, $port, $path) = @_ my $url = "http://$host";; $url .= ":$port" if $port; $url .= $path if $path; notice that in this case you would be 'golden' with get_from_server('www.wetware.com'); get_from_server('www.wetware.com','80'); get_from_server('www.wetware.com','80','/drieux/PR/blog2/'); Then if you decide that you want to manage schema other then http you could modify it with say my ($host, $port, $path, $schema) = @_ my $url = $schema || 'http'; $url .= "://$host"; ... ah whala! ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: More died on open command (from 55103)
On Monday, Nov 10, 2003, at 13:54 US/Pacific, Ganesh Shankar wrote: [..] since you chdir INTO the $folder you need to merely fix the foreach loop: foreach my $seqfilename (@files){ $seqfilename = ''; comment out the #$seqfilename =''; otherwise the next line: open (TXTFILE,"<$seqfilename") or die $!; #dies on this line.Replace with will be interpreted as open (TXTFILE,"<") and that should DIE! since it is trying to open as input a non-existent file! [..] ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Playing with Numbers
On Monday, Nov 10, 2003, at 13:13 US/Pacific, SilverFox wrote: Hi all, i'm trying to figure out how to test if a number is five digits and if not add zero/s in front to make it 5 digits. Any ideas? Examples: 444 = 00444 4120 = 04120 23 = 00023 there are two parts to your question, the later is answered with the sprintf - cf perldoc -f sprintf, as others have noted this leaves only the RE part $token = sprintf("%05d", $token) if ($token =~ /^\d+$/ ); the 'if' condition is checking that the "$token" is all numeric from beginning to end, and if so it will sprintf() it. ciao drieux --- cf: my @list = qw( 444 4120 23 bob 12345 123456 3bob ); five_wide($_) foreach(@list); # # sub five_wide { my ($token) = @_; print "$token = "; $token = sprintf("%05d", $token) if ($token =~ /^\d+$/ ); print " $token \n"; } # end of five_wide -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
The File::Spec approach was Re: Died on open command
On Monday, Nov 10, 2003, at 14:54 US/Pacific, James Edward Gray II wrote: On Nov 10, 2003, at 4:47 PM, R. Joseph Newton wrote: Look down the thread, and you will find correction from others, also. I can tell you that I have generated tousands of files in folders reached by relative paths, and all I have had to offer Perl was '/'s. It has been working for some time, and quite handsomely. Let me guess, on UNIX flavors, Windows, Mac OS X and/or Linux, right? All of these OSes understand '/'. This is no Perl magic. Again, they bundle the File::Spec modules for a reason, I would bet. for fun, folks might want to do perldoc -m File::Spec::Win32 and one will notice the Old Dog at the top of that module package File::Spec::Win32; use strict; use Cwd; use vars qw(@ISA); require File::Spec::Unix; @ISA = qw(File::Spec::Unix); at which point there is the question about 'over-riding' those base set of methods. Also if folks Peek into File::Spec we notice that it will be checking against '$^O' and/or using 'Unix' so if the version of perl one is using is NOT returning my %module = (MacOS => 'Mac', MSWin32 => 'Win32', os2 => 'OS2', VMS => 'VMS'); then the File::Spec::Unix will be used directly. If one wants to check they can run the old scam: [jeeves: 5:] perl -e 'print "my OS is $^O\n";' my OS is darwin [jeeves: 6:] HTH. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: More died on open command (from 55103)
At 01:54 PM 11/10/03 -0800, you wrote: I tried modifying the open command ar suggested and got the enclosed errors. Also, I'm working with Activestate Activeperl 5.6 on a Windows 2000. Also, from the syntax of the readdir example, the test is to the left of the readdir command. Does this mean I should place my file processing block to the left of the readdir command. That would be one ugly statement. Hi. Ever try a glob? i.e. perl -e "@files = glob( 'C:\perl\eg\*' ); print join (\"\n\", @files), \"\n\" " [This is off a win9x platform running AS 5.6.1] I have used similar to process directories of EDI translated data; the key being I knew what to expect in terms of no hidden files, weird file names and the like. I should think if you're ramping up for sequence processing, you'd be in that kind of a situation. Of course if you have to traverse a directory tree or two, then stick with the module File::Find -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Died on open command
James Edward Gray II wrote: > On Nov 10, 2003, at 4:47 PM, R. Joseph Newton wrote: > > > Look down the thread, and you will find correction from others, also. > > I can > > tell you that I have generated tousands of files in folders reached by > > relative paths, and all I have had to offer Perl was '/'s. It has been > > working for some time, and quite handsomely. > > Let me guess, on UNIX flavors, Windows, Mac OS X and/or Linux, right? > All of these OSes understand '/'. This is no Perl magic. Again, they > bundle the File::Spec modules for a reason, I would bet. > > James Well, I was thinking specifically of Windows, since the issue arose concerning filepaths on Windows. I will take folks word on this, though, that Perl does no translation of path delimiters. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl module to prevent auto registration scripts
Drieux wrote: On Monday, Nov 10, 2003, at 08:59 US/Pacific, Paul Kraus wrote: [..] Also why do this. A website provides content. Its not any of the providers business how I view it or what I do with it afterwards. I am not the person to answer the 'why' for doing silly things, there is probably someone in the 'legal' and/or 'marketting' department who comes up with the 'hey what if we did...' sets of requirements. There is also the problem with 'copyright laws' and that 'fair use' is one thing, but beyond that, one has embarked upon merely plagarism and 'theft of intellectual property'. The Yahoo image trick has the complication for some of my optically challenged friends, in that they can not always pick out the 'number' if the 'hue shifts' are not smack dab in the middle of their limited RGB processing. Those folks do not 'dress badly' because they are 'fashion challenged' they do so because they can not tell that certain hues in the visual spectrum, are, well GARISH TOGETHER on planet earth. { probably on their home planet the atmosphere protects them from this problem, since the light refracted from their sun does not provide the full range as we get here. but should we be prejudiced against the non-terran? I mean, how would we look in their native atmosphere? The question what is the colour of the sky in your world? is not merely a pejorative you know. } ciao drieux --- Oops I did not get it. So is there a module to do this or not. Or should I write a jpg genertor using something like gd and create a database of images and the actual numbers they contain Thanks Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to optimize a string search
Ramprasad A Padmanabhan wrote: > I know this is more of an algorithm question but please bear with me. > > In my program I am checking wether a emailid exists in a list > I have in the complete_list a string like > $complete_string="<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> ... > <[EMAIL PROTECTED]>"; > > # that is a string of emailids sorted > > Now I want to find out if another ID "<[EMAIL PROTECTED]>" exists in this list > > How is it possible to optimize the search given that the complete list > string is sorted in order Don't optimize--at least not until you are sure your getting the information right. It is just the wrong emphasis. Here are a couple of approaches that have worked for me. The first, used in building an index, is predicated on the concept of saving all possible information. The second, used in loading a tree structure, takes as a design imperative that any node should focus only on one prime reference, in this case the post being replied to. The wealth of possibilities can be a recipe for inifnite loops when loading a tree, hence it's better to throw away some information than to follow potentially circular links. First approach: Setup: The only information available to this routine is the $message_info hash reference. This has the form: $message_info => { $sequence_number1 => { 'Message-ID' => $message_id, Subject => $subject ... } ... } The references item is a potentially multi-item string, and this routine handles this. $reference_index and $no_references are sent into the gather_References_items function to load their data structures. The latter, no_references, is an afterthought. sub create_References_index { my $message_info = $_[0]; my $reference_index = {}; my $no_references = []; gather_References_items($message_info, $reference_index, $no_references); open OUT, ">dbm/referenc.ndi" or die "Could not open file to write Reference index: $!"; foreach my $column_value (sort {uc $a cmp uc $b} keys %$reference_index) { my $index_row = column_index_line($reference_index, $column_value); print OUT "$index_row\n"; } close OUT or die "Could not close file after writing Reference index: $!"; create_no_reference_index($no_references); } sub gather_References_items { my ($message_info, $reference_index, $no_references) = @_; foreach my $msg_key (keys %$message_info) { my $data_field = $message_info->{$msg_key}->{'References'}; if (!$data_field) { push(@$no_references, $msg_key); } next if !$data_field or $data_field !~ /\S/; $data_field =~ s/^<(.*)>$/$1/; my @references = split />\s*{$reference} = [] # create the anonymous target array if !defined($reference_index->{$reference}); # if it doesn't exist push @{$reference_index->{$reference}}, $msg_key; } } } The above very hadily preserves all sequence numbers of posts referencing any given Message-ID. The following is more focused on getting just one [hoefully the best, but more importantly cogent]. It is used in the active process of loading a threaded mail index. As I said, the focus here is on keeping the data lean and focused. That is why, instead of dealing with the whole list of References items, I just pop until I find the one that seems best suited, then get out, leaving extraneous data behind. I tried using different data structures to hold different kinds of relationships, and ended up fighting with the loading routine all day. This works: sub establish_parentage { my ($message_details, $subjects, $message_ids, $threads) = @_; my $no_references = []; my $candidate_roots = [sort {$a <=> $b} keys %$message_details]; my $parents = {}; my $temp = []; while (my $candidate = shift @$candidate_roots) { seek_explicit_references($candidate, $message_details, $no_references, $parents, $message_ids); } $candidate_roots = $no_references; $no_references = []; while (my $candidate = shift @$candidate_roots) { seek_implicit_references($candidate, $message_details, $no_references, $parents, $subjects); } return $parents; } sub seek_explicit_references { my ($candidate, $message_details, $no_references, $parents, $message_ids) = @_; my $details = $message_details->{$candidate}; return if $details->{'parent'}; my $references = $details->{'References'}; $references =~ s/^\s+//; $references =~ s/\s+$//; my @references = split /\s+/, $references; my $found = 0; while (my $reference = pop @references) { if (my $parent_sequence = $message_ids->{$reference}) { $details->{'parent'} = $parent_sequence; $parents->{$candidate} = $parent_sequence; $found = 1; last; } } push @$no_references, $candidate if not $found; } sub seek_implicit_references { my ($candidate, $message_details, $no_references, $parents, $subjects) = @_; # We won't go here. I'm still feelin