Re: timestamp conversion

2005-05-18 Thread Peter_Farrar
My goal is to get element 9 of stat which is mtime. I am getting this with ease, but my end goal is to convert this number back into a readable format giving me how old the file is. So here is a rough draft formula : (time in seconds - last MTime ) = seconds old. Convert seconds old to a

Re: Encrypt a file, was Re: Encrpt a file

2005-04-18 Thread Peter_Farrar
On Mon, 18 Apr 2005, Anish Kumar K wrote: Can [anyone] suggest a good algorithm for [encrypting] and [decrypting] files ..I donot want to use any perl module for that... Check out the perl stuff on this site. I haven't actually used it yet, though I've been meaning to look at it. But their

Request for regex: Strip last dash in a record

2005-02-15 Thread Peter_Farrar
Hi All, The code below does what I want to do, but it takes 3 lines and a temporary array (yuck). I can't come up with a one line regex substitution. Anyone got one? my $tmp = reverse split //, $_; $tmp =~ s/-//; $_ = reverse split //, $tmp; TIA, Peter ** CONFIDENTIALITY NOTICE **

Re: Request for regex: Strip last dash in a record

2005-02-15 Thread Peter_Farrar
[EMAIL PROTECTED] wrote: Hi All, The code below does what I want to do, but it takes 3 lines and a temporary array (yuck). I can't come up with a one line regex substitution. Anyone got one? my $tmp = reverse split //, $_; $tmp =~ s/-//; $_ = reverse split //, $tmp; can you post a sample

Re: Request for regex: Strip last dash in a record

2005-02-15 Thread Peter_Farrar
If you just want to remove the last occuring '-' character, then the following would work. s/(.*)-(.*)/$1$2/; Well, huh. That does work. Though it reminds me only of how little I understand why. Thanks, you've made it look easy. ** CONFIDENTIALITY NOTICE ** NOTICE: This e-mail

Re: Does the SWITCH statement have a default?

2005-01-20 Thread Peter_Farrar
Is there a correct way to define a default case within a SWITCH? I tried with the bottom case, but that errors with: Quantifier follows nothing before HERE mark in regex m/* HERE / at ./ctest line 251. SWITCH: { $field =~ /^CR\d{0,7}$/ do { $openCRs++; print tda

RE: pronunciation guide

2003-08-25 Thread Peter_Farrar
I thought it was only called 'string' in Applesoft... Glad to hear I'm not the only one. My co-workers think I'm crazy. |-+ | | Paul Kraus | | | [EMAIL PROTECTED]| | | .com| | |

Re: trouble with math... driving me nuts.

2003-08-22 Thread Peter_Farrar
This seems to work, although there are some odd line returns and '0' is being returned as '0.' Still, I can work around that, THANKS! |-+ | | zsdc [EMAIL PROTECTED]| | || | | 08/21/2003

RE: trouble with math... driving me nuts.

2003-08-22 Thread Peter_Farrar
True, it's not a Perl issue (I've been able to duplicate the problem in C, and Scheme), but I'm looking for a Perl solution. Math::BigFloat seems to work well enough. Thanks, Peter |-+ | | Levon Barker | | | [EMAIL

trouble with math... driving me nuts.

2003-08-21 Thread Peter_Farrar
Luckily I was easily able to recreate the problem. See code below: print 37.75 - 33.67 - 4.08 ; STDIN; I find these things all the time. Is there a particular module I can use to fix these things? Output is -1.77635683940025e-015 Should be 0 Running on Win2000 / Intel P3

RE: trouble with math... driving me nuts.

2003-08-21 Thread Peter_Farrar
Hi Bob, I'm doing data-processing (EDI). I need to format and present values in text, round here and there. Have lots of various attempts that have failed for one math related reason or another. Currently I convert to a string and split and round, etc. (Even modulo '%' has failed me at

How do I check disk space through Perl?

2003-05-27 Thread Peter_Farrar
Hi All, It seems like I should know this, but I don't, and I can't seem to find it written anywhere. I need to check disk space on an NT platform using ActiveState Perl 5.6.1. Is there an easy way to do this? Thanks, Peter ** CONFIDENTIALITY NOTICE ** NOTICE: This

Re: Net::FTP in Passive mode hangs and fails (really frustrating)

2003-04-03 Thread Peter_Farrar
Hi David, I'm using Active State 5.6.1 build 631 on NT 4. This problem appears to be connected to the level of network traffic. But two things stand out. The files are on average only 12K, and the previous process had it's problems, but not this one. It was running on the same box, but was

Net::FTP in Passive mode hangs and fails (really frustrating)

2003-04-02 Thread Peter_Farrar
Hi All, I'm unsure what to do next. I hope someone has beaten this before and hears my cry for help. I've implemented a script to transfer files to a client, and to pick files up. There is a firewall, though I don't know much about it. I instantiate the Net::FTP object with Passive = 1. The

Re: How to map hash keys only, not values?

2003-03-14 Thread Peter_Farrar
Hi Joseph, Probably just as well. Is there some context where you anticipate having to repair broken keys after the fact? In this case I'm building packages, and don't want to count on the user to get the case of the text correct when passing the values. So if I need to set the 'smile'

How to map hash keys only, not values?

2003-03-13 Thread Peter_Farrar
Hi All, I'm passing a hash to a subroutine like this: subname(a = 123, b =fff, C = joyjoyjoy); On the receiving side I want all keys to be upper case. I can map like this: sub subname{ map {$_ =~ tr/a-z/A-Z/} @_; my %values = @_; .. } and I

Re: How to map hash keys only, not values?

2003-03-13 Thread Peter_Farrar
First, please don't use map in a void context for its side effects. Uh oh... What side effects? I use map like this all the time! What dread is looming in my future? Just loop it: sub subname { my %values; while (@_ = 2) { my ($key, $value) = splice @_, 0, 2;

Re: How to map hash keys only, not values?

2003-03-13 Thread Peter_Farrar
Replace EVIL: map { some;block;of;code;that;changes;$_ } @some_array; with GOOD: for (@some_array) { some;block;of;code;that;changes;$_ } I guess I don't get it. Map returns a value and I ignore it; so what? What side effects does this have? Which one's faster? I like to avoid obvious

Re: How to map hash keys only, not values?

2003-03-13 Thread Peter_Farrar
The foreach loop *will* be faster. Good enough for me! Thanks, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: how to concat files easily?

2003-03-11 Thread Peter_Farrar
use File::Slurp $file1 = read_file($fileone); $file2 = read_file($filetwo); write_file($filenew,$file1\n$file2) Thanks Dan, It's that easy! -Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

how to concat files easily?

2003-03-10 Thread Peter_Farrar
Hi All, Sorry if this is a stupid question. It took me awhile to figure out I could use the File::Copy module to copy a file, and this is about the same level of ignorance. Is there an easy way to concatenate two (text) files in Perl, short of opening two to read and one to write and then loop

Win32::Process question

2003-02-25 Thread Peter_Farrar
Hi All, I'm hoping someone has done this before. I need to spawn 3 processes and then wait for all three to finish. spawn like this: my $obj; my $appname = $perl; my $cmdline = $deliverscript $arg; my $iflags = 1; my $cflags = CREATE_NEW_CONSOLE |

FW: Win32::Process question

2003-02-25 Thread Peter_Farrar
but how can I tell when all three are finished? If I use $obj1-Wait(INFINITE); $obj2-Wait(INFINITE); $obj3-Wait(INFINITE); what happens if $obj2 finishes before $obj1? looks like this works fine... PHF -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,

Re: Dynamic Hash Naming and multi-dimensional hashes

2003-02-25 Thread Peter_Farrar
I've played tag the wall with the forehead long enough. a) a way to name a hash from user input If you mean assign a value with in a hash using the user input, then: my %hash $key = STDIN; $val = STDIN; $hash{$key} = $val; If you really want to let the user name

Re: calling a subroutine as an element of a hash table...

2003-02-10 Thread Peter_Farrar
Thanks to all who replied. |-+ | | Rob Dixon | | | [EMAIL PROTECTED]| | | m.co.uk | | || | | 02/07/2003 05:09 | | | PM

Re: calling a subroutine as an element of a hash table...

2003-02-10 Thread Peter_Farrar
Oops, hit send by mistake. This problem all seems to be about mistakes... Thanks to all who replied. You have three different hashes in use. Look: I did indeed have 3 hash tables... Duh (Must have been Friday afternoon). The central problem was calling '{${$date_format{$format}}{now}}()'

RE: Comparing Arrays

2003-02-10 Thread Peter_Farrar
if (@Af1 eq @Af2) { print Files compare okay\n; } else { print Files differ\n; } # How about something clunky like this: if (join(,@Af1) eq join(,@Af2)) { print Files compare okay\n; } else { print Files differ\n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

calling a subroutine as an element of a hash table...

2003-02-07 Thread Peter_Farrar
Hi All, I swear I've called subroutines this way before, but I can't find any examples. In this case, I'm looking to build some time/date functions. Regardless of what the actual code is supposed to do, the calling of subroutines as elements of a hash is causing me grief. I am receiving the

RE: Tk with Perl

2003-01-24 Thread Peter_Farrar
Trying it now from the Command Prompt.seems to be just 'sitting' there. Hi Tony, If you're still having trouble getting the package, it could be a firewall issue. I have to download packages, then install from my local box because of corporate B()[[S][|~!. I believe this is the correct

Re: Hash of Hashes of Arrays?

2003-01-24 Thread Peter_Farrar
I have a list of inspection stations in a data file which is comma-separated. It contains the following data, in order: Station Name, Address 1, Address Line 2, City, State, Zip, Phone Number I need to group the lines (of address information) by city and get a count of the number of stations in

my struggle to work with structures... pls hlp!

2003-01-23 Thread Peter_Farrar
Hi All, I'm playing with record formats. I need to be able to have more than one kind of delimited format available at one time. I've written a sort routine to get the values in the order I want, but it assumes one variable name (in this example that is %delimited format). I want something a

Re: Tk with Perl

2003-01-23 Thread Peter_Farrar
I have installed Perl 5.6.1 ( which works ) and Tcl/Tk 8.3 ( which works ) on Windows 2000 but when I try to perl -e use Tk I get the following error: Can't locate Tk.pm in @INC ( @INC contains: D:/Perl 5.6.1/lib D:/Perl 5.6.1/site/lib . ) at -e line 1. Have you

cc and bcc in Net::SMTP

2002-12-04 Thread Peter_Farrar
Hi, The 'cc' and 'bcc' methods in Net::SMTP seem to simply alias the 'to' method. How do I actually 'cc' and 'bcc' in Net::SMTP? I tried putting these in the DATA area (though it doesn't really make sense to me to do it that way). I even looked through RFC 822 and 2821 for hints... but I

Re: cc and bcc in Net::SMTP

2002-12-04 Thread Peter_Farrar
Just like that. Thanks for demystifying that for me. |-+ | | George | | | Schlossnagle| | | [EMAIL PROTECTED]| | | m | | |

Programming pipes to and from another program

2002-09-25 Thread Peter_Farrar
Hi there, I hope this is a trivial newbie problem: I know how to open a pipe to another program: open (OUT, |perl .\\bogus.pl) or warn Unable to open pipe to bogus.pl\n; print OUT Stuff\n; And I know how to open a pipe from another program: open (IN, perl .\\bogus.pl|) or

RE: Programming pipes to and from another program

2002-09-25 Thread Peter_Farrar
If *nix, look at help for the open3 function. Attached as a text file is the little run class that I use to do this. Here is an example of how to use this class to encapsulate GPG, where the passphrase gets written to stdin of the child process, and the results are reaped from the childs

Re: Recognizing Directories...

2002-09-17 Thread Peter_Farrar
Hello Everyone, I am writing a utility that needs to index the files contained within about 500 directories (some nested). I want to provide the script with a top directory and have it recurse through everything underneath while indexing the files within each. I've searched Google and can't

globbing problem with longfilenames containing spaces (Windows)

2002-08-28 Thread Peter_Farrar
Hi all, Here is the code I'm having problems with: my @arr = glob($here\\*); foreach $val (@arr){ if (-d $val){ travel_dirs($val, $level-1) if $level 0; }else{print$val\n;} } 'else print $val' is just there for debugging, so I can

RE: How to check installed Modules in perl

2002-04-17 Thread Peter_Farrar
in windows: ppm query Jaimee Spencer

Re: external hashtable

2002-03-19 Thread Peter_Farrar
The book from O'Reilly, Perl DBI, chapter 2, has a good look at Data::Dumper and other approaches that could work here. Jonathan E.

Re: Perl Tk.

2002-03-15 Thread Peter_Farrar
I've been growing interested in the Tk module too. I found this today. It's really really introductory. http://www.perl.com/pub/a/1999/10/perltk/

RE: How long can $_ be?

2002-03-13 Thread Peter_Farrar
I've seen this effect when using data I copied off the internet (using Explorer) into a text file in a Unix environment. In my case the problem was definitely a control character within the string causing a line return without a line feed. It didn't show up when I viewed the file with less or

RE: Error installing package

2002-03-08 Thread Peter_Farrar
Now I can! Timothy Johnson To:

Error installing package

2002-03-07 Thread Peter_Farrar
I am on NT, trying to use 'PPM INSTALL DBI' and receiving an error message: Error installing package 'DBI': Could not locate a PPD file for package DBI: Very frustrating. I have yet to succeed with PPM. I know there is a firewall here, is that possibly the problem? Are there config scripts or

RE: Error installing package

2002-03-07 Thread Peter_Farrar
In my case, PPM has been working. PPM QUERY returns a list of the modules that were initially installed. But the error comes each time I try to install new modules with PPM: Installing package 'DBI'... pause Error installing package 'DBI': Could not locate a PPD file for package DBI I assume

RE: Error installing package

2002-03-07 Thread Peter_Farrar
Awesome Timothy! You are Awesome! I haven't fixed the Proxy problem, but I copy-pasted the HTTP_PROXY variable name from your email into the search box at ActiveState.com and it gave me a link to a doc that says it can help solve the problem. Unfortunately the network guys went home already.

'use strict' kills Oracle spooling...

2001-06-26 Thread Peter_Farrar
I'll try and keep it short. I have code that opens an Oracle client and pipes it a few SQL statements, including spool. I've heard a lot about 'use strict' and I felt that my code was actually organized well enough to pull this off, so I tried it. The only change I made was to declare all

Re: C++ in perl.

2001-06-08 Thread Peter_Farrar
how about system(some command line); ? |+--- || [EMAIL PROTECTED]| || m| || | || 06/08/01 | || 09:45 AM | || |

hiding logins at prompt

2001-05-25 Thread Peter_Farrar
Hi, I've got a Perl script that logs into one of our applications as Admin. I didn't want to hard code in the password, so I'm prompting for it. I was looking for a way to hide the input, just like when you log into a Unix or NT box. I was hoping to either have the actual input chars