Re: Template Toolkit on Windows 7

2012-07-11 Thread Arms, Mike
Dennis Daupert [ddaup...@csc.com] wrote:
  Run the script or cmd as admin (right click on the command icon,
  select run as admin) would probably help
 
 This is a Perl script, configure.pl, no command icon to click on.
 Is there another way I can run it as admin?
 
 best,
 
 /dennis


Maybe do this:

Create a shortcut for it
Right click on it and select Properties
On the Shortcut tab, press the Advanced... button
Check the Run as administrator box 

If you need the CMD window console to stay up after running the Perl script, 
you could instead create a BAT file. The contents would be something like:

@echo off
C:\path_to_script\my_script.pl
PAUSE

Then right click on the BAT file, select Properties, select the Compatibility 
tab, check the Run this program as an administrator box.

This may or may not get you around file system permissions (I did not test) 
that Howard Tanner addressed in his email.

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: win32 and modifying a file

2012-06-07 Thread Arms, Mike
 -Original Message-
 From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
 win32-users-boun...@listserv.activestate.com] On Behalf Of Greg Aiken
 Sent: Thursday, June 07, 2012 4:08 PM
 To: Perl-Win32-Users@listserv.activestate.com
 Subject: [EXTERNAL] win32 and modifying a file
 
 dear win32 perl users, ive never actually known how to 'modfiy' a file using
 perl on win32.  up till now, ive always read file1, found the data i intended 
 to
 change, and have always created a new file 2 containing the changes.  if i
 wanted to 'simulate' changing file1, when done i could rename file2 to file1.
 in other words, ive never learned how to modify a file directly.
 
 ive read win32 makes it more difficult to do this than on unix os's.
 
 but in any case, today i wanted to ask the group.
 
 assumming 'file1' exists with the following 3 records in it:
 
 A
 B
 C
 
 is there a 'simple' code fragment someone could post that would
 demonstrate iterating through this file and when record 'B' is encountered,
 we want to change 'B' to 'B_modified' - done in a way where we only access
 'file1'.  maybe this cant be done, but im asking.
 
 yes i do realize there is another approach, upserp contents of 'file1' modify 
 in
 memory, delete 'file1', then recreate it by dumping the in-memory modified
 contents.  this seems more like a 'hack' than a direct manipulation of the
 original file.
 
 anyways, thanks to any who might be willing to enlighten me about this
 topic.
 
 greg

Possibly you want the Perl command line options:

   -i[extension]
specifies that files processed by the  construct are to be
edited in-place.  It does this by renaming the input file, opening
the output file by the original name, and selecting that output
file as the default for print() statements.  The extension, if
supplied, is used to modify the name of the old file to make a
backup copy, following these rules:

If no extension is supplied, no backup is made and the current
file is overwritten.

If the extension doesn't contain a *, then it is appended to the
end of the current filename as a suffix.  If the extension does
contain one or more * characters, then each * is replaced with
the current filename.  In Perl terms, you could think of this as:

($backup = $extension) =~ s/\*/$file_name/g;

This allows you to add a prefix to the backup file, instead of (or
in addition to) a suffix:

$ perl -pi'orig_*' -e 's/bar/baz/' fileA# backup to 
'orig_fileA'

Or even to place backup copies of the original files into another
directory (provided the directory already exists):

$ perl -pi'old/*.orig' -e 's/bar/baz/' fileA # backup to 
'old/fileA.orig'

But, when I try the following one-liner attempting to overwrite my file under 
Windows7 CMD shell, I get an error:

perl -pi -e s/^B$/B_modified/ file1
Can't do inplace edit without backup.

Note: This was run with ActivePerl v5.12.4 build 1205.

---

Also, when I tried running a similar command under Cygwin's Perl (v5.10.1), it 
behaves differently. It apparently defaults to assuming a .bak backup:

perl -pi -e 's/^B$/B_modified/' file1

produces:
file1   -- the new file
file1.bak   -- the original file

If I try using the * construct referred to in the perldoc:

perl -pi'*' -e 's/^B$/B_modified/' file1

it pretty much fails quietly as file1 ends up truncated as a zero length file 
(and there is no backup file).

---

So, maybe you can just live with this:

perl -pi.bak -e s/^B$/B_modified/ file1

It will first rename file1 to file1.bak, then process the file outputting each 
line into the output file, file1. You will end up with two files though.

Note: I did not code any guard to only do this action if the file name was 
file1. So you could pass any number of files to it, and it would iterate on 
each of them in similar fashion.

PS. Not sure that this is of any help to you as I ended up having two files. 
But at least it may illustrate some more power in Perl.

--
Mike Arms
ma...@sandia.gov


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Help with file redirect

2011-07-05 Thread Arms, Mike
http://search.cpan.org/~kenshan/IO-Tee-0.64/Tee.pm

Think you can use this module to do exactly what you want.

- Mike Arms


-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Barry 
Brevik
Sent: Tuesday, July 05, 2011 2:43 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Help with file redirect

I am writing an app that has a lot of screen output which it writes to
STDERR.

The screen output is copious, but I need it right now for debugging; I
can get rid of it later.

My question is if it is possible to write to STDERR and a named file at
the same time? I'd rather not go through the code and change every print
statement.

Barry Brevik
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


PPD for two modules?

2011-03-07 Thread Arms, Mike
Hi, all.

I am looking for PPD's for the following two modules compiled for ActivePerl 
v5.12.3:

String-CRC  (v1.0)  - note: NOT String-CRC32
Time-modules(v2006.0814)

I did not find them under the ActiveState, bribes, trouchelle, or uwinnipeg 
repositories. Anyone have a PPD source for them?

--
Mike Arms
(marms) AT (sandia.gov)



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Iffor

2006-04-19 Thread Arms, Mike
Bill Ng [bill.ng AT citigroup.com] wrote:
 Thanks,

 Just ordered it from Amazon.  Went the super-cheap route and ordered
 it free shipping ... should have it in a week or so.

  If anyone cares, I ended up using this as my code ... it accomplished
 exactly what I was looking for:
 ---
 for (grep($_ !~ /$zipDir/i, @folders))
 ---

 For those who weren't fond of that .. I'm sorry, but I did comment
 the hell out of that line =)

 Bill Ng


 D D Allen [dewey.allen AT us.ibm.com]
 snip good advice
   Read Damian Conway's Perl Best Practices.  And when you feel
   the need to write clever code, read it again.
 /snip
 
Bill, as long as your goal was *less efficient and obfuscated code*,
then you succeeded. You do realize that you are making a second
copy of all of the contents of @folders less the items that do
not match your regex? In the general case, if @folders is very
large, this is hugely expensive in terms of memory compared to
iterating across the list and just not doing whatever action if
the regex does not match. In both cases you are doing the test
against each element. As far as obfuscation, yes I read that you
commented the hell out of it, but that is little comfort for
doing something so obscure and needless. Not only is it harder
to maintain, I would suggest that it is harder to extend. And
my pity if this code is handed to someone else to maintain.
 
In a subsequent post, D D Allen wrote:
 Save cleverness for the times when it could make a significant,
 measurable difference.
 
Sing it, brother!
 
--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Iffor

2006-04-18 Thread Arms, Mike
Bill Ng [bill.ng AT citigroup.com] wrote:
 Syntax issue (I think),
 
 I'm trying to do the following:
 I need to execute a block of instructions for all items in an array
 except for one.
 
 So if my array was:
 @a=(1,2,3,4,5);
 And we assume that I don't want to execute the block if the value of
$_
 is 3 ...
 
 Then, in my head, I'm looking for the WORKING (key word there) version
 of this:
 ---
 @a = (1,2,3,4,5);
 if ($_ != 3) for (@a)
 {
   print something;
   doSomething();
   print somethingelse;
   yada($yada{$ya})
 }
 -
 
 But that if ... for line doesn't work.
 Neither does:
 
 for (@a, $_ != 3) {}
 
 
 Anyone got any ideas?  I've always done this by running a standard for
 loop and having an if condition inside the loop .. but that seems
 inefficient to me right now and I'm looking for the easier way.

Don't think you'll find anything simpler than the old standard next if
expr :

for ( @a ) {
next if $_ == 3;
print something;
doSomething();
print somethingelse;
yada($yada{$ya})
}

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Replace Leading Spaces

2006-04-07 Thread Arms, Mike
Dirk Bremer [Dirk.Bremer AT nisc.coop] wrote:
 Using a regex, I want to replace each leading space-character with a
 corresponding zero-character on a one-to-one basis. For an example
 string:
 
   my $string = ' 259.00 ';
 
 Note that I don't want to change the trailing space character. The
 resulting string would look like:
 
 '0259.00 '
 
 The total length of the string would remain the same after the
 replace operation.

Hi, Dirk,

You mean something like this?

  $string =~ s/^(\s+)(?=\d)/'0'x(length $1)/e; 

The power of the 'e' modifier on the substitution function. :-)

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Which LWP?

2006-02-10 Thread Arms, Mike
Assuming that I didn't miss a smiley face, the '-M' option
is a way do a use on a Module before executing your
program and the '-e' option allows you to specify the program
text directly on the command line.

Quoting from the perlrun FAQ:

  -m[-]module
  -M[-]module
  -M[-]'module ...'
  -[mM][-]module=arg[,arg]...
  -mmodule executes use module (); before executing your program. 

  -Mmodule executes use module ; before executing your program. 
  You can use quotes to add extra code after the module name, 
  e.g., '-Mmodule qw(foo bar)'.

  If the first character after the -M or -m is a dash (-) then 
  the 'use' is replaced with 'no'.

  A little builtin syntactic sugar means you can also say 
  -mmodule=foo,bar or -Mmodule=foo,bar as a shortcut for 
  '-Mmodule qw(foo bar)'. This avoids the need to use quotes 
  when importing symbols. The actual code generated by 
  -Mmodule=foo,bar is use module split(/,/,q{foo,bar}). Note 
  that the = form removes the distinction between -m and -M.

  -e commandline
  may be used to enter one line of program. If -e is given, 
  Perl will not look for a filename in the argument list. 
  Multiple -e commands may be given to build up a multi-line script.

  Make sure to use semicolons where you would in a normal program.

And as Rob (Sisyphus) said, you have to use different quoting
mechanisms under Unix versus Win32 shells. Examples:

   perl -MLWP -e 'print $LWP::VERSION\n'
   this works under Unix shells as the single quotes suppress
   the shell from trying to treat $LWP as an Environment variable
   substitution

   perl -MLWP -e print qq($LWP::VERSION\n)
   this works under the Win32 CMD shell as you can only use
   double quotes around a command line argument. The qq()
   construct is a alternative Perl way of specifying a
   string that allows variable interpolation.

Anyway, hope this helps.

--
Mike Arms


-Original Message-
From: Jerry Kassebaum [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 09, 2006 6:04 PM
To: Arms, Mike
Cc: perl-win32-users@listserv.ActiveState.com
Subject: RE: Which LWP?

Mike,

First, thanks!

Second, what was my book doing with telling me to enter

perl -MLWP -e 'print $LWP::VERSION\n '

from the command line??

Jerry


***

It's just the LWP module in libwww-perl.

Try doing this.

use LWP;
print version=, $LWP::VERSION, \n;

- Mike


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Jerry Kassebaum
Sent: Thursday, February 09, 2006 10:34 AM
To: perl-win32-users@listserv.ActiveState.com
Subject: Which LWP?

Tutors,

I am to the LWP chapter in Suehring's Beginning Perl Web Development.
I know I need to use PPM to install LWP, but which one??? Here's what I
tried:

ppm search LWP
Searching in Active Repositories
   1. LWP-attic  [1.00] LWP-attic
   2. LWP-Authen-Wsse[0.05] LWP-Authen-Wsse
   3. LWP-Charset[0.06] LWP-Charset
   4. LWP-LastURI[0.03] LWP-LastURI
   5. LWP-Protocol-http-SocksChain[1.2] LWP-Protocol-http-SocksChain
   6. LWP-Protocol-http-SocksChain10  [1.3]
LWP-Protocol-http-SocksChain10
   7. LWP-Protocol-sftp  [0.01] LWP-Protocol-sftp
   8. LWP-Protocol-virtual   [0.02] LWP-Protocol-virtual
   9. LWP-Simple-Cookies [0.01] LWP-Simple-Cookies
  10. LWP-Simple-Post[0.04] LWP-Simple-Post
  11. LWP-UserAgent-Determined   [1.03] LWP-UserAgent-Determined
  12. LWP-UserAgent-iTMS_Client  [0.15] LWP-UserAgent-iTMS_Client
  13. LWP-UserAgent-TWiki-TWikiGuest [0.01]
LWP-UserAgent-TWiki-TWikiGuest
  14. LWP-UserAgent-WithCache[0.03] LWP-UserAgent-WithCache
ppm install libwww-perl
Note: Package 'libwww-perl' is already installed.

Man, it is great to know a clear answer is on the way. Seriously, this
group is great!

Jerry

P.S. My guess is #12. My second guess is #14. #10?





___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Which LWP?

2006-02-10 Thread Arms, Mike
Gisle Aas [gisle AT ActiveState.com] wrote:
Mike Arms [marms AT sandia.gov] wrote:
 And as Rob (Sisyphus) said, you have to use different quoting 
 mechanisms under Unix versus Win32 shells

 A command line that works both on Unix and Windows shells is this one:

   perl -MLWP 99

Isn't the just because there is no dollar symbol in your
example that the Unix shell would try to expand inside of
the double quotes? 

Examples:

  perl -MLWP $foo

  perl -MLWP print $foo

Inside of double quotes, the Unix shell with try to replace $foo 
with the contents of an Environment variable named foo. If foo 
is not set, then it is replaced with the empty string. Either way 
you don't end up with a dollar sign inside of your Perl script 
which you would like to use to reference some Perl variable ($foo).

I'm not saying you can't use double quotes under a Unix shell, 
but they will require more internal escaping. Easier to use
single quotes around arguments under Unix shell.

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: comparing floating point numbers

2005-07-25 Thread Arms, Mike
 
Ed Chester [EMAIL PROTECTED] wrote:
 just a warning to be careful of subtracting or dividing similar
numbers in
 floating point and what your expectations are for the results. google
for
 'catastrophic loss of precision' or similar, or check out the floating
point
 standard (IEEE #754) for why these fall apart. *most* tests of
equality, or
 relative size, in *most* architectures, map to subtractions by the
time they
 get the processor. watch out. 

Ed, a cursory look at the search results from Google produced a bunch
of items that specifically referred to the floating point Error in
the first batch of Pentium chips. As this has been corrected, are there
other occurrences of 'catastrophic loss of precision' that can be
tested using modern Pentiums (e.g. II - IV) or AMD chips? Some URLs
would
be helpful here. Thanks.

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: How do I compare and get difference of two arrays

2005-02-25 Thread Arms, Mike
Sasi Kiran Kumar Mungamuru wrote:
 How Do I compare and get difference of two arrays as my 
 both arrays carries scalar values and my output should be 
 stored to another array.

In addition to the excellent responses by $Bill and others
I would add that I use Mark-Jason Dominus' excellent module,
Algorithm::Diff . This enables doing Unix style diff on
lists as it is sometimes important to know how the lists
differ in a concise manner.

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: perlctrl and cygwin - using cygwin development tools with pdk

2005-02-15 Thread Arms, Mike
wagnerc AT plebeian DOT com wrote:
 Edward Peschko (esp5 AT pge DOT com) wrote:
 However, when I try this, I get:
  No perl found at C:\perl\bin\perl.exe
 
 even though there *is* a perl found at C:\perl\bin\perl.exe
 
 /cygdrive/c/perl/bin/perl.exe
 
 Cygwin retains Unix's distaste for the MS-DOS style path.  
 Only ActiveState
 Perl understands c:\dir\

Ah, but cygwin also understands paths that use the drive
letter, colon, and forward slashes. Example:

  ls -l C:/perl/bin/perl.exe

So that is another possibility for Edward.

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Using regular expressions to replace file text?

2004-12-22 Thread Arms, Mike
Matt Harp wrote:
 This has to be an easy question to answer, but I've been 
 looking and hacking for a day now and can't figure it out.
  
 I want to just do search/replace on a set of files using 
 regular expressions.
  
 I have ActiveState 5.8.6 installed on WinXP, if that matters.
  
 I am trying it like this...
  
 perl -i.bak -pe s/^ext$/HARP/m fred.txt
  
 Perl help says that using m should result in ^,$ matching 
 beginning of line, end of line, but that's not what this 
 does. It matches any 'ext' string and replaces it with HARP. 
 I've tried \n instead also, but then that doesn't replace anything.
  
 My second question is of course, how to make this into a 
 script so I can pass *.txt. I've found a couple scripts but 
 none of them will even run w/o giving me errors.
  
 Any help on either issue would be immensley appreciated. I 
 can't take any more of this...
  
  
 Regards,
  
 -matt [EMAIL PROTECTED] 
 [EMAIL PROTECTED]
 
I'm guessing that the issue is that you need to put the script 
portion in quotes:

  perl -i.bak -pe s/^ext$/HARP/m fred.txt

Try that and let us know.

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Using regular expressions to replace file text?

2004-12-22 Thread Arms, Mike
Matt Harp
 Thanks Mike!
 
 I had tried single quotes but didn't think to try double quotes.
 
 I should probably be banned from this mailing list for such stupidity.
 
 but Ok, I'll push my luck... Any hints on how to make this a script
 that'll let me pass *.*?
 
 I seem to remember a reference to a way to tell it to work on multiple
 files from the cmd-line but can't seem to find the forum post any
 longer.
 
 Something like -file (name=*.*)? Or something...
 
 -matt
 mharp AT seapine DOT com
 

 Arms, Mike [marms AT sandia DOT gov] 
  Sent: Wednesday, December 22, 2004 5:40 PM
  To: Matt Harp; perl-win32-users@listserv.ActiveState.com
  Subject: RE: Using regular expressions to replace file text?
  
  Matt Harp wrote:
   This has to be an easy question to answer, but I've been 
  looking and 
   hacking for a day now and can't figure it out.

   I want to just do search/replace on a set of files using regular 
   expressions.

   I have ActiveState 5.8.6 installed on WinXP, if that matters.

   I am trying it like this...

   perl -i.bak -pe s/^ext$/HARP/m fred.txt

   Perl help says that using m should result in ^,$ matching 
   beginning of line, end of line, but that's not what this
   does. It matches any 'ext' string and replaces it with HARP.
   I've tried \n instead also, but then that doesn't replace 
   anything.

   My second question is of course, how to make this into a 
   script so I can pass *.txt. I've found a couple scripts but
   none of them will even run w/o giving me errors.

   Any help on either issue would be immensley appreciated. I 
   can't take any more of this...

   Regards,

   -matt
   mharp AT seapine DOT com
   
  I'm guessing that the issue is that you need to put the 
  script portion in quotes:
  
perl -i.bak -pe s/^ext$/HARP/m fred.txt
  
  Try that and let us know.
  
  --
  Mike Arms

Single quote work great in Unix/Linux. In fact I prefer them there
as they prevent the $ for being interpreted as an Environment
variable reference.

But under Win32, single quotes do not work. You have to use
double quote. Fortunately, it does not try to do any command
line substitutions. By the way, if you need to use double quotes
in your script, I recommend using the qq() construct. Example:

  perl -e $i='foo'; print qq(This is a $i test\n);

On to your multiple files question, you may want Jenda Krynicky's
G module:

  http://jenda.krynicky.cz/#G

then try:

  perl -MG -i.bak -e while (){ s/(^ext$/HARP/m; print; } *.txt

or recursive even: 

  perl -MG=R -i.bak -e while (){ s/(^ext$/HARP/m; print; } *.txt

The globbing wouldn't be an issue if you were on Linux/Unix. :-)

--
Mike Arms



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Using regular expressions to replace file text?

2004-12-22 Thread Arms, Mike
[Decided to top-post this time since Matt is.]

Under Win32, you need to set binmode() on binary files:

  my $file = 'myImage.jpg';
  # Opening binary file for read  write.
  open( IMAGE, +$file ) or die *** Trouble opening '$file' : $!\n;
  binmode( IMAGE );

I would caution you though that you are always safer opening
one file in Read mode and another file descriptor in Write mode.
Then after you are done writing to the new file, close the
file handles, then delete the old file, and rename the new
file to the old file's name. This prevents various nastiness
when in a multi-processing environment. And you don't clobber
your original file until you have completely finished writing
your replacement file which protects you from your own logic
errors. Just a suggestion.

  while ( @ARGV )
  {
my $out = $_.NEW;
open( IN, $_ ) or die *** Trouble opening '$_' : $!\n;
open( OUT, $out ) or die *** Trouble creating '$out' : $!\n;
binmode( IN );
binmode( OUT );
# ...
close( OUT );
close( IN );
unlink $_;
rename $out, $_;
  }

--
Mike Arms


 -Original Message-
 Matt Harp wrote:
 
 Thanks much for the info.
 
 One question though...
 
 I'm trying Perl because using the ReplaceRegExp stuff from Ant script
 was corrupting my binary files. Now that I got Perl working, 
 I find out
 that it's corrupting my binary files too :(
 
 I'm trying to do this stuff on a cvs ,v archive file that represents a
 binary file (a .jpg for my testing). Doing a search/replce from my Vim
 editor or from CodeWright works great and doesn't corrupt the 
 file. But
 running that Perl command on that ,v file ends up with a 
 corrupted image
 file when I do a Checkout from CVS.
 
 Are there special flags to tell Perl to stop corrupting my 
 binary files?
 Am I hosed, and should just stick to do it from an editor?
 
 Thanks,
 
 -matt
 mharp AT seapine DOT com
 
  
 
  -Original Message-
  Mike Arms [marms AT sandia DOT gov] wrote:
  
  Matt Harp
   Thanks Mike!
   
   I had tried single quotes but didn't think to try double quotes.
   
   I should probably be banned from this mailing list for such 
  stupidity.
   
   but Ok, I'll push my luck... Any hints on how to make 
 this a script 
   that'll let me pass *.*?
   
   I seem to remember a reference to a way to tell it to work 
  on multiple 
   files from the cmd-line but can't seem to find the forum post any 
   longer.
   
   Something like -file (name=*.*)? Or something...
   
   -matt
   mharp AT seapine DOT com
   
  
Mike Arms [marms AT sandia DOT gov]

Matt Harp wrote:
 This has to be an easy question to answer, but I've been
looking and
 hacking for a day now and can't figure it out.
  
 I want to just do search/replace on a set of files 
  using regular 
 expressions.
  
 I have ActiveState 5.8.6 installed on WinXP, if that matters.
  
 I am trying it like this...
  
 perl -i.bak -pe s/^ext$/HARP/m fred.txt
  
 Perl help says that using m should result in ^,$ matching 
 beginning of line, end of line, but that's not what 
  this does. It 
 matches any 'ext' string and replaces it with HARP.
 I've tried \n instead also, but then that doesn't replace 
 anything.
  
 My second question is of course, how to make this into 
  a script so 
 I can pass *.txt. I've found a couple scripts but 
 none of them 
 will even run w/o giving me errors.
  
 Any help on either issue would be immensley 
  appreciated. I can't 
 take any more of this...
  
 Regards,
  
 -matt
 mharp AT seapine DOT com
 
I'm guessing that the issue is that you need to put the script 
portion in quotes:

  perl -i.bak -pe s/^ext$/HARP/m fred.txt

Try that and let us know.

--
Mike Arms
  
  Single quote work great in Unix/Linux. In fact I prefer them 
  there as they prevent the $ for being interpreted as an 
  Environment variable reference.
  
  But under Win32, single quotes do not work. You have to use 
  double quote. Fortunately, it does not try to do any command 
  line substitutions. By the way, if you need to use double 
  quotes in your script, I recommend using the qq() 
 construct. Example:
  
perl -e $i='foo'; print qq(This is a $i test\n);
  
  On to your multiple files question, you may want Jenda 
  Krynicky's G module:
  
http://jenda.krynicky.cz/#G
  
  then try:
  
perl -MG -i.bak -e while (){ s/(^ext$/HARP/m; print; } *.txt
  
  or recursive even: 
  
perl -MG=R -i.bak -e while (){ s/(^ext$/HARP/m; print; } *.txt
  
  The globbing wouldn't be an issue if you were on Linux/Unix. :-)
  
  --
  Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: numeric vs string scalars...difference?

2004-11-16 Thread Arms, Mike
Paul Rogers [perl-users AT coservers DOTnet] wrote:
 I need to dynamically do comparisons tests on an array of 
 values...some strings, some numeric.  One snag I hit is
 comparing the occasional numeric values.  Using eq as
 the comparison operator fails on comparisons like
 45.0 vs 45.
 
 Is there a way to determine if a scalar value is indeed numeric?

Look in the Perl FAQ for various regex tests for a numeric.
Then do this (pseudo-code):

  if ( is_numeric( $left)  is_numeric( $right ) )
  {
$is_equal = $left == $right;
  }
  else
  {
$is_equal = $left eq $right;
  }

That is, only use the numeric equality test '==' if both values
are numeric. Otherwise use the string equality test 'eq'.

--
Mike Arms


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Trouble printing a field

2004-10-07 Thread Arms, Mike
Gary Kuznitz [EMAIL PROTECTED] wrote:
 I'd like to print what is in %BlaklistedIPs.  Could somone please 
 let me know what am I doing wrong?

   my %BlacklistedIPs = map +( $_, 1 ), split (/\\e/,
$cli-GetBlacklistedIPs());
  print \%BlacklistedIPs from server = \n %BlacklistedIPs;

If you just want to see what is in %BlacklistedIPs say for
debugging purposes, I recommend using the Data::Dumper module:

  use Data::Dumper;
  $Data::Dumper::Indent = 1;
  print Data::Dumper-Dump( [ %BlacklistedIPs ], [qw(*BlacklistedIPs)] );

This will print out the contents of %BlacklistedIPs no matter
how complex your hash is.

On the other hand, if %BlacklistedIPs is just a simple hash of
keys and their associated string values, then:

  print $_ = $BlacklistedIPs{$_}\n for sort keys %BlacklistedIPs;

Hope any of this is illustrative.

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: The old \015 problem

2004-10-07 Thread Arms, Mike
Title: RE: The old \015 problem






David D Miller [ddmiller AT raytheon DOT com] wrote:

I just copied (using ftp in binary mode) my perl scripts from DOS 

to Unix and got caught on the carriage return problem: When I 

try to executethe DOS scipt in Unix, I get the following



[mdscom]/usr/people/dmiller/WWW/cgi perl wtdl.pl -w

Illegal character \015 (carriage return) at wtdl.pl line 5.

(Maybe you didn't strip carriage returns after a network transfer?)



Good message. Right on target. The question is, how do I remove 

those pesky CRs?


Easiest: use the dos2unix executable (available on Linux and most Unix)


Pure Perl (run under Linux/Unix):


 perl -pe 's/\r$//' filename  filename.stripped


--

Mike Arms



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: array size confusion

2004-09-17 Thread Arms, Mike
One thing that I would suggest. If you are getting data
from a source that uses CRLF for its line endings while
running your Perl script on a machine that just uses LF
for line endings (whew!), then you may need to add one
line after the chomp to strip off the CR:

  while (STUFF){
chomp;
s/\r$//;

Obviously you won't see it using DATA as that will be
on the same machine. But I see it often between Win32
and Linux/Unix systems (also when requesting data via HTTP).

On the other hand, this may be nowhere near your problem.
I just figured I should mention it since you are doing a
test for string equality.

--
Mike Arms


-Original Message-
From: Gerber, Christopher J [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 17, 2004 2:39 PM
To: Liam Arbetman; [EMAIL PROTECTED]
Subject: RE: array size confusion


 i am reading a txt file where data elements are separated by 
 |. some lines are only contain a |.  i get an 
 uninitialized value in string eq error at the last line of 
 code above--but only on lines that have more than just |.
 
 wtf?
 
 i am convinced that it's something ridiculously simple and i 
 made a really simple mistake.  but for the life of me i can't 
 figure it out.

Liam,

I couldn't get your code to run as is, so I tweaked it a little and don't
see any problems.  My changes include:
* Change STUFF to DATA so that I can include data inside
  my script
* Use strict, use warnings
* Add my before variable names (because of strict)
* Remove invalid last statement: if($arrsize1);  (Maybe
  you didn't want a semicolon on the previous line?)
* Close the curly brace
* Make indenting more consistent
---8---
use strict;
use warnings;

while (DATA){
   chomp;
   my @line=split/\|/;
   my $arrsize=0;
   if($_ eq |){
  $arrsize=0;
   } else {
  [EMAIL PROTECTED];
   }
   print $arrsize\n;
}
__DATA__
|
test|test

X
---8---

Chris


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be
privileged. It is intended for the addressee(s) only. Access to this E-mail
by anyone else is unauthorized. If you are not an addressee, any disclosure
or copying of the contents of this E-mail or any action taken (or not taken)
in reliance on it is unauthorized and may be unlawful. If you are not an
addressee, please inform the sender immediately.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Request: howto install GD.pm using ppm on 5.8?

2004-09-09 Thread Arms, Mike
step 3 profit

:-)

--
Mike Arms


-Original Message-
From: Michael 'topdog' Thompson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 09, 2004 11:40 AM
To: [EMAIL PROTECTED]
Subject: Request: howto install GD.pm using ppm on 5.8?

hi ,

step 1 is ppm

step 2 is install GD

step 3 is ???

regards,
michael thompson

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Chop!

2004-06-18 Thread Arms, Mike
Suchindra Sandhu [EMAIL PROTECTED] wrote:
 Suppose  I have a string like 
 $sequence = [sas];
 How can I get rid of the leading and trailing brackets and just have
 $sequence = sas;
 
 One way I thought of was :
 chop($sequence);
 reverse($sequence);
 chop($sequence);
 reverse($sequence);
 
 This doesnt seem very clever. Can someone please help ?


my $string = '$sequence = [sas]';
$string =~ s/\[(.*?)\]/$1/;
print string='$string'\n;

Output is:

string='$sequence = sas'

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Convert .bat files to .com

2004-06-11 Thread Arms, Mike
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:
 Actually I need to convert all .bat files to .exe files..

It has to be asked: Why?

I'm at a loss to see the reasons behind the percieved 
need for such an action. By the way, not all .BAT actions
could successfully be done via compiled code (EXE or COM).
The setting of Environment variables which persist after
running a BAT is easily done, but I do not think is even
possible via compiled code (without creating a sub-shell
which gets memory intensive REAL fast with repeated use).

Example:

- start setfoo.bat ---
@echo off
set FOO=bar
- end setfoo.bat ---

Run it, and then type set. You will see that FOO is still
set. Try to do that in a compiled program. Best of luck.

Still the question of why the need to convert all
of you .bat to .exe files remains.

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: named hash inside of hash

2004-06-08 Thread Arms, Mike
Look up autovivification:

 
http://www.google.com/search?hl=enlr=ie=ISO-8859-1q=perl+autovivification
btnG=Search

Just part of the power of Perl.

--
Mike Arms


 -Original Message-
 From: Matt Bazan [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 08, 2004 4:51 PM
 To: [EMAIL PROTECTED]
 Subject: RE: named hash inside of hash
 
 
 Thanks for help, it's starting to make sense.  I don't understand this
 line:
 
  $ips{$source_ip}-{$dest_ip}++;
 
 how can you access and increment something that doesnt exist?  Thanks
 again.
 
  -Original Message-
  From: Peter Guzis [mailto:[EMAIL PROTECTED] 
  Sent: Tuesday, June 08, 2004 12:50 PM
  To: Matt Bazan; Thomas, Mark - BLS CTR
  Cc: [EMAIL PROTECTED]
  Subject: RE: named hash inside of hash
  
  Like this?
  
  ## begin code
  
  use strict;
  use Data::Dumper;
  
  my %ips;
  
  foreach my $source_ip ('192.168.1.2', '192.168.1.1', 
 '192.168.1.12') {
  
foreach my $dest_ip ('192.168.1.3', '192.168.9.19', 
 '192.168.9.1') {
  
  $ips{$source_ip}-{$dest_ip}++;
  
}
  
  }
  
  print Dumper \%ips;
  
  ## end code
  
   
  Peter Guzis
  Web Administrator, Sr.
  ENCAD, Inc.
  - A Kodak Company
  email: [EMAIL PROTECTED]
  www.encad.com 
  
  -Original Message-
  From: Matt Bazan [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, June 08, 2004 12:36 PM
  To: Thomas, Mark - BLS CTR
  Cc: [EMAIL PROTECTED]
  Subject: RE: named hash inside of hash
  
  
  Ok..here's a diagram:
  
  I need to setup a data structure that will keep track of a 
  source IP address.  Each source IP address I then need to 
  link to a destination IP
  (note: there can be multiple destiantion IP addresses for 
  each source) and a destination IP counter.  So, something like:
  
  source IP 1 - dst ip 1, counter
 dst ip 2, counter
 dst ip 3, counter
  source IP 2 - dst ip 1, counter
 dst ip 2, counter
  
  etc, etc.  Thanks! 
  
   -Original Message-
   From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED]
   Sent: Tuesday, June 08, 2004 12:28 PM
   To: Matt Bazan
   Cc: [EMAIL PROTECTED]
   Subject: RE: named hash inside of hash
   
create a hash who's first key's value is an anon ref to a
   hash who's
second key's value is a non-anon hash..get my drift?  
 Is there an 
easier way to do this?  Thanks..
   
   I have no idea what you're saying... so here's a stab in the dark:
   
   my $data = {
this = {
  is =   {
nested = 'true'
  },
  isnt = {
nested = 'false'
  }
}
  };
   
   print $data-{this}-{is}-{nested}; #prints 'true'
   print $data-{this}-{isnt}-{nested}; #prints 'false'
   
   Does that help?
   
   'perldoc perldsc' may help too.
   
   
   
   -- 
   Mark Thomas[EMAIL PROTECTED] 
   Internet Systems Architect DigitalNet, Inc. 
   
   $_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; 
   ;;print;;
 
   
   
   
  
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
  
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: quirky question....

2004-06-07 Thread Arms, Mike
bruce [mailto:[EMAIL PROTECTED]
 
 i have a simple/quirky question. i have a url --
 http://www.acs.rutgers.edu:8880/pls/sc_p/sc_display.select_maj
 or. i can get
 to this page by doing a submit from
 ==http://clue.rutgers.edu:8880/sc_pn/plsql/sc_display.main.
 
 however, when i try to simply use libwww or one of the other 
 perl packages to access the select_major page, i fail to 
 get it. just as a test, i copied the url from one browser 
 window to another, and the 2nd broswer couldn't access the page...
 
 can someone shed some light into what might be happening/going on..??
 
 i suspect that there's some kind of redirection/session 
 function in the background... i also tried enabling/disabling 
 cookies with no difference in behavior...
 
 thanks...
 
 -bruce


Ah, but it does work if you provide values for the
fields:

 
http://www.acs.rutgers.edu:8880/pls/sc_p/sc_display.select_major?p_campus=NB
p_level=Up_yearterm=20047

So, I would guess that the script is checking for
the existence (and maybe even validate values)
of the fields before attempting to pass them on
to another page. I am not too confident of this guess
though without knowing the code and just basing this
off of observed behavior. The good news is that the
extended URL that I have above illustrates that a
GET method will work. Hopefully this will help in
your sleuthing.

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: undef example

2004-05-07 Thread Arms, Mike
Sorry for the top posting, but I don't feel like manually
massaging the thread.

Hold on, Dave, before you stop using  on subroutines
and prototypes, I'd like to hear Rob's explanation
for both of his claims. This is the first I have ever
heard from one of the regulars here on this mailing list
recommending this.

I use prototypes for most of my code. Like use strict,
I prefer the slight reinforcement it provides. On the
other hand I rarely use the  symbol on a subroutine
unless I'm taking a reference of it like:

  finddepth( \wanted, $dir );

So Rob, I'd be interested in reading the reasons behind
your recommendations. Is this something that Damian Conway
or Mark Jason Dominus has written on? Thanks.

--
Mike Arms


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, May 07, 2004 12:26 PM
To: Rob Dixon
Cc: [EMAIL PROTECTED]
Subject: Re: undef example

Rob, 

Thanks for the help!  I learned something today from you.  As far as the
ampersand notation and prototypes I was using, I saw that use in the PERL
book I have and did not mention any reason why.  I've been using them for
years without problems.  I will stop using them. 

I also did not use the __END__ in the script.  For some strange reason I
put that in my message only to distinguish the main routine from the
subroutine.  I do not know why I picked that! 

Do you have any good books that you recommend which are good in describing
these uses and behaviors?  I've been using the O'Reilly camel book called
Programming PERL but it's pretty old (first edition). 

Regards,

Dave



Rob Dixon [EMAIL PROTECTED] 
05/07/2004 02:28 AM 

To:[EMAIL PROTECTED],
[EMAIL PROTECTED] 
cc: 
Subject:Re: undef example



Hi Dave.

See my answer in-line below.



[EMAIL PROTECTED] wrote:

 This may be a lame question and I understand what it's doing, but I would 
 like to know if it is possible to undefine a global EXPR if it's passed 
 into a subroutine?
 
 Code here reduced to the basics.  After the return from routine 
 closeFtpConn I want, in this case, $MVSFTP undefined.
 
 .
 my $MVSFTP;
 .
 
 $MVSFTP = Net::FTP-new( $mvsFtpHost, Debug = $myDebugMode )
   or errout(Cannot connect to $mvsFtpHost;);
 .
 .
 closeFtpConn ( $MVSFTP );

Don't use the ampersand notation unless you specifically need it. If you
don't know what it does differently then you don't need it!

 closeFtpConn($MVSFTP);

is the syntax to use.

 __END__

Perl will stop compilation at this line, so with it placed here
closeFtpConn() will be undefined and you'll get a run-time error.

 sub closeFtpConn ($) {

Like the ampersand notation, don't use prototypes unless you know
what they do, and you need that behaviour. In particular they're
for writing list operators, and you're not using closeFtpConn()
as a list operator. Just

 sub closeFtpConn {
   :
 }

Will do fine.

my ( $FTPOBJ ) = @_;

At this point the elements of the @_ array are aliases for the
actual parameters passed in the call. This line copies the value
of the first parameter into the (local) lexical variable $FTPOBJ.

$FTPOBJ-quit;
.
.
undef $FTPOBJ;

And this line undefines the lexical variable. It has no effect outside
the subroutine.

 }

However, because the elements of @_ are aliases, you can affect
the actual parameters by manipulating those elements, so

 undef $_[0];

will work for you. Since in this case the parameter is an object
reference it should work fine; but note that if you pass a constant
as the actual parameter then this statement will throw a run-time
error. You should use 'eval' to handle this case if it is a possibility.

HTH,

Rob

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: undef example

2004-05-07 Thread Arms, Mike
$Bill Luebkert [EMAIL PROTECTED] wrote:
 Using the  will disable the use of prototypes.  You 
 should naturally pre-declare your subs that use prototypes.

Doh! (Note to self: wait a little while longer before
replying as often all will be made clear.)

I actually did remember this back in the tiny recesses
of my brain. This is the reason why I rarely use the 
symbol -- because I almost always use function prototypes.

So all that remains is to hear why not to use function
prototypes. (Something tells me I should wait before
sending this -- augh, my first paragr..

ENDOFLINE

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: shifting bits

2004-03-29 Thread Arms, Mike
This combined with this quote from Anton:

  I'm trying to avoid people looking at the data without proper access

sounds like he is wanting to do some really simplistic encryption
of his data that will be stored in a database accessible by
others. Anton, this will be incredibly easy to decipher.
Maybe you should look into the real Crypt::* modules to
significantly increase your security. Of course, this depends 
on you not storing your keys in the clear either (and a list
of other concerns). 

--
Mike Arms


 -Original Message-
 From: Anton Ganeshalingam 
 [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 29, 2004 2:19 PM
 To: 'Mike Jackson'; Anton Ganeshalingam
 Cc: [EMAIL PROTECTED]
 Subject: RE: shifting bits
 
 Let's say my data is the following phrase 'Hello World'. This 
 phrase is represented in machine language in bits (assuming 
 I'm right). So this was the reason I thought I could insert
 the data into MS db after shifting a bit.
 
 tks
 Anton
 
 -Original Message-
 From: Mike Jackson [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 29, 2004 12:49 PM
 To: Anton Ganeshalingam
 Cc: [EMAIL PROTECTED]
 Subject: Re: shifting bits
 
 
 it sounds like you weren't talking about bit-shifting 
 integers... What do you mean by shifting a byte of
 data by any number?
 
 On Mon, 29 Mar 2004 12:23:21 -0800, Anton Ganeshalingam 
 [EMAIL PROTECTED] wrote:
 
  Mike,
  Thanks for your reply. But I'm confused not by your 
 answer but my
  lack of knowledge on this matter. How would I convert the data like 
  Hello
  World. Should I convert to acssii first ?
 
  tks
  Anton
 
  -Original Message-
  From: Mike Jackson [mailto:[EMAIL PROTECTED]
  Sent: Monday, March 29, 2004 12:16 PM
  To: Anton Ganeshalingam; '[EMAIL PROTECTED]'
  Subject: Re: shifting bits
 
 
   from perlop:
 
  Shift Operators
 
  Binary ``'' returns the value of its left argument 
 shifted left by the
  number of bits specified by the right argument. Arguments should be
  integers. (See also Integer Arithmetic.)
 
  Binary ``'' returns the value of its left argument 
 shifted right by the
  number of bits specified by the right argument. Arguments should be
  integers. (See also Integer Arithmetic.)
 
  so,
 
  use Win32::ODBC;
  $db = new Win32::ODBC('DBQ=myDB.mdb;Driver={Microsoft Access Driver
  (*.mdb)};') or die can't open database;
  $db-Sql SELECT * FROM myTable WHERE someVal=$myConditionalVal;
  if ($db-FetchRow) {
 my %datahash = $db-DataHash;
 $datahash{myVal} = $datahash{shiftAmt};
 $db-Sql UPDATE myTable SET myVal=$datahash{myVal} WHERE
  someVal=$datahash{someVal};
  }
  $db-Close();
 
  would retrieve a row from myTable where someVal equals 
 $myConditionalVal,
  shift myVal left by shiftAmt bits, and re-write... if you 
 wanna do the
  whole table, just push all the result hashes onto an array, 
 and when 
  done,
  go through the array, pop each one, do the shift and re-write...
 
  which would be even easier with a tied hash - but I havent 
 yet played 
  with
  tied hashes...
 
 
 
  On Mon, 29 Mar 2004 11:54:43 -0800, Anton Ganeshalingam
  [EMAIL PROTECTED] wrote:
 
 
 
  Hello to all,
I'm writing a perl program that will take a byte of 
 data and shift
  (right or left) it by any number and write it to a MS 
 access DB. Since
  Perl is free type language how would you accomplish this on perl.
 
  Please help.
 
  tks
  Anton

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: TK question - resizeable columns

2004-02-23 Thread Arms, Mike
Hi, Burak.

I'm not sure what your problem might be. Runs fine for me on
my system.

  OS: Win2K
  Perl: 5.6.1 (ActivePerl build 635)
  Tk: 800.024

You are running on the bleeding edge. Tk 804.025 is very
much beta right now. Which sub-version of Tk 804.025
are you running? Current is beta 14. I subscribe to the
pTk mailing list. There seem to be a lot of gotchas still
with that version. Patches come out weekly. Any way you
can go back to Tk 800.024 and try again?

--
Mike Arms


 -Original Message-
 From: Burak Gürsoy [mailto:[EMAIL PROTECTED]
 Sent: Saturday, February 21, 2004 1:51 PM
 To: [EMAIL PROTECTED]
 Subject: RE: TK question - resizeable columns
 
 
 I get errors with this module (installed via ppm).
 OS: Win2k
 Perl: 5.8.2
 Tk: Tk 804.025
 
 for example, I tried to run Tk-TableMatrix-1.01\demos\basic 
 in the distro
 and got this:
 so, I believe that this module is not compatible with my Tk 
 version? or
 what?
 
 #-
 --
 --#
 Had to create Tk::XlibVtab unexpectedly at 
 C:/Perl/lib/DynaLoader.pm line
 249.
 Can't call method die_with_trace on an undefined value at
 C:/Perl/site/lib/Tk/
 Widget.pm line 190.
  at basic line 35
 
 Tk::Widget::new('Tk::TableMatrix','Tk::Frame=HASH(0x1a9bacc)',
 '-sparsear
 ray',0,'-rows',8,'-colstretchmode','last','-rowtagcommand',...
 ) called at
 C:/Per
 l/site/lib/Tk/Widget.pm line 256
 
 Tk::Widget::__ANON__('Tk::Frame=HASH(0x1a9bacc)','-sparsearray
 ',0,'-rows
 ',8,'-colstretchmode','last','-rowtagcommand','CODE(0x2ef2d50)
 ',...) called
 at C
 :/Perl/site/lib/Tk/Widget.pm line 1201
 
 Tk::Widget::Scrolled('MainWindow=HASH(0x2f13e98)','TableMatrix
 ','-rows',
 8,'-cols',8,'-width',6,'-height',...) called at basic line 35
  at basic line 35
 #-
 --
 --#
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] 
 Behalf Of Arms,
 Mike
 Sent: Friday, February 20, 2004 11:34 PM
 To: 'Jeremy A'; [EMAIL PROTECTED]
 Subject: RE: TK question - resizeable columns
 
 
 Jeremy A [EMAIL PROTECTED] wrote:
  I have a Tk problem.
  I want to create a table. the table will contain rows and
  columns of cells. What i want is to have the column width
  resizeable (field resize within a table). I want the user
  to be able to resize width of a column using the mouse
  curser.
 
 Ok, now I have a better idea of what you are looking for.
 It's not an exact match for the behavior, but check out
 Tk::TableMatrix::Spreadsheet . It is very close. It does
 allow resizing of columns based on the mouse. I've included
 a sample program to illustrate.
 
 Hope this is more what you are looking for.
 
 --
 Mike Arms
 
 
 = cut here =
 #!/usr/bin/perl
 use strict;
 use warnings;
 
 use Tk;
 use Tk::TableMatrix::Spreadsheet;
 
 my $mw = MainWindow-new();
 
 my $rows = 21;
 my $cols = 5;
 
 # Where the data will be stored. Cells are addressed via key
 # of the form $row,$col.
 my %table = ();
 
 my $t = $mw-Scrolled( 'Tk::TableMatrix::Spreadsheet',
 -rows   = $rows,
 -cols   = $cols,
 -width  = 6,
 -height = 6,
 -titlerows  = 1,
 -titlecols  = 1,
 -variable   = \%table,
 -selectmode = 'extended',
 -resizeborders  = 'both',
 -titlerows  = 1,
 -titlecols  = 1,
 -bg = 'white',
 )-pack();
 
 # Sets the column widths to non-default sizes.
 $t-colWidth( 2, 40, 1, 15, 3, 15, 4, 20 );
 
 for my $row (0..$rows-1)
 {
 for my $col (0..$cols-1)
 {
 $t-set( $row,$col , R$row, C$col );
 }
 }
 
 # Set one cell special.
 $t-set( 3,2 , I set this one );
 
 MainLoop;
 
 # Just to show that it really was set into the variable.
 print table{'$_'} : $table{$_}\n for '2,1', '3,2';
 
 1;
 __END__
 # vim: ts=4 sw=4
 = cut here =


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Net::SSH::Perl

2004-02-10 Thread Arms, Mike
Derek Jones [EMAIL PROTECTED] wrote:
 John Ramsden [EMAIL PROTECTED] wrote:
  Just out of curiosity, in what sense did you find Math::Pari
  a PoC?
  
  Did you have trouble building it? I did a quick web search,
  and saw a couple of plaintive posts by people having trouble
  building it on AIX. I'm just wondering in case I ever need to
  use it.
 
 I could not get this (Math::Pari) to build on Win32 under 
 Cygwin. It was a known bug when I did a net crawl to find
 out more info. Anyone any more information? Activestate
 don't supply the module either, so I was seeking to build
 under the latest Cygwin port / toolset instead.
 
 I had no problem building under Linux.
 
 Derek Jones.

I successfully built it last night using cpan under Cygwin
on my WinXP-Pro system running the latest Cygwin updates.
I am using Cygwin's Perl 5.8.2-1 (the current version available).
Also, I may have required Cygwin's perl-libwin32 0.191-1
(the current version of this library) package. I am
using the most recent version of gcc and gnu make. Hope
this helps.

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: build perl 5.8.1 with gcc-3.3.1 w32api-2.4 and dmake-4.1pl1-w in32

2003-12-23 Thread Arms, Mike
Sisyphus [EMAIL PROTECTED] wrote:
 Ken Cornetet wrote:
  You will not be able to use modules containing compiled code without
  compiling them yourself. 
 
 Actually, any of the ActiveState ppm's that I've installed on my 
 mingw-built perl have worked fine. I've also installed mingw-built 
 binaries on AS perl without any problem.
 
 Having the mingw compiler does however enable you to build your perl 
 with different build options (eg no multithreading). And it 
 does enable you to build (XS) modules for which no ppm exists (eg
 your own modules) . all of that without having to spend a cent.
 
 Cheers,
 Rob

Rob, have you been able to compile the Tk module for Perl under
Cygwin? I assume by mingw compiler, you are using Cygwin. If so,
did you have to load any special Cygwin items (from Cygwin's setup
tool)? When I try to compile the Tk module using gcc under Cygwin,
I get all kinds of errors. I have been able to build some XS modules
under Cygwin, but not Tk (and a few others that I cannot recall just
now).

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: seek parameters

2003-12-16 Thread Arms, Mike
Well, I could see a possibility here, but this is total
speculation as I do not know the underlying implentation
of the sysseek function.

Think of the case of function prototypes:

  sub f (\@) { print 'foo'; }
  my @a = qw(b c d e f z);
  f( @a[-2,-3,-1] );

I get this error:

  Type of arg 1 to main::f must be array (not array slice)

The prototype specifies that this function expects an actual array
to be passed in (and it addresses it via a ref). The fact that it
knows the difference between an array slice and an array I think
means that that info concerning the type of args being passed to
a subroutine can be known to the subroutine.

So, maybe the code author for sysseek, since it is a pretty
low level (as in close to the OS) function, made an assumption
that the parameters being passed in were 3 individual scalars.
It could then misbehave if an array slice is passed in instead.
Maybe a direct interface to a C-function call.

Again - pure thought conjecture here on my part as I do not
know the Perl guts nor the specifics of sysseek. 

 And curiously,  the error from the first is about the 
 number of parameters.

This statement adds strength to my conjecture as an array slice
could be a single parameter (rather than three).

--
Mike Arms


 -Original Message-
 From: Sisyphus [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 16, 2003 4:27 PM
 Cc: Win32 perl
 Subject: Re: seek parameters
 
 
 Glenn Linderman wrote:
  Here's a strangeness:
  
  my $res = sysseek( @stk[ -2, -3, -1 ] );
  
  fails to compile, but
  
  my $res = sysseek( $stk[ -2 ], $stk[ -3 ], $stk[ -1 ] );
  
  compiles fine.  As far as I can tell, they have the same effect.
  
  And curiously,  the error from the first is about the 
 number of parameters.
  
 
 That would mean that '@stk[-2,-3,-1]' is being seen as other than 3 
 arguments. But that's impossible, isn't it ?
 
 ('parameters' mean 'arguments' doesn't it ?)
 
 I certainly can't explain it.
 
 Cheers,
 Rob
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Perl commands and Proxy servers (DPR#67741)

2003-12-12 Thread Arms, Mike
Assuming that you are able to get throught the proxy using your browser,
then we should focus on the name of the environment variable and
the value set for it. 

On both my windows sytem and my Unix (solaris) system, I use:

http_proxy=http://myproxy.domain.foo:80

You will need to set replace myproxy.domain.foo with the
name of your proxy server. The :80 after it specifies the
port that the proxy listens on. Note the lowercase letters
used for the environment variable http_proxy. This may (or
may not) be important on your system -- I think Win32 systems
tend to ignore casing but not sure.

Make sure that your proxy environment variables are indeed
set by typing this at the command prompt (if not maybe you
forgot to export them):

  set

Anyway, some ideas to look at. May not help depending on
your situation.

--
Mike Arms


 -Original Message-
 From: Furioli Giancarlo [mailto:[EMAIL PROTECTED]
 Sent: Friday, December 12, 2003 11:51 AM
 To: [EMAIL PROTECTED]
 Subject: R: Perl commands and Proxy servers (DPR#67741)
 Importance: High
 
 
 
 I've downloaded ActivePerl-5.8.0.806-MSWin32-x86.zip and I've 
 installed it on my PC WinNT4.0.
 I've installed http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd
 No problem until last week.
 
 Last week my company installed an Apache/1.3.26 proxy server 
 on our LAN.
 Now it's impossible to contact a web site with a perl command using =
 HTTPS protocol.
 If I use a browser I havn't any problem: I can send my 
 user-login and my =
 password to proxy with browser's command before contacting any site.
 I set the system's variables HTTP_proxy, HTTP_proxy_user, =
 HTTP_proxy_pass according hand-book instructions, but that not works.
 I also tried to set HTTPS_proxy, HTTPS_proxy_user, HTTPS_proxy_pass =
 (this is not written on hand-book) but not works too.
 
 Is there any perl-package to install before to execute my 
 perl command? =
 Where can I find it ?
 It is any step to do on our proxy ?=20
 
 Could you help me ?
 
 Thank-you.
 
 Best regards.
 
 G.Furioli

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Seemingly simple???

2003-12-10 Thread Arms, Mike
Try the Linux command: dos2unix

--
Mike Arms


 -Original Message-
 From: Maraglia, Dominicx [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, December 10, 2003 11:07 AM
 To: [EMAIL PROTECTED]
 Subject: Seemingly simple???
 
 
 Hello,
 
 I have a small problem, which at first seems simple, but has 
 proven to be a bit of a hair puller.
 
 A collegue and I are importing some windows formatted ascii 
 files (onto our linux systems) and extracting certain string 
 data.  Simple enough.  However, our problem is that some of 
 the string data is terminated with what appears to be a 
 windows carriage return..looks like this:
 
 somestring^M
 anotherstring^M
 
 I tried chop(), but it does not seem to recognize that character.
 
 Any suggestions?
 
 Thanks,
 Dominic
 
 
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: just installed ActivePerl on my win98 - what's next

2003-11-25 Thread Arms, Mike
Ted, you coding logic is faulty. Here is a much more compact way
to write it right way. :-)

my @adj = qw( totally really truly awesomely );
my @verb = qw( rules rocks dominates );
for my $y (0..20)   # No need to loop 500 times :-)
{
  print ViM;
  print ' ', ( $_  $y ? $adj[int(rand @adj)] . ($_  $y-1 ? ',' : '') :
$verb[int(rand @verb)] . !\n ) for 0..$y;
}

Enjoy! :-)

--
Mike Arms


 -Original Message-
 From: Ted Schuerzinger [mailto:[EMAIL PROTECTED]
 Sent: Friday, November 21, 2003 9:54 PM
 To: [EMAIL PROTECTED]
 Subject: RE: just installed ActivePerl on my win98 - what's next
 
 
 Messenger, Mark graced perl with these words of wisdom:
 
  ...and shame on you for continuing it! :)
 
 Well, if we're going to continue it, we should at least do it 
 in a way 
 that's actually related to Perl.  Here's a small script I 
 cooked up late 
 on a Friday evening:
 
 #! perl -w
 
 use strict;
 
 my ($x, $y);
 
 foreach $y (0 .. 500) {
print vim;
foreach $x (0 .. $y) {
   if ($x == $y) {
  print  sucks!\n;
  }
   else {
  print  really;
  if ($x+1 != $y) {
 print ',';
  }
   }
}
 } 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: RegEx to remove \x0D\x0A

2003-10-01 Thread Arms, Mike
Bullock, Howard A. [EMAIL PROTECTED] wrote:
 My script slurps in a file 
 
 Local $/;
 $data = FILE;
 
 and want to remove the CRLF's. but even a simple RegEx match does not
 succeed for me.
 
 These all have failed.
 
 print \nYES\n if $data =~ /\015\012/;
 print \nYES\n if $data =~ /\015\012/s;
 print \nYES\n if $data =~ /\x0D\x0A/;
 print \nYES\n if $data =~ /\x0D\x0A/s;
 print \nYES\n if $data =~ /\r\n/;
 print \nYES\n if $data =~ /\r\n/s;
 
 What I am doing wrong?

Without seeing more of the code, it is hard to say.
But here's some approaches:

1. Make sure $data has any contents (i.e. the read worked as expected).
Add these two lines. Does the length equal the file size? Do you see
multiple lines?

  print len=, length( $data ), \n;
  print data='$data'\n;

2. Make sure your file has CRLF's. I'd use Cygwin's od command.
You should look for \r \n in the output of this command.

  od -c datafilename

If the file was generated on a Mac, your probably see \r as line
terminators.
If the file was generated under Unix, your should see \n as line
terminators.
Some old oddball machines actually used \n \r.

3. Doh! Just noticed that you wrote: Local $/; . Maybe it is a typo
or your email client auto capalitalized. It must be lowercase:

  local $/;

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: RegEx to remove \x0D\x0A

2003-10-01 Thread Arms, Mike
Got it (I think).

Just add this after you open the file and before the read.

  binmode( FILE );

My tests on my machine agreed with you.

--
Mike Arms


 -Original Message-
 From: Bullock, Howard A. [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, October 01, 2003 12:17 PM
 To: 'Arms, Mike'; '[EMAIL PROTECTED]'
 Subject: RE: RegEx to remove \x0D\x0A
 
 
 More testing shows that...
 
 These two statements fail:
 print \nYES\n if $data =~ /\x0D/s;
 print \nYES\n if $data =~ /\x0d/s;
 
 These two statements succeed:
 print \nYES\n if $data =~ /\x0A/s;
 print \nYES\n if $data =~ /\x0a/s;
 
 As I stated before two different HEX editors show od oa 
 sequences in my file
 and I can print the $data variable to STDOUT successfully.
 
 This is running ActiveState's build 633.
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: 'which' functionality in Perl

2003-09-30 Thread Arms, Mike
Dax T. Games [EMAIL PROTECTED] wrote:
 How would I determine if a file existed in a directory in the 
 PATH environment variable on a Windows box with Perl.  If the 
 file exists I want to return the full path to the file.
 
 The functionality I want is similar to 'which' on Unix/Linux.

Dax, I second the folks recommending the Perl Power Tools (ppt)
if you want a straight implementation of Unix commands in Perl.

I wrote my own enhanced which.pl command which could do more than
the standard Unix which:

1. If on a Win32 platform, it is PATHEXT aware and will match
without typing the suffix. And in such a case it only matches
files that have a suffix in the PATHEXT list. Example:

  C:\which gvim
  C:\WINNT\gvim.bat
  C:\Pkgs\vim\vim61\gvim.exe

2. Each directory in the PATH environment variable is searched
and all matches are displayed (not just the first). You can
see this in the example above. This is useful to determine if
you have more than one executable of the same basename in 
various directories of your PATH. The first file with the given
basename hides the others from being executed (unless a full
path is specified).

3. Can type in a wildcard character '*' or '?' to have it match
any executables with that filename pattern. Example:

  C:\ which.pl jav*
  C:\Java\j2sdk1.4.1_02\bin\java.exe
  C:\Java\j2sdk1.4.1_02\bin\javac.exe
  C:\Java\j2sdk1.4.1_02\bin\javadoc.exe
  C:\Java\j2sdk1.4.1_02\bin\javah.exe
  C:\Java\j2sdk1.4.1_02\bin\javap.exe
  C:\Java\j2sdk1.4.1_02\bin\javaw.exe
  C:\WINNT\system32\java.exe
  C:\WINNT\system32\javaw.exe

Another example illustrating two wildcards:

  C:\which *nd*
  C:\Perl\bin\find2perl.bat
  C:\Pkgs\bin\pfind.pl
  C:\Perl\bin\find2perl.bat
  C:\WINNT\system32\append.exe
  C:\WINNT\system32\command.com
  C:\WINNT\system32\expand.exe
  C:\WINNT\system32\faxsend.exe
  C:\WINNT\system32\find.exe
  C:\WINNT\system32\findstr.exe
  C:\WINNT\system32\nddeapir.exe
  C:\WINNT\system32\rundll32.exe
  C:\WINNT\system32\sndrec32.exe
  C:\WINNT\system32\sndvol32.exe

4. A command line option ('-l' or '--list') to provide a
directory listing for matching items. Example:

  C:\which -l jav*
  2003/02/20 14:17:34 24677  C:\Java\j2sdk1.4.1_02\bin\java.exe
  2003/02/20 14:17:34 28794  C:\Java\j2sdk1.4.1_02\bin\javac.exe
  2003/02/20 14:17:34 28800  C:\Java\j2sdk1.4.1_02\bin\javadoc.exe
  2003/02/20 14:17:34 28794  C:\Java\j2sdk1.4.1_02\bin\javah.exe
  2003/02/20 14:17:34 28790  C:\Java\j2sdk1.4.1_02\bin\javap.exe
  2003/02/20 14:17:34 28775  C:\Java\j2sdk1.4.1_02\bin\javaw.exe
  2003/02/20 14:17:38 24677  C:\WINNT\system32\java.exe
  2003/02/20 14:17:38 28775  C:\WINNT\system32\javaw.exe

5. A command line option ('-m' or '--md5') to compute a
MD5 digest checksum for matching items. Example:

  C:\which -m jav*
  9f455abce73150ed13707c1827589501  C:\Java\j2sdk1.4.1_02\bin\java.exe
  96fa7cc38ef36a16750cdfaeb7ce7c84  C:\Java\j2sdk1.4.1_02\bin\javac.exe
  2e2752ccf39d3d8d5654153b23ef44d0  C:\Java\j2sdk1.4.1_02\bin\javadoc.exe
  d967925f345b70bcc2c379b0e9e65c35  C:\Java\j2sdk1.4.1_02\bin\javah.exe
  29bf016d4642956a47364b0e0b612d36  C:\Java\j2sdk1.4.1_02\bin\javap.exe
  2ec1d702ff5252e88e12b124c53f9099  C:\Java\j2sdk1.4.1_02\bin\javaw.exe
  9f455abce73150ed13707c1827589501  C:\WINNT\system32\java.exe
  2ec1d702ff5252e88e12b124c53f9099  C:\WINNT\system32\javaw.exe

Note: the '-m' and '-l' options can be combined:

  C:\which -l -m java
  9f455abce73150ed13707c1827589501  2003/02/20 14:17:34 24677
C:\Java\j2sdk1.4.1_02\bin\java.exe
  9f455abce73150ed13707c1827589501  2003/02/20 14:17:38 24677
C:\WINNT\system32\java.exe

This is good for finding truly duplicate executables.

6. On Win32 platforms, the current directory '.' is prepended
to the PATH list as this is implied on Win32 systems (this
is not implied on Unix systems). Example:

  C:\Tempwhich which
  .\which.pl
  C:\Pkgs\bin\which.pl

7. I also implement multi-level debugging and tracing to
allow more explanation of the breakout of the filename argument
and the PATH and PATHEXT environment variables. Example:

  C:\Tempwhich -# which*
  Debugging C:\Temp\which.pl -d which
 version  = v1.4 2003/09/14
 debug= 1
 filename = which
 PATHEXT  = .COM .EXE .BAT .CMD .VBS .VBE .JS .JSE .WSF .WSH .PL
  Matches:
 .\which.pl
 C:\Pkgs\bin\which.pl
 C:\Pkgs\bin\which0.bat
  which.pl: Finished


This may be overkill for your needs, but I have found
this to be an extremely useful utility on my Win32
platform. I add to it occasionally when I find more
things that I want it to be able to do.

You can get it here:

  http://marms.sourceforge.net/perl/

--
Mike Arms



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: *nix or Windows Text Files?

2003-09-30 Thread Arms, Mike
Hanson, Rob [EMAIL PROTECTED] wrote:
 If you want the same line endings under *nix and Windows you could
 explicitly state the line ending:
 
 my $NL = \x0A; # ascii 10 in hex
 print The end is near$NL;
 
 \n will use the system default.

Not true. On a Win32 system, the above will priduce output ending
in CR-LF (\x0a\x0d) just like \n.

Verification:

  C:\perl -e print qq(\n) | od -tx1
  000 0d 0a
  002

  C:\perl -e print qq(\x0a) | od -tx1
  000 0d 0a
  002

You could turn on binmode STDOUT to get just a LF (\x0a):

  C:\perl -e binmode STDOUT; print qq(\x0a) | od -tx1
  000 0a
  001

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: The Unofficial Perl Win32 Users Flameware/Mega-Thread FAQ

2003-09-23 Thread Arms, Mike
Michael D. Smith [EMAIL PROTECTED] wrote:
 You will recall the current mega-thread started not with a 
 question but a mention of it in jest. I hesitate to say 
 it for obvious reason but since everyone knows what it
 means, that may not matter. We may all be doomed to lifetime
 filled with hundreds of emails about it.

The correct answer for it is, of course, VIM.


:-)

We are no longer the Knights-Who-Say-Ni!

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: newbie hlelp!

2003-09-18 Thread Arms, Mike
Lee Goddard ([EMAIL PROTECTED]) wrote:
 How about:
 
() - plain/round parenthesis/brackets
[] - square parenthesis/brackets
{} - curly parenthesis/brackets, set delimiters (maybe not)
 - angle brackets; greater-/less-than
 
 Really, though, bull aside, do you Yankees really
 think () are not brackets?  Or [] aren't?

Well, I'm taking a chance in replying to this thread that
Lee isn't just trolling or having a good laugh. To answer
your question, No, I do not think () are brackets. Here goes
from a Yankee's perpective:

  () - parentheses (or shortened as parens)
  [] - brackets (or referred to as square brackets if the other person
doesn't understand)
  {} - braces (or referred to as curly braces if the other person doesn't
understand)
   - angle brackets (or referred to as less-than greater-than if the other
person doesn't understand)

While we're at it, some more computer geek lingo:

  !  - bang; as in !! is bang-bang to repeat the last command in many
Unix shells
  #  - pound
  *  - star
  /  - slash
  \  - backslash
  |  - pipe

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: newbie hlelp!

2003-09-16 Thread Arms, Mike
Lee Goddard ([EMAIL PROTECTED]) wrote:
 opendir opens a directory so the contents can be listed.
 utime changes the modification times associated with the file.
 stat will give you the last modified time (as will -M).
 
 warn -M $file;
 warn ((stat ($file))[9])


Trevor Joerges ([EMAIL PROTECTED]) wrote:
 Try perldoc -f -M.
 
 my $modtime = -M file; # will get you the last modified time in days.

A correction for Lee and Trevor. The -M function is not 
the same as  (stat $file)[9] which is what the original
poster wanted (i.e. mtime of a file).

Here is the section from perldoc -f -M :

   -M  Age of file in days when script started.

Let's try it. I have two files in my current dir doit.bat and doit.sh:

   ls -l doit.*
  -rwxr-xr-x1 marmspwrusers 1360 Feb  6  2003 doit.bat
  -rwxr-xr-x1 marmspwrusers 1502 Jul 17 11:27 doit.sh

So I run this test:

  perl -e 'for (@ARGV) { print $_ : -M=, -M $_,   mtime=, (stat $_)[9],
\n }' doit.*

Produces this as output:

  doit.bat : -M=222.013171296296  mtime=1044548597
  doit.sh : -M=60.9687268518519  mtime=1058462837

Hope this helps.

--
Mike Arms


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Rename hash keys

2003-09-04 Thread Arms, Mike
Gerard ter Haar ([EMAIL PROTECTED]) wrote:
 I have a hash related question. Thanks in advance for your assistance!
 
 I have quite a large number of values in a hash:
 
 $errs-{ err_main_notfound } = file not found. check config.;
 $errs-{ err_main_perms } = no permissions, check docs.;
 $errs-{ err_main_unknown } = unknown error occured.;
 
 Now I would like to remove the _main part of the hash keys, 
 so I would get:
 $errs-{ err_notfound } = file not found. check config.;
 $errs-{ err_perms } = no permissions, check docs.;
 $errs-{ err_unknown } = unknown error occured.;
 
 How can I accomplish this using some perl statements?

The following code is tested:

  $errs-{ err_main_notfound } = file not found. check config.;
  $errs-{ err_main_perms } = no permissions, check docs.;
  $errs-{ err_main_unknown } = unknown error occured.;
  $errs-{ foo } = untouched, eh?;

  for ( keys %$errs )
  {
next unless /^err_main_/;
my $oldkey = $_;
s/^err_main_/err_/;
$errs-{$_} = $errs-{$oldkey};
delete $errs-{$oldkey};
  }

  # This is so that we can easily see the contents of the hash.
  use Data::Dumper;
  print Data::Dumper-Dump( [$errs], [qw(*errs)] );



Produces this as output:

%errs = (
  'err_unknown' = 'unknown error occured.',
  'foo' = 'untouched, eh?',
  'err_perms' = 'no permissions, check docs.',
  'err_notfound' = 'file not found. check config.'
);

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regex Help Needed

2003-09-02 Thread Arms, Mike
It looks like you may be doing standard command line option
parsing (or almost standard as the '--' prefix is reserved
for long option names). If this is so, look at GetOpt::Std .

For a subroutine that does what you specified (tested):

  sub is_DTG_Option ($)
  {
my $opt = shift;
return 0 if $opt =! /^--?([mevqgn]+)$/;
my @c = split //, $1;
my %h = ();
for ( @c )
{
  return 0 if $h{$_}++;
}
return 1;
  }
  
  # Test various combinations (both legal and illegal)
  my @test = qw( --mevqgn -mevqgn ---mevqgn mevqgn -mv --qm -neq -ef );
  
  for ( @test )
  {
print $_  . is_DTG_Option( $_ ) . \n;
  }

--
Mike Arms


-Original Message-
From: Dax T. Games [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 02, 2003 11:26 AM
To: Perl Users
Subject: Regex Help Needed


I have a list of characters.  I need to get a list of all possble sequences
of these characters for example.  

I have a string that consists of '-mevqgn' I need to pattern match any
combination of 'mevqgn' with a preceding - or --.

Right now this is what I am doing but it is very ugly and difficult to come
up with the combinations and it makes my brain hurt!:

 if ($LS_Val =~ /-{1,2}(mevqgn|
   emvqgn|evmqgn|evqmgn|evqgmn|evqgnm|
   veqgnm|vqegnm|vqgenm|vqgnem|vagnme|
   qvgnme|qgvnme|qgnvme|qgnmve|qgnmev|
   gqmnev|gmqnev|gmnqev|gmneqv|gmnevq|
   mgnevq|mngevq|mnegvq|mnevgq|mnevqg|
   nmevqg|nemvqg|nevmqg|nevqmg|nevqgm|
   envqgm|evnqgm|evqngm|evqgnm|evqgmn|
   )/i) 
{
#Do Something;
}


A subroutine that takes the string of characters as an argument and then
returns 1 on success and undef on fail would be ideal for my purpose.


Any help is appreciated.

Dax

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Environment variables on Win98

2003-08-18 Thread Arms, Mike
Looks like one too many }, here:

4 = {  0 = { 1 = 'Windows 95',
   2 = 'Windows NT 4.0' }, },

and the close should be after:

 90 = { 1 = 'Windows Me' },

So the tested code becomes:

  my %maj_min_id = (
3 = {  51 = { 0 = 'Windows NT 3.51' }, },
4 = {   0 = { 1 = 'Windows 95', 2 = 'Windows NT 4.0' },
10 = { 1 = 'Windows 98' },
90 = { 1 = 'Windows Me' }, },
5 = {   0 = { 2 = 'Windows 2000' },
 1 = { 2 = 'Windows XP' },
 2 = { 2 = 'Windows Server 2003' }, },
);

--
Mike Arms


 -Original Message-
 From: $Bill Luebkert [mailto:[EMAIL PROTECTED]
 Sent: Monday, August 18, 2003 11:54 AM
 To: Arms, Mike
 Cc: [EMAIL PROTECTED]
 Subject: Re: Environment variables on Win98
 
 
 Arms, Mike wrote:
 
  Hi, Bill.
  
  Is there a bug in this entry:
  
 4 = {0 = { 1 = 'Windows 95' },
  10 = { 1 = 'Windows 98' },
  90 = { 1 = 'Windows Me' },
   0 = { 2 = 'Windows NT 4.0' }, },
  
  The second 0 = effectively wipes out the first.
  So you end up with no entry for Win95.
 
 Thanks for the catch.  Didn't notice the dup when I built the hash.
 Try this one:
 
 my %maj_min_id = (
   3 = { 51 = { 0 = 'Windows NT 3.51' }, },
   4 = {  0 = { 1 = 'Windows 95',
  2 = 'Windows NT 4.0' }, },
10 = { 1 = 'Windows 98' },
90 = { 1 = 'Windows Me' },
   5 = {  0 = { 2 = 'Windows 2000' },
   1 = { 2 = 'Windows XP' },
 2 = { 2 = 'Windows Server 2003' }, },
 );
 
  To see this, add this:
  
use Data::Dumper;
print Data::Dumper-Dump( [ \%maj_min_id ], [qw(*maj_min_id)] );
  
  --
  Mike Arms
  
  
  
 -Original Message-
 From: $Bill Luebkert [mailto:[EMAIL PROTECTED]
 Sent: Friday, August 15, 2003 10:51 PM
 To: Joe Camel
 Cc: [EMAIL PROTECTED]
 Subject: Re: Environment variables on Win98
 
 
 Joe Camel wrote:
 
 
 Does anyone know where online I could find out about
 env variables on win98? Some of the software I am
 supporting contains the following line:
 
 return unless !defined $ENV{PROMPT} or (defined
 $ENV{CMDLINE} and $ENV{CMDLINE}eq 'WIN');
 
 The purpose of the return statment is to prevent the
 rest of the code from running if the user has a DOS
 prompt open already. $ENV{PROMPT} is for XP/2000/NT4,
 whereas $ENV{CMDLINE} is suppose to be for WIN 95/98,
 but I am not sure if things are working properly since
 I don't have a copy of WIN98 handy. Thanks.
 
 This may be a more useful method:
 
 use strict;
 my %maj_min_id = (
   3 = { 51 = { 0 = 'Windows NT 3.51' }, },
   4 = {  0 = { 1 = 'Windows 95' },
  10 = { 1 = 'Windows 98' },
  90 = { 1 = 'Windows Me' },
   0 = { 2 = 'Windows NT 4.0' }, },
   5 = {  0 = { 2 = 'Windows 2000' },
   1 = { 2 = 'Windows XP' },
   2 = { 2 = 'Windows Server 2003' }, },
 );
 
 my ($str, $maj, $min, $bld, $id) = Win32::GetOSVersion();
 print OS Version = $maj_min_id{$maj}{$min}{$id} - $str 
 Build=$bld\n;
 
 
 
 -- 
   ,-/-  __  _  _ $Bill Luebkert
Mailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic
http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: mulitple graphs on one web page.

2003-08-05 Thread Arms, Mike
Mitch Raful ([EMAIL PROTECTED]) writes:
If you look at my code below you will see I have created two 
graphs from files.  How can I print both graphs on the same 
web page???

The question is: Do you know HTML?

I am not trying to be sarcastic here. This is primarily an
HTML question (not Perl - although you can certainly use
CGI.pm to write HTML). Below is a trivial example of
HTML displaying two images (centered). The pathnames for
the files must be either absolute or relative URL's
that your web server can serve. That means you need to 
write them out to a directory that your web server can
access for a remote user.

html
head
titleExample: two graphs/title
/head
body
center
img src=plot1_filename alt=Plot 1
br
img src=plot2_filename alt=Plot 2
/center
/body
/html

--
Mike Arms

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression Help

2002-06-10 Thread Arms, Mike

PS I have learned something from this post, I didn't know you could 
define a string using brackets as you have done...

Except that what you learned:

  $a = (12345678904539);

is a bad practise. It is a novice mistake. What is being done here is
an anonymous list has been created with one element: 12345678904539 .
The scalar $a is then assigned the last element of the array (which
in this case is also the first element. To see this, try:

  $a = (123, 456);
  print $a;
  # you will get: 456

Also, the value is not a string. It is a number. The following is an
error:

  $a = (abc);
  # this is an error!

--
Mike Arms


-Original Message-
From: Stephen J Martin [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 8:51 AM
To: steve silvers
Cc: [EMAIL PROTECTED]
Subject: Re: Regular Expression Help


On Mon, 10 Jun 2002 13:38:52  
 steve silvers wrote:
How can I put a white space between every second number.

I have $a = (12345678904539);
I want 12 34 56 78 90 45 39

I'm trying

$a =~ s/\\d[2*]/ /g; #This obviously dosen't work :-(

Also how can I tell if there are 3,4, or 5 digits.

$3dig = (888);
$4dig = ();
$5dig = (8);

Thanks in advance.
Steve.

Oops, forgot to answer the second part. But we really need more info.
Is each number (i.e. a run of digits) in a separate variable as you have
shown? If so simply find length($5dig), etc.

If it is not as simple as this (e.g. are the numbers in a file which you
will read in, is there one number per line, is there anything else on the
line, do you have to find all the numbers or just the first or just the
last, etc.) something like
print 3 digits found: $\n if ($string =~ m%[\d]{3}%);
may get you started, but note that 3 digits will be found even when there
are 4 or 5, so do the tests in the right order.
---
Steve Martin
[EMAIL PROTECTED]

PS I have learned something from this post, I didn't know you could define a
string using brackets as you have done...

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: How Perl Helped Find My Missing Gigabyte

2002-04-05 Thread Arms, Mike

For those who have the GNU Unix 'find' command (I use Cygwin),
you can just do this:

  find YourDirList -type f -size +100c -printf '%s %p\n' | sort -n

This will find any files 1,000,000 bytes or larger and list them
with their sizes in numerically ascending order.

Lots of power in GNU Unix commands, especially when combined.

--
Mike Arms


-Original Message-
From: Warner, William A [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 05, 2002 12:51 PM
To: Perl-Win32-Users
Subject: RE: How Perl Helped Find My Missing Gigabyte

Jim, 

I like your code. 

FYI, you can do the same thing with Windows Explorer. Select Tools, Find,
Files or Folders..., Advanced. It has a selection box that lets you select
at least and an entry box for the file size. 

Quite a gotcha you documented. My PC has gotten slower and slower too. I
still haven't figured out why. I'm not low on disk space. The disk has been
defragmented. I don't have a virus on it. I'm thinking that maybe my
registry has grown too big. I guess I'll have to reinstall the OS sometime.
Any ideas?

Bill Warner


-Original Message-
From: James E Keenan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 5:15 PM
To: Perl-Win32-Users
Subject: How Perl Helped Find My Missing Gigabyte

I share the following account of a problem I recently experienced using Perl
and Textpad on a Windows 98 box.  It may help other Perl-Win32-Users avoid
headaches.

In January I installed RedHat Linux 7.2 as a dual boot on my Windows98 box.
Prior to the partitioning my C: drive had 6.4G.  Recognizing that Windows is
a memory hog, when I partitioned I allocated approx 3.3G to Windows and 3.1G
to Linux.  I know that before partitioning I had used slightly less than 2G.
Hence, I expected that after partitioning a check on disk usage would show
that my Windows partition (hda1 as viewed from Linux) would appear to be
slightly less than two-thirds full.  And so it was.

In late March, however, when I would go to check available disk space on the
Windows drive, I would find that I only had 175M free space left; my Windows
drive appeared to be 95% full!  Other than a Microsoft Critical Update
and 5-6 CPAN modules, I hadn't installed any new software on the Windows
side in the previous 2 months.  What could explain the sudden disappearance
of approximately 1 gigabyte of free space?

I was very afraid I had contracted a virus, especially since I got a Windows
alarm box indicating I had been infected when I opened a news message on
comp.lang.perl.misc on March 30 or 31.  I updated my virus definitions and
ran every Norton/Symantec program I had -- but found no indication of any
viral infection or damage therefrom.  I began uninstalling software I had
not recently used, including my entire Java for Windows installation.  But
all this, not surprisingly, freed up only 250-300M on my C: drive; it was
still more than 90% full.  Everything on the Windows side was slowing down.

At an Easter dinner, of all places, a fellow guest overheard me talking
first about my computer problem and then about my love for Perl.  He said,
Yes, it's always a problem doing this in Windows, because you have to click
on each directory icon in Explorer to find out its size.  But if you know
Perl, you should be able to write something which identifies the largest
files on your system.

I was embarrassed that I hadn't thought of this, but once the challenge had
been laid down, I had to pick it up.  After several nights of sweat, I
developed the script below.  I first tested it out on smaller directories on
my Linux partition, then mounted Windows on my Linux file system and called
the script as a background process.  Since I have over 100,000 files on the
Windows side, the script took somewhere between 5 and 10 minutes to run.
But when it did it clearly identified 2 files, each created within the last
3 months, as being massively larger than anything else on the partition
(including the windows swap file). Their name and sizes were:

txp42f6.tmp930,473kb
txp12f5.tmp 86,742kb

Note that they total slightly over 1 gig.  I said, Aha!  I examined these
files with both vi from the Linux side and DOS Edit from the Windows side.
They were filled with the following strings repeated endlessly:

Use of uninitialized value in modulus (%) at insertfeed.pl line 8.

Use of uninitialized value in pattern match (m//) at dmhis1.pl line 28.

A massive file filled with Perl error messages?  I suddenly grasped what had
gone wrong.  When I write Perl on Windows I use Textpad, which, in general,
I really love, particularly the fact that you can run Perl scripts from
inside Textpad.  But when you get a runaway script (say, an infinite loop),
using Textpad's Stop command sometimes doesn't really stop the process.
(This seems to happen more when I try to run a Perl script that requires
command-line arguments from inside Textpad; I haven't devoted the time to
finding out why.)  Sometimes the process keeps going ...