Re: how to get the command line from code ?

2002-12-10 Thread Tim . Moose
It is in $0. If you type perl .\foo.pl arg1 ... argn $0 will be '.\foo.pl'. You can break this apart with functions in the File::Basename package if you need to. Tim ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://li

Re: Perl equivalent to VB's IsObject

2002-12-06 Thread Tim . Moose
"Does anybody know whether there is some equivalent in Perl to VB's IsObject function?" It would be helpful to have a description of the VB IsObject function, but judging by the name, you could do something like this (untested) sub isObject { my %types = map {$_=>$_} qw(SCALAR ARR

Re: sorting version numbers

2002-12-02 Thread Tim . Moose
"Is there an existing (semi-built-in?) solution to this problem?" I'm not sure if this qualifies as semi-built-in, but it uses only one "sort". @versions =("4.0.0.10", "4.0.0.9", "4.0.1.0"); @versions = sortVersions(@versions); print join "\n", @versions; sub sortVersions { # Works for

Re: Check a perl reference type

2002-10-13 Thread Tim . Moose
Use ref(). For example, the following print ref bless {}; # object reference (in package main) print "\m", ref []; # array reference print "\n", ref {}; # hash reference results in main ARRAY HASH Tim

Re: working with array references.

2002-10-13 Thread Tim . Moose
This will do it push @{$hash{$key}}, $item; Tim ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Check existence of registry key - not working

2002-10-07 Thread Tim . Moose
Change if($regvals{$envVar}->[2] == "Microsoft SML Parser") to if($regvals{$envVar}->[2] eq "Microsoft SML Parser") Tim ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Regualr Expression

2002-09-10 Thread Tim . Moose
The problem here $dir =~ s/\///g; is that the two characters you are dealing with have special meaning. The / is interpreted as a quote delimiter because you are using s///. The strings inside of s/// are interpolated, so the \ is interpreted as an escape character. Try escaping both

Re: Newbie: Faster way to do this and hash problem

2002-08-17 Thread Tim . Moose
You are looping over all of the %ext keys, and provided that $ext{$6} exists, assigning a value to $tad for each key. Therefore, the final value of $tad will always be the same, i.e. the one determined by the last key. > foreach $key ( keys %ext ) {# > if (exists

Re: how to match '*'

2002-07-09 Thread Tim . Moose
It works for me. I suspect that your $line variable is not what you think it is. $line = "*line"; print "Match! $line\n" if $line =~ /^\*/; Tim ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveS

Re: Glob question

2002-05-02 Thread Tim Moose
There is nothing inherently wrong with the statement @list = glob($filename); but you need to provide more information. What is the value of $filename? What is the name of a file that you expect to see in @list? What is the working directory set to? Tim ___

Re: Printing to file

2002-04-24 Thread Tim . Moose
>Dear Tim, > I might be wrong on this. >I believe that, we can open the file for both read and write ( perl). >something like, > open("AA"," +>>philips.txt"); ### Using this we >can read/write/a

Re: Printing to file

2002-04-24 Thread Tim . Moose
You can't read from a file that is opened for writing. Your script actually crashes perl on my machine. I'm not exactly sure what you intended to do there, so I can't offer any suggestions unless you provide more detail. Tim ___ Perl-Win32-Users mail

Re: file test failure

2002-04-24 Thread Tim . Moose
Try ... if (-T "dston"){ ... Without the quotes, dston is interpreted as a filehandle. Tim ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: next match

2002-04-20 Thread Tim . Moose
You would do it like this while ($file =~ //g) { # do something here based on the match data } See perlop in the documentation that came with your perl distribution for further explanation. Search for //g. Unless the patterns you match span across line boundarie

Re: help matching special characters!

2002-04-09 Thread Tim . Moose
Please provide a minimal test script that exhibits the problem. Tim ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Freeze and Thaw

2002-03-21 Thread Tim . Moose
>You're right, I was trying to figure out what's wrong and I left exec `thaw.pl`; >Here is the siuation: >the following script reads the log file and starts the other scripts. Most of them need the same data from the database. >I'm trying to avoid running database queries again and again by stor

Re: Freeze and Thaw

2002-03-21 Thread Tim . Moose
$srl_num_item is undefined in the child process, hence the error. What are you trying to do, exactly? The line exec `thaw.pl`; is very odd---you are exec'ing the output of backticks operation, `thaw.pl` (which executes thaw.pl in a new process). Tim ___

Re: Multi-level hashes and arrays

2002-03-17 Thread Tim . Moose
John, I am not clear on what you want to do with the data structure; but from what you describe, the syntax looks correct. Why do you say that it does not work? Tim p.s. You can write foreach () { print $_; $config{$custnum}->{$filename}->[$cnt]=$_;

Re: Regular Expression Question

2002-03-04 Thread Tim . Moose
h position to the beginning of the string, but you can avoid that by adding the /c modifier (e.g. m//gc). Modifying the target string also resets the search position. Tim _________ Tim Moose | T R I L O G Y voice (51

Re: Regular Expression Question

2002-03-04 Thread Tim . Moose
m//gc). Modifying the target string also resets the search position. Tim _________ Tim Moose | T R I L O G Y voice (512) 874-5342 fax (512) 874-8500 "Joseph Youngquist" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 03/04/2002

Re: comparing two arrays, removing elements

2002-03-01 Thread Tim . Moose
James, Does the following code do what you want? The first step is ro cache the indices of the most recent files. This can be done with a hash table, keyed off of file name, that saves date and index. When a later date is found, replace the current hash record. The final step is to strip all b

Re: querying once, using several times

2002-03-01 Thread Tim . Moose
Greg, Look into the Storable package. http://aspn.activestate.com/ASPN/CodeDoc/Storable/Storable.html Tim _ Tim Moose | T R I L O G Y voice (512) 874-5342 fax (512) 874-8500 ___ Perl-Win32-Users mailing

Re: yet another regex issue?

2002-01-16 Thread Tim . Moose
One way is to use to use //g and pos. The program         while () {                         while (/@(\w)/g) {                                 # The pos function returns the position                         # where the last //g search left off. The next //g                         # search wil

RE:How to delete a line in a file

2001-11-26 Thread Tim . Moose
Better yet... perl -ni.bak -e "print unless /^\s*subnet/" input.txt will update input.txt and backup the original file in input.txt.bak. Tim ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo

RE:How to delete a line in a file

2001-11-26 Thread Tim . Moose
>Hi, I would like to parse a file and delete the entire line if it begins with >subnet. >How can I do this in Perl? >Thanks. Step one: Type the command perl -e "print unless /^\s*subnet/" -n infile.txt >outfile.txt where infile.txt and outfile.txt have the obvious meaning. Step two:

Strange performance problem processing large files

2001-11-12 Thread Tim . Moose
I've run into a strange performance problem that has me stumped. When processing large files, in this case 30MB, the performance of my script drags to a crawl. I've boiled the original problem down to a much smaller size and included the code at the end of the message. Here is the main loop. The l