Re: Pipe Help
Hi, for the while loop i figure out before your answers, anyhow, my question was should i send the whole array or not? also is it possible to retrieve the data from the pipe or not? Anthony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Marking a file
Hi all Can you help me I my tailing a growing file but in between these I execute a script which to has the same file as the growing file is there a way to mark were I got to in the file so when the file grow the script that is executed in the first pass will know that start at the place were it left from the first pass. -- Thank You Benjamin Jeeves -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Marking a file
Benjamin Jeeves wrote: Hi all Hello, Can you help me I my tailing a growing file but in between these I execute a script which to has the same file as the growing file is there a way to mark were I got to in the file so when the file grow the script that is executed in the first pass will know that start at the place were it left from the first pass. perldoc -f tell John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: confused with File::Glob
John W. Krahn [EMAIL PROTECTED] writes: cat ./testglob.pl #!/usr/local/bin/perl -w use File::Glob ':glob'; ^^^ Note that the only options available are ':case', ':nocase' and ':globally', Maybe it recognizes the abbrev or something. Doesn't seem to be wreaking havoc after fixing the (or, ||) operator. In my post it is a verbatim quote from perldoc File::Glob: NAME File::Glob - Perl extension for BSD glob routine SYNOPSIS use File::Glob ':glob'; @list = bsd_glob('*.[ch]'); $homedir = bsd_glob('~gnat', GLOB_TILDE | GLOB_ERR); if (GLOB_ERROR) { # an error occurred reading $homedir } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: confused with File::Glob
Harry Putnam wrote: John W. Krahn [EMAIL PROTECTED] writes: use File::Glob ':glob'; ^^^ Note that the only options available are ':case', ':nocase' and ':globally', Maybe it recognizes the abbrev or something. Doesn't seem to be wreaking havoc after fixing the (or, ||) operator. In my post it is a verbatim quote from perldoc File::Glob: File::Glob handles the :glob tag automatically via the EXPORT_OK array, while :case, :nocase, and :globally are handled explcitly in the import method as they are modes of operation rather than groups of exported ientifiers. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
calling sub
Can someone tell me why my call to build_db() works but when I call alert() it will not work as it calls alert but will not enter the while loop I my opening the file with #!/usr/bin/perl $filein = $ARGV[0]; open(filein, $filein); sub start { for(;;) { while ( filein ) { build_db(); $counter++; alert(); $counter1++; print $counter..$counter1\n; } sleep 50; seek filein,0,1; } } sub alert { while( filein ) { does some thing on pattern matching } -- Thank You Benjamin Jeeves -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
On Sun, Feb 09, 2003 at 04:39:00PM +, Benjamin Jeeves wrote: Can someone tell me why my call to build_db() works but when I call alert() it will not work as it calls alert but will not enter the while loop I my opening the file with #!/usr/bin/perl $filein = $ARGV[0]; open(filein, $filein); sub start { for(;;) { while ( filein ) { build_db(); $counter++; alert(); $counter1++; print $counter..$counter1\n; } sleep 50; seek filein,0,1; } } sub alert { while( filein ) { does some thing on pattern matching } With just a quick look I see there is no closing brace on sub alert is that a typo? kent -- To know the truth is to distort the Universe. Alfred N. Whitehead (adaptation) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
Benjamin Jeeves wrote: Can someone tell me why my call to build_db() works but when I call alert() it will not work as it calls alert but will not enter the while loop I my opening the file with #!/usr/bin/perl Please add these lines here: use strict; use warnings; as together they will cut down dramatically on the number of unfathomable bugs. You will then need to declare all of your variables with: my $filein; etc. $filein = $ARGV[0]; open(filein, $filein); Filehandles are traditionally all uppercase, and it's not good to put a variable in quotes unless you have a reason to. open FILEIN, $filein; I presume you have a call start(); somewhere here? sub start { for(;;) { while ( filein ) { build_db(); $counter++; alert(); $counter1++; print $counter..$counter1\n; } sleep 50; seek filein,0,1; } } sub alert { while( filein ) { # does some thing on pattern matching } } Are you clear that filein will read a line from your input file? Both your subs 'start' and 'alert' are reading lines from the file, and 'start' doesn't do anything with the one it reads. If you have only one line of data in your file then 'start' will read this line and, as there are no more lines, the while condition in 'alert' will fail immediately. It will therefore return without doing anything. It's my guess this is what's happening. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
if I do not call build_db then alert will run fine as I want it to so is there away around this problem. See I need the FILEIN to go though a number of different sub routes how would I go about this. On Sunday 09 Feb 2003 4:39 pm, Benjamin Jeeves wrote: Can someone tell me why my call to build_db() works but when I call alert() it will not work as it calls alert but will not enter the while loop I my opening the file with #!/usr/bin/perl $filein = $ARGV[0]; open(filein, $filein); sub start { for(;;) { while ( filein ) { build_db(); $counter++; alert(); $counter1++; print $counter..$counter1\n; } sleep 50; seek filein,0,1; } } sub alert { while( filein ) { does some thing on pattern matching } -- Thank You Benjamin Jeeves -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
Benjamin Jeeves, You can probably figure this out. Try running the code below supplying whatever file name you choose to save it as for an argument. #!/usr/bin/perl -w use strict; my $filein = $ARGV[0]; print $filein\n; open(FILEIN, $filein); my $counter = 0; my $counter1; start; sub start { for(;;) { while ( FILEIN ) { build_db(); $counter++; alert(); $counter1++; print $counter..$counter1\n\t\t$_; exit if $counter 2; } sleep 2; seek(FILEIN,0,1); } } sub alert { while( FILEIN ) { printAlert called\n\t$_; } } sub build_db { printbuild_db called\n; } HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Spamassassin Ports
Hi, I just tried to install Spamassassin out of the FreeBSD ports. Even from cpan it didn't work out. After that, I tryed to download a package from HTML::Parser from cpan and did a make with the same results. Any suggestions are welcome. Please CC:' I'm currently not subscribed! Thanks Tom procmail: Locking spamassassin.lock Can't locate loadable object for module HTML::Parser in @INC (@INC contains: lib /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 . /usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503) at /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssassin/HTML.pm line 6 BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssassin/HTML.pm line 6. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssassin/PerMsgStatus.pm line 41. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssassin.pm line 61. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
slurp in file
Is there any function that places perl code from a file into a program as if it was just part of the program file itself? Something like: file ** Hello World. ** program $file = slurp('file'); print $file\n: I'm creating an address book as described on page 237 of Beginning Perl and adding a few twists. I would like to add functionality that would allow a person to be prompted for and add/edit/delete entries in the address book. I thought it would be best to place those entries into a separate file in the format of: From the book - $addressbook{Paddy Malone} = { address = 23, Blue Jay Way, phone = 404-6599 }; And then bring them back into the program to print out. Thanks, kent -- To know the truth is to distort the Universe. Alfred N. Whitehead (adaptation) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Pipe Help
On Sun, 9 Feb 2003 11:02:52 +0100, [EMAIL PROTECTED] (Anthony) wrote: Hi, for the while loop i figure out before your answers, anyhow, my question was should i send the whole array or not? also is it possible to retrieve the data from the pipe or not? If you don't want to use a module like IPC::Open2, then you need 2 pipes, 1 to send the array, and 1 to return the sorted array. After your sort script is finished, have it write it to another pipe back to the original script. You will have to keep the original script going, while the sort script does it's work, so you will have to work out a loop of some kind, to check for the return array through the second pipe. It all can be done. But you will find that the IPC series of modules take care of all the details for you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: slurp in file
ktb wrote: Is there any function that places perl code from a file into a program as if it was just part of the program file itself? perldoc -f use perldoc -f require perldoc -f eval Will get you started. As for slurping data: perldoc -f open perldoc perlopentut http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
CPAN module - cmd history
Should I have a cmd history with the current CPAN module? If it is something I can setup. Can someone explain how? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Pipe Help
anthony wrote: Hi, for the while loop i figure out before your answers, anyhow, my question was should i send the whole array or not? also is it possible to retrieve the data from the pipe or not? Anthony No and no. There are better ways than using a pipe. Pipes makes sense only when you need specific, standardized output processing. They do not make sense in cases where your program needs the results. In cases where your program needs the results, it is better to import the functionality than top export and re-import the data. If you feel you sorted.pl routine is solid enough to warrant using it from a variety of programs, then you should probably restructur it as sorted.pm, and include it with the use or require statement. Then you can call the sort function directly. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CPAN module - cmd history
From: Harry Putnam [EMAIL PROTECTED] Should I have a cmd history with the current CPAN module? If it is something I can setup. Can someone explain how? Yes you should, but it may depend on your OS. Under WinNT/2k/XP it's the console that provides the history, under Win9x you need to load doskey.exe (if I remember right), under Unix the CPAN should load Term::Readline which should provide this. Tell us what OS do you have and someone will be able to give some more details. 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Pipe Help
Hi, But like i said on my second post i wanted to learn how to receive message from pipe. anthony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
Rob Dixon wrote: $filein = $ARGV[0]; open(filein, $filein); Filehandles are traditionally all uppercase, and it's not good to put a variable in quotes unless you have a reason to. open FILEIN, $filein; You're right, of course, about the quotes. It seems to me that this is the downside of Perlish convenience. Since Perl offers variable interpolation within double quotes, this can be very confusing to a novice. Of course, since the facility is there, I use it. Still, I tend to look at such constuctions as: print Hello, $User, how are you doing?\n; as: print Hello, . $User . , how are you doing?\n; which, as the error messages returned when $User is undefined make clear, the way the interpreter handles it internally--it sees the string in the first line as the concatenation shown in the second. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Spamassassin Ports
Tom Beer wrote: Hi, I just tried to install Spamassassin out of the FreeBSD ports. Even from cpan it didn't work out. After that, I tryed to download a package from HTML::Parser from cpan and did a make with the same results. Any suggestions are welcome. Please CC:' I'm currently not subscribed! Thanks Tom procmail: Locking spamassassin.lock Can't locate loadable object for module HTML::Parser in @INC (@INC contains: lib /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd /usr/local/lib/perl5/site_perl/5.005 . /usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503) at /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssassin/HTML.pm line 6 BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssassin/HTML.pm line 6. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssassin/PerMsgStatus.pm line 41. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/Mail/SpamAssassin.pm line 61. Tom, If you want current Perl functionality, you should use the current Perl version. The messages from your interpreter indicate that you are running version 5.005. That is years out of date, and likely to not have the support needed for any very recent modules. Try upgrading to 5.8 or at least 5.61. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
Benjamin Jeeves wrote: if I do not call build_db then alert will run fine as I want it to so is there away around this problem. See I need the FILEIN to go though a number of different sub routes how would I go about this. Benjamin. I'm pretty sure that, as I said before, you're reading from the file in several different places. The 'start' subroutiine will read the first line and then call 'build_db' which may well read all of the rest of the lines. If you call 'alert' then there will be no data remaining to be read and its while loop will exit immediately. If you don't call 'build_db' then all lines in the file but the first one will still be unread and there will be some work for 'alert' to do. I'm not at all sure what your program is supposed to be doing so I can't suggest what may be the correct coding. Are you intending that both 'build_db' and 'alert' read all the way through the file? Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
R. Joseph Newton wrote: Rob Dixon wrote: $filein = $ARGV[0]; open(filein, $filein); Filehandles are traditionally all uppercase, and it's not good to put a variable in quotes unless you have a reason to. open FILEIN, $filein; You're right, of course, about the quotes. It seems to me that this is the downside of Perlish convenience. Since Perl offers variable interpolation within double quotes, this can be very confusing to a novice. Of course, since the facility is there, I use it. Still, I tend to look at such constuctions as: print Hello, $User, how are you doing?\n; as: print Hello, . $User . , how are you doing?\n; which, as the error messages returned when $User is undefined make clear, the way the interpreter handles it internally--it sees the string in the first line as the concatenation shown in the second. Yes, but of course the concatentation operator is implicitly forcing string context onto $User (who taught you to Capitalise your scalars :-? ) so the explicit $User could be considered to be clearer! I tend to force a required coercion to a string or a number by concatenating the null string or adding zero respectively; then it looks deliberate. Interestingly, I found a bug recently due to the opposite problem - I was passing a URI object reference to a function which required either a string or an array reference. Because a reference was acceptable no stringifying was done within the called code and had to be done in the actual parameter as foo ($uri.''). Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CPAN module - cmd history
Jenda Krynicky [EMAIL PROTECTED] writes: Tell us what OS do you have and someone will be able to give some more details. Yeah, sorry. OS is linux (Redhat 8). I have both Term::ReadLine (which is part of 5.8.0 I think and Term::ReadLine::Gnu which isn't. I have newest CPAN-1.65 installed. In addition: rpm -qa|grep -i readline readline-4.3-3 readline-devel-4.3-3 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: slurp in file
ktb wrote: From the book - $addressbook{Paddy Malone} = { address = 23, Blue Jay Way, phone = 404-6599 }; And then bring them back into the program to print out. Thanks, kent Hi Kent, How about don't do it? Look, when your text shows an assignment statement such as this, it is simply an example of how to prime your hash--for testing purposes only--from within your code. The rule should be: NEVER hard-code your data. Data is one thing. Program code is another. To include coded functionality, use the use or require statements. To store and retrieve data: =Devise a storage format appropriate to your data. For instance: ==CSV: Paddy Malone, 23 Blue Jay Way, 404-6599 ==Tagged Sections [BEGIN ADDRESS] name=Paddy Malone address=23 Blue Jay Way phone=404-6599 [END ADDRESS] =Develop a standard set of functions to store in this format and retrieve from it. =When you need to add, delete or modify data, call the appropriate function to open and edit the data file. I'll give you an example for the second format. You just got a new entry for Paddy Malone, with the same address as above, but phone number 514-2233 [Paddy went cellular, say]. #assumed: Paddy Malone has been loaded into $CurrentMember{'name'} open IN, address_book.txt; open OUT, address_book.tmp; my $EnteredName = $CurrentMember{'name'}; my $Line; while (defined ($Line = IN) and !( $Line =~ $EnteredName) ) {print OUT $Line;} if (defined($Line) { #if existing record is found print OUT $Line; #this prints the name=Paddy Malone line, which, being the #key for the record, will not changed $Line = IN; while ( !($Line =~ /[END ADDRESS]/)) { chomp $Line; my ($attribute, $value) = split (/=/, $Line); if (defined ($CurrentMember{$attribute})) { $value = $CurrentMember{$attribute} } print OUT $attribute=$value\n; $Line = IN; } print OUT $Line\n; while (defined ($Line = IN)) {print OUT $Line;} } else { # Here goes code to append a new record if no existing record for # Paddy Malone is found } close IN; close OUT; rename address_book.tmp address_book.txt; At first galnce, this might seem like a lot of processing, but the thing is, you only have to do it once. Of course, the code above is only an example, and you would need to refine it for your purposes. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
Benjamin Jeeves wrote: On Sunday 09 Feb 2003 7:23 pm, Rob Dixon wrote: I'm pretty sure that, as I said before, you're reading from the file in several different places. The 'start' subroutiine will read the first line and then call 'build_db' which may well read all of the rest of the lines. If you call 'alert' then there will be no data remaining to be read and its while loop will exit immediately. If you don't call 'build_db' then all lines in the file but the first one will still be unread and there will be some work for 'alert' to do. I'm not at all sure what your program is supposed to be doing so I can't suggest what may be the correct coding. Are you intending that both 'build_db' and 'alert' read all the way through the file? Yes I would like build_db and alert to read all the way through the file can that be done if so what do you think is the best way or point me in the right way Fine. I thought so. Well, you had the right idea when you coded seek filein,0,1; after the while loop in sub 'start'. However the '1' means to set the file pointer relative to its current position, so with an offset of zero the statement leaves things as the are. What you want is seek filein, 0, 0; or, far better seek filein, 0, SEEK_SET; for which you need to use the Fcntl module which defines the constant SEEK_SET as zero, but leaves the code much more readable. Furthermore, this needs to be before each of the loops in the subroutines which read through the file. Finally, I don't think you want to do any file reading in sub 'start' at all. Certainly at the moment you're throeing away the first line. Over all, how about the following skeleton program: use strict; use warnings; use Fcntl ':seek'; my $filein = $ARGV[0]; open FILEIN, $filein or die $!; sub start { for(;;) { build_db(); $counter++; alert(); $counter1++; print $counter..$counter1\n; sleep 50; } } sub alert { seek FILEIN, 0, SEEK_SET; while( filein ) { # does some thing on pattern matching } } Note that the same 'seek' command needs to be before whatever code you have in sub 'build_db'. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
Rob Dixon wrote: sub alert { seek FILEIN, 0, SEEK_SET; while( filein ) Of course, that should be while (FILEIN) { # does some thing on pattern matching } } Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Removing duplicates from an array
Hello, What's the best and cleanest way to remove duplicates from an array? I have an array that reads entries from a text file and I would like to remove all the duplicates from it. Thanks in advance! Troy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Pipe Help
anthony wrote: Hi, But like i said on my second post i wanted to learn how to receive message from pipe. anthony Hi Anthony, That's fine. but use the pipe for it's designed purpose, which is NOT to return data to a calling program. Try constructing your own version of more, maybe, if you need a pipe exercise. Set it up with a feature that will allow the user to backtrack thruough the output by using the 'U' key to page up. That would be a much more appropriate use of pipe. Your input data should come from STDIN in the program you pipe to. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
Rob Dixon wrote: ...(who taught you to Capitalise your scalars :-? )... Huh?!? Taught?? Wuzzat mean--taught? ~( ;- |) ) Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Removing duplicates from an array
From: Troy May [EMAIL PROTECTED] What's the best and cleanest way to remove duplicates from an array? I have an array that reads entries from a text file and I would like to remove all the duplicates from it. Run perldoc -q duplicate :-) 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: calling sub
It still add record that it found on the first pass though the while loop to my database what I need is some way to mark my file to the point that it get to so it will not find a dupluted of the some record as the file grows. ant ideas on how I do that. On Sunday 09 Feb 2003 8:30 pm, Rob Dixon wrote: Rob Dixon wrote: sub alert { seek FILEIN, 0, SEEK_SET; while( filein ) Of course, that should be while (FILEIN) { # does some thing on pattern matching } } Rob -- Thank You Benjamin Jeeves -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Mysql lib
I'm interested in libraries or procedures which can produce reports on a mysql database. I've loaded a mysql database which has powerball numbers. I'd like to analyze the data for simple things like: Which number occurs most frequently? Adding the winning numbers and taking their average? Statistical techniques to discover a pattern? Other ideas are welcome. Thanks re-v -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cmd history with CPAN shell
Setup: OS Linux (Redhat 8) Perl: 5.8.0 CPAN: 1.65 $SHELL: Bash Anyone else here have trouble getting a command history to work with the perl CPAN shell (perl -MCPAN -e shell)? I have mu OS readline packages installed. rpm -qa |grep readline readline-4.3-3 readline-devel-4.3-3 As well as the perl modules Term::ReadLine Term::ReadLine::Gnu In the .cpan directory I see a `histfile' and it has a few commands in it. But I can't seem to access them. Trying the emacs-like up arrow gives me A. Trying for vi type syntax, press ESC then k, types ^[k. Trying the old emacs style with C-p types ^p. What do I need to do to get a cmd history working? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Removing duplicates from an array
Troy May wrote: Hello, What's the best and cleanest way to remove duplicates from an array? I have an array that reads entries from a text file and I would like to remove all the duplicates from it. Thanks in advance! Troy I'd say prevention is the best cure. Check for duplicates as you read. You need to prevent duplication raises another question, though. Is an array really the best data structure for your purpose. The hash structure was created to maintain uniqueness of keys. Therefore, if you store your elements as hash keys, then you could be assured that there is no duplication: if ( defined( $contents{$currentKey} ) ) {contents{$currentKey}++;} else {$contents{$currentKey} = 1;} Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mysql lib
reavey wrote: I'm interested in libraries or procedures which can produce reports on a mysql database. The DBI module is recommended for database access. You'll need the DBD::mysql driver module to go with it. I've loaded a mysql database which has powerball numbers. I'd like to analyze the data for simple things like: Which number occurs most frequently? Adding the winning numbers and taking their average? Statistical techniques to discover a pattern? You can retreive the data using DBI, and write scripts to do statistical analysis. But since lottery drawings are independent events, what could any of this information possibly tell you? :~) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Removing duplicates from an array
Hi - -Original Message- From: R. Joseph Newton [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 09, 2003 3:32 PM To: Troy May Cc: Perl List Subject: Re: Removing duplicates from an array Troy May wrote: Hello, What's the best and cleanest way to remove duplicates from an array? I have an array that reads entries from a text file and I would like to remove all the duplicates from it. Thanks in advance! Troy I'd say prevention is the best cure. Check for duplicates as you read. Yes prevention is prob the best way. But if you must remove dups anyway: ...@array_with_dups in the input array... my %temp_hash; $temp_hash{$_} = 1 for (@array_with_dups); my $array_without_dups = (); push @array_without_dups, $_ for (keys %temp_hash); The downside is that thr array order will be messed up... You can sort it: ... for (sort keys ... Aloha = Beau; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help geting rid of annoying setting locale failed messgaes
I'm using Mac OS X (10.2), and upgraded the default installation (5.6.0) to 5.8.0. Now, whenever I run the 'perl' command through tcsh I get this annoying error: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = (unset), LANG = en_US are supported and installed on your system. perl: warning: Falling back to the standard locale (C). After the error is displayed, however, the script runs fine. I did an env command, and it says : blah blah blah LANG=en_US more blah This looks ok to me, as the variable LC_ALL is never set, and en_us is the language. How can I get rid of this annoying message? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How do I feed terminal output into a perl script...
I want to feed the output of an ls command into a perl script and store it as a variable, but I can't seem to figure out how to do this. How can I get this working? thanks, mark p.s. I'm using tcsh on mac os 10.2 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do I feed terminal output into a perl script...
Mark VanMiddlesworth [EMAIL PROTECTED] writes: I want to feed the output of an ls command into a perl script and store it as a variable, but I can't seem to figure out how to do this. How can I get this working? thanks, mark p.s. I'm using tcsh on mac os 10.2 I now nothing about OS 10 but have heard its a bsd OS so this should work. You'll get better answers than mine no doubt, but there are quite a lot of ways Ill list a few: None of these are tested... just some ideas tossing it in from outside using the shell ls|my.pl cat my.pl -- #!/usr/bin/perl -w ## process incoming filenames while (){ chomp; ## collect each name into array varialb @ls_array push @ls_array,$_; } for(@ls_array){ $filename = $_; ## do something clever with each filename print $filename\n; } -- Running the ls from inside perl program #!/usr/bin/perl -w ## Notice the pipe symbol open(PROC,ls ); while(PROC){ ## collect file names push @ls_array,$_; } close(PROC); for(@ls_array){ [...] } Another inside technique @ls_array = qx(ls); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]