Re: SFTP

2014-10-27 Thread Justin Allegakoen
Off on another tangent, but it seems not much has changed over the years:
http://code.activestate.com/lists/perl-win32-users/31633/

Math::Pari fails to install with strawberry with 5.20 on x64 - never had
the time to find out why.

I'm sure if you ask sisyphus nicely he'll try and put it up on his repo if
he can get it to build or he'll tell us why it failed at the worst.


Just in


On 28 October 2014 07:02, Ashley Hoff ah...@da.com.au wrote:

 That is pretty much the approach I have taken as well.  In my instance,
 the batch  is written dynamically, based on the required process (read from
 an INI file) and the files found either remotely or locally (based on
 wildcard searches).

 The command that we call looks like:
 $command = echo n|\$psftpDir\\psftp\ $ftpUid\@$ftpAddr -i $ftpKey -pw
 $ftpPwd -bc -b $commandFile 1$outputFile 2$errorFile

 The echo answers the caching prompt, the biggest gotcha that I have with
 the process.

 From: Mike Malony [mailto:mhmal...@gmail.com]
 Sent: Tuesday, 28 October 2014 9:22 AM
 To: Ashley Hoff
 Cc: Schwartz, Peter W; perl-win32-users@listserv.ActiveState.com
 Subject: Re: SFTP

 I had much the same experience.

 I've used both PSFTP.exe from Putty and sftp.exe from Cygwin.

 In both cases I write a batch file and execute the exe via a system call.

  $RUNSTRING = $main::sftpbin -b $SFTP_BATCH_FILE $SFTPLOGIN  $TEMPLOG;

 ## which translates to
 ##'c:\cygwin\bin\sftp -b c:\work\client_batch.txt user@site 
 \work\client_user.yyymmdd.log

  $my_rc = system($runstring);

 For error trapping you need to capture the output and scan it for key
 words.
 Though, I think sftp from cygwin give a pretty trustworthy success/fail
 return code. psftp doesn't.

 Good luck,
 Mike

 On Mon, Oct 27, 2014 at 5:05 PM, Ashley Hoff ah...@da.com.au wrote:
 Not sure if you are going to get much more of a response Peter - this mail
 list seems pretty dead.

 As far as I know, it's not an easy task to actually get SFTP client
 functionality in Perl.  I've had plenty of issues over the years, that I
 gave up trying to find a Perl module that will do what I want.

 In the end, I used PSFTP.exe via a system command call.  PSFTP is included
 with Putty.  It can be a bit of a hack, but you can get it to work.  Some
 of the Gotcha's include answering all the interactive prompts (or more to
 the point, ignore some of them) and capture output, but it's all doable.

 Cheers
 Ashley

 From: perl-win32-users-boun...@listserv.activestate.com [mailto:
 perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Schwartz,
 Peter W
 Sent: Tuesday, 28 October 2014 2:14 AM
 To: perl-win32-users@listserv.ActiveState.com
 Subject: SFTP

 I'm trying to locate an SFTP install for Windows (32-bit) but I can't seem
 to find anything in the PPM for some reason.  Does anyone have any
 recommendations on how to get this for Windows?

 
 Peter W Schwartz | Vice President | IB Tech Market | Investment Bank |
 J.P. Morgan | Floor 4, 115 S Jefferson Road, Bldg D, Whippany, NJ | T: +1(973)
 793-7407 | peter.w.schwa...@jpmorgan.com | jpmorgan.com

 This email is confidential and subject to important disclaimers and
 conditions including on offers for the purchase or sale of securities,
 accuracy and completeness of information, viruses, confidentiality, legal
 privilege, and legal entity disclaimers, available at
 http://www.jpmorgan.com/pages/disclosures/email.
 ___
 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

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


Re: learning references/dereferencing (understand $, @, %, but trouble understanding )

2012-12-20 Thread Justin Allegakoen
On 21 December 2012 06:30, Greg Aiken gai...@visioninfosoft.com wrote:

 #if one desires to pass a scalar reference into a sub-routine,
 #the easiest way to assign a local scalar to the contents of the scalar
 reference is...
 subroutine(\$scalar);
 sub subroutine {
my $subroutine_scalar = ${$_[0]};  #note you need the {} brackets, or
 this doesn't work!
print $subroutine_scalar\n;
 }

 #if one desires to pass an array reference into a sub-routine,
 #the easiest way to assign a local array to the contents of the array
 reference is...
 subroutine(\@array);
 sub subroutine {
my @subroutine_array = @{$_[0]};  #note you need the {} brackets, or
 this doesn't work!
print in subroutine:  . join(' ', @subroutine_array) . \n;
 }

 #if one desires to pass a hash reference into a sub-routine,
 #the easiest way to assign a local hash to the contents of the hash
 reference is...
 subroutine(\%hash);
 sub subroutine {
my %subroutine_hash = %{$_[0]};  #note you need the {} brackets, or
 this doesn't work!
print in subroutine:  . join(' ', keys (%subroutine_hash)) . \n;
 }

 all above works fine and is easy for me to understand.  its below that im
 having difficulty with...

 #seeing the 'pattern' of behavior for $, @, % variable types...
 #i, not knowing any better, assumed the same should also be able to be
 done for  (subroutines)
 #i therefore tried a test to see if i could assign a new subroutine to
 equal a de-referenced subroutine reference
 #i literally copied the same code as used above, but used the  operator
 instead of ($, @, %)
 #this did not give the expected result...  perl reported:
 #hello CODE(0x237dbc)
 #Can't modify non-lvalue subroutine call at D:\_junk\TEST.PL line 6.

 sub subroutine {
print hello @_\n
 }
 sub2(\subroutine);
 sub sub2 {
sub3 = {$_[0]};  #problem is obviously here with this line, seems its
 not being dereference
sub3('world');
 }


It's more like:

use strict;
use warnings;

sub subroutine
{
print hello @_\n;
}

sub2( \subroutine );

sub sub2
{
my $sub3 = shift;

$sub3-('world');
}

Typically you assign from subroutine parameters straight away rather than
use @_ implicitly.

Anyway, if you're on this path a recommended read is
http://hop.perl.plover.com/

A definite cure for the seasonal hangovers . . .

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


Re: Need help with Data Structure: array of hash

2012-11-22 Thread Justin Allegakoen
On 23 November 2012 08:23, Daniel Burgaud burg...@gmail.com wrote:

 Hi All,

 I am having problem with array and Hash data structure. Example is show
 below:

 #CODE 1
 my @list;
 my %this;
 $this{x} = 1;
 $this{y} = 2;
 $this{z} = 3;
 $this{Z} = 4;
 push @list, %this;

 My intention above is to have variable @list as an array of hash, ie:
 $list[0]{x}
 $list[0]{y}
 $list[0]{z}
 $list[0]{Z}
 or
 %{$list[0]}

 The last line does not work according to what I want it to do.
 And instead, @list now contains:
 $list[0] = 'x';
 $list[1] = 1;
 $list[2] = 'y';
 $list[3] = '2';
 .
 .
 .

 I have resorted to:
 @list[ scalar @list ] = %this;
 which I find not so elegant...
 What is the correct way of writing it anyways?

 Secondly, is there a way to not use the has variable %this above?
 ie, something like
 push @list, {x=1,y=2,z=3,Z=4};
 How should I write it correctly?

 And lastly, as I try to pop it out:
 %this = pop @list;
 printf %d %d %d %d\n, $this{x}, $this{y}, $this{z}, $this{Z};
 it wont work. I am getting zeroes/blank on the hashes.
 Why? How should I write it correctly again?


 Thanks
 Dan


Arrays and hashes only hold single values. So in order to do the above you
need to use references. Google perlreftut and then move on to perldsc for a
very good if not whimsical explanation.

Your second point uses something called anonymous hashes, which are fine.

Thirdly - what does pop do? Or more to the point what does it return? A: a
single scalar. Which in your case is a reference. For understanding data
structures always use Data::Dumper which is invaluable:

C:\Perl\Programsperl
push @list, {x=1,y=2,z=3,Z=4};
%this = pop @list;

use Data::Dumper;
print Dumper(\%this);
^D
$VAR1 = {
  'HASH(0x60e170)' = undef
};

So perlreftut it is.

Just in
___
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 Justin Allegakoen
-8---
 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.
-8---


Windows doesn't allow in place editing, so on DOS you're left with an
extra move command.

What I like using for this problem is Tie::File

So long as the input file isnt too large (it trades memory for speed)
this module works a treat.

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


Re: Calling a Perl exe with VB - VB/Windows changing current path

2012-04-12 Thread Justin Allegakoen
On 13 April 2012 08:37, Ashley Hoff ah...@dataaction.com.au wrote:

 **

 Howdy Fellow Win32 Perl users.

 At the moment we are in the process of modding a few file munging app’s
 to make them Cross platform – this means taking the existing Perl from
 our Unix based servers, making them compatible with Win32, compiling using
 PDK and then modding some existing Windows apps (VB 6) to call the
 compiled Perl.  (We are using the existing VB apps, as apparently Ops can’t
 use command line and don’t like change L )

 Everything seems to work fine until you navigate to a file via the
 Windows front end, which then changes the current path to where ever the
 file is located, which the Perl app is picking up on.  This is an issue
 as I want to write a report to a subdirectory of where the app is, not
 where the files are found.

 I have overcome the issue at the moment using Cwd 'abs_path' and
 abs_path($0), then using a substitute to re-construct the path of where
 the Reports are to go.

 What I would like to know, is there a way that Perl can keep in control of
 its current path?  Or is this something that I should get our VB guru’s
 to look at?  (they have asked me to fix it in the Perl…..  Maybe they
 are just being lazy)


Haven't checked, but what does  http://perldoc.perl.org/FindBin.html report
out from the Perl exe in comparison to getcwd?

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


Re: Making directories

2011-10-24 Thread Justin Allegakoen
On 25 October 2011 13:08, Kanhaiya Prasad kpra...@aptaracorp.com wrote:

 Hi

 Here is the very good approach to create directories as well recursive
 directories.

 use File::Copy;
 mkdir c:/abc/def/xyz;

 (It will create all 3 directories and subdirectories as well)

 ---Kanhaiya




You probably mean File::Path along with make_path

http://perldoc.perl.org/File/Path.html

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


Re: GuiTest and Locked Screen

2011-09-20 Thread Justin Allegakoen
On 19 September 2011 10:20, Edwards, Mark (CXO) mark.r.edwa...@hp.comwrote:


 I have a simple Win32::GuiTest example where I find a Notepad window, print
 its handle and title and then send some keys to it.   When I open Notepad
 and the run the script I see...

 4915356: Untitled - Notepad
  Notepad pops up on top of other windows and Testing 123 shows up in
 Notepad as expected.

 Here's the problem.  I need this to work with the screen locked.  When I
 lock the screen and give it time to run, I still get the handle and window
 title but no keys get sent to Notepad.  It seems like it never get set as
 the foreground window since it's not on top after I unlock the screen.

 I tried SetForegroundWindow, SetActiveWindow and SetFocus but none seems to
 make it the current window.

 Any suggestions?


 #
 use warnings;
 use strict;
 use Win32::GuiTest qw(SetFocus SetActiveWindow FindWindowLike
 SetForegroundWindow SendKeys GetWindowText);

 sleep 15;  #Give me time to lock the screen
 my ($winid)=FindWindowLike(0, Notepad);
 print $winid: , GetWindowText($winid), \n;
 #SetForegroundWindow($wind);
 #SetActiveWindow($winid);
 SetFocus($winid);
 sleep 3;
 SendKeys(Testing 123~);



Based on what I googled it seems that when the screen is locked no window
can be set to active - it's a security feature.

I guess for the sake of this post you've dumbed it down, but what exactly
are you trying to do? There may be other ways rather than GuiTest  . . .

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


Re: Perl Module Win32::FileOp 'ShellExecute'

2011-01-03 Thread Justin Allegakoen
On 4 January 2011 13:58, Kanhaiya Prasad kpra...@aptaracorp.com wrote:

 Hi

 Could anyone tell me that how to resolve below mentioned error showing during 
 execution of my script which uses Module Win32::FileOp 'ShellExecute'.

 Use of uninitialized value in subroutine entry at 
 C:/Perl/site/lib/Win32/FileOp.pm line 519.

 ---Kanhaiya


I'm using FileOp v 0.14.1 with 5.8.8 and this:

use strict;
use warnings;
use Win32::FileOp;

ShellExecute( 'open' = $ENV{ProgramFiles}\\Internet Explorer\\iexplore.exe);

__END__


works without any warnings being spewed.

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


Re: TaskScheduler and Win32::OLE

2010-04-03 Thread Justin Allegakoen
On 3 April 2010 22:21, Brzezinski, Paul J paul.brzezin...@hp.com wrote:
 I should have stated that I did first try to download this module – it’s
 missing from the Activestate repository.  So I downloaded the source and
 attempted to compile and it’s _broken_.  It hasn’t been updated in several
 years and according to the CPAN testers site this module fails to compile –
 so it’s not just me.

ppm installs fine for me with 5.10 with the additional repositories:

C:\Perl\Programsppm install  Win32-TaskScheduler
Downloading ActiveState Package Repository packlist...done
Updating ActiveState Package Repository database...done
Downloading bribes packlist...done
Updating bribes database...done
Downloading trouchelle packlist...done
Updating trouchelle database...done
Downloading uwinnipeg packlist...not modified
Downloading Win32-TaskScheduler-2.0.2...done
Unpacking Win32-TaskScheduler-2.0.2...done
Generating HTML for Win32-TaskScheduler-2.0.2...done
Updating files in site area...done
   9 files installed



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


Re: Printing on Win32

2009-12-16 Thread Justin Allegakoen
2009/12/16 Jon Bjornstad j...@logicalpoetry.com

 Esteemed Perl-Win32 people,

 How do I send a plain ASCII text file to the default printer
 from a Perl program?

 Win32::Printer has been discontinued (or so says CPAN)
 and as far as I know it is not available from activestate.com for Perl
 5.10.

 I need to do this from XP, Vista, and beyond.

 Failing a CPAN module is there a way to have my script invoke
 notepad.exe
 and send it the keystrokes to have it do the print for me?

 Thank you very much!
 Jon

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


The documentation on CPAN may be a little misleading.

I can confirm the following works for me:-

C:\Perl\Programsppm search Win32-Printer
Downloading ActiveState Package Repository packlist...not modified
Downloading bribes packlist...not modified
Downloading trouchelle packlist...done
Updating trouchelle database...done
Downloading uwinnipeg packlist...not modified
1: Win32-Printer
   Perl extension for Win32 printing
   Version: 0.9.1
   Repo: bribes

2: Win32-Printer
   Perl extension for Win32 printing
   Version: 0.9.1
   Released: 2008-04-28
   Repo: ActiveState Package Repository

C:\Perl\Programsppm install Win32-Printer
Downloading ActiveState Package Repository packlist...not modified
Downloading Win32-Printer-0.9.1...done
Unpacking Win32-Printer-0.9.1...done
Generating HTML for Win32-Printer-0.9.1...done
Updating files in site area...done
  11 files installed

C:\Perl\Programsperl -MWin32::Printer
my $dc = new Win32::Printer(
papersize   = A4,
dialog  = NOSELECTION,
description = 'Hello, Mars!',
unit= 'mm'
);

 my $font = $dc-Font('Arial Bold', 24);
 $dc-Font($font);
 $dc-Color(0, 0, 255);
 $dc-Write(Hello, Mars!, 10, 10);

 $dc-Brush(128, 0, 0);
 $dc-Pen(4, 0, 0, 128);
 $dc-Ellipse(10, 25, 50, 50);

 $dc-Close();
^D

C:\Perl\Programs



HTH

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


Re: Need help with RE:

2009-11-16 Thread Justin Allegakoen
2009/11/16 Daniel Burgaud burg...@gmail.com

 Hi,

 my $line = Unconfirmed;

 I need an RE that will give me a TRUE value if the string is 2~8 chars
 long.
 otherwise, it gives FALSE;

 I tried

 if ($line =~ /\S{2,8}/) {
return 1;
 } else {
return 0;
 }

 However this does not work.

 I cannot use length($line) because it has to be Regular expression.

 Thanks.

 Dan


You probably want the start and end of line anchors:

use strict;
use warnings;


while (DATA)
{
print _regexp( $_ ) ? TRUE\n : FALSE\n;
}

sub _regexp
{
my $line = shift;

if ( $line =~ /^\S{2,8}$/)
{
return 1;
}
else
{
return 0;
}
}

__DATA__
I
saw
an
elephant
eating
a
rhinoceros

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


Re: Re: Microsoft PowerPoint 9.0 Object Library

2009-09-30 Thread Justin Allegakoen
 
  Hi,
 
  I want to write
  use Win32::OLE::Const 'Microsoft PowerPoint';
  instead of
  use Win32::OLE::Const Microsoft PowerPoint 9.0 Object Library';
 
  ... on one machine the first Notation works correctly on the other machine
  not, I get
  an error Message when Loading the TypeLib. Can anyone tell me what do
  I have to do, so the first on works?
 
  Cheers
  Armin

 That's worked for me in the past. What error message do you get?

 ###
 ... I got the message Win32::OLE(0.1704): GetOleTypeLibObject() Not a 
 Win32::OLE::TypeLib object at C:
 /Perl/site/lib/Win32/OLE/Const.pm line 49.
 ###


 Perhaps a pointless reminder but the version numbers refer to the
 version of MS Office you're running on the machine.

 There's probably a better way to determine the Office version that a
 machine is running but I have used the following successfully:

 sub _DetermineExcelVersion
 {
    for ( 7 .. 15 )
    {
        my $office_path =
          $Registry-{
 HKEY_LOCAL_MACHINE|Software|Microsoft|Office|$_.0|Excel|InstallRoot|Path
          };

        if ( defined $office_path and -e $office_path/EXCEL.exe )
        {
            return $_;
        }
    }

    die Excel not found on '$ENV{COMPUTERNAME}!';
 }
 ###
 this is a nice way but it doesn't help me in my Skript.
 Because I want to run the same skript on different machines.
 So actually on both machines is the Version 9.0 of the Object Library.
 But on the on machine it isn't necessary to specify the Version Number.
 I thought there would be a pointer/overall-class-name in the registry
 which is refering to the actuall/highest version of the installed
 library. And it would be nice if I could have the same installation
 on the other machine, So I would not have to care about which version 
 installed.
 




 HTH,

 Just in


I'd say that something's gone and corrupted the Office installation on
that particular machine - perhaps you can undo some recent of the
recent automatic updates. Or even reinstall Office?

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


Re: Microsoft PowerPoint 9.0 Object Library

2009-09-29 Thread Justin Allegakoen
2009/9/29  armin.no...@aktion-mensch.de:

 Hi,

 I want to write
 use Win32::OLE::Const 'Microsoft PowerPoint';
 instead of
 use Win32::OLE::Const Microsoft PowerPoint 9.0 Object Library';

 ... on one machine the first Notation works correctly on the other machine
 not, I get
 an error Message when Loading the TypeLib. Can anyone tell me what do
 I have to do, so the first on works?

 Cheers
 Armin

That's worked for me in the past. What error message do you get?

Perhaps a pointless reminder but the version numbers refer to the
version of MS Office you're running on the machine.

There's probably a better way to determine the Office version that a
machine is running but I have used the following successfully:

sub _DetermineExcelVersion
{
for ( 7 .. 15 )
{
my $office_path =
  $Registry-{
HKEY_LOCAL_MACHINE|Software|Microsoft|Office|$_.0|Excel|InstallRoot|Path
  };

if ( defined $office_path and -e $office_path/EXCEL.exe )
{
return $_;
}
}

die Excel not found on '$ENV{COMPUTERNAME}!';
}


HTH,

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


Re: TK question

2009-09-20 Thread Justin Allegakoen
2009/9/19 Spencer Chase spen...@spencerserolls.com

 Greetings Perl-Win32-Users,

 I have been trying everything I can think of and nothing works. I have a TK 
 application that uses getopenfile. The problem is that you can select a file 
 in the browser window by either clicking the file and then clicking open or 
 you can double click the file and not have to click open. This is fine but 
 if the browser window happens to be over another widget, the second click 
 seems to select something in that widget. In my case, that widget is s 
 scrolled listbox. I do not want to change the selection accidentally. I have 
 tried everything I can think of to lock the listbox but nothing works. A 
 button to lock the listbox would be fine but I can't figure out how to do it. 
 Disabling a double click in the getopenfile browser would also be fine but 
 can't find a way to do that either. Open to any and all suggestions.



focus? http://www.perlmonks.org/?node_id=192188


HTH

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


RE: :Socket question (client receive - when # of bytes to be received is NOT known in advance)

2009-04-21 Thread Justin Allegakoen
Very quickly - the Perl Cookbook has a number of working examples in Chapter
17

 

Just in

 

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg
Aiken
Sent: Wednesday, 22 April 2009 7:36 AM
To: perl-win32-users@listserv.activestate.com
Subject: IO::Socket question (client receive - when # of bytes to be
received is NOT known in advance)

 

method 1 (below) does work to receive a response from a server.  but
requires I know in advance the number of bytes to receive.

 

I am wondering if something like method 2 may be used in the case of where
one does NOT know in advance how many bytes the server will be sending.  ive
attempted to try this using the code presented in method 2, but this fails
miserably.  was hoping someone in the group had a working alternative method
to share.

 

 

use IO::Socket;

 

$http_get_request =  HTTP_GET;

GET /index.htm HTTP/1.1

Host: google.com

Keep-Alive: timeout=15, max=60

Connection: keep-alive

 

HTTP_GET

 

#setup client socket

$main::socket = new IO::Socket::INET 

( Proto  = tcp, PeerAddr = google.com, PeerPort = 80, );

$main::socket-autoflush(1);

 

#send http1.1 (persistent connection) request for data

$main::socket-send($http_get_request);

 

 

#receive the http1.1 response...

 

#method 1

#this method works

#but requires i know how many bytes to receive

#which I dont always know - so i dont like this method

$main::socket-recv($response, 8192);

print $response;

 

#method 2

#cant something like this be done instead?

#i would prefer to use this pseudo-code method

#as there is no hard-coded number of bytes to receive

#is there a way to achieve this?

#  while ( $main::socket-recv($block, 8192) ) {

# $response .= $block;

#  }

#  print $response;

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


Re: trouble understanding unicode

2009-03-27 Thread Justin Allegakoen
Not at all. In fact I concede. This largely depends on the user's locale.
Just in

2009/3/27 Chris Wagner wagn...@plebeian.com

 Sorry for being contrarian here, but this is wrong.  Unconditionally
 blowing
 away control characters is not the right way to do anything.  Using Perl's
 own encoding disciplines is the right way to do this.  While this tr// may
 work in this case and on other simple files, u just don't know what
 legitimate unicode is in there that u want to keep.  Especially on Windows.


 At 09:22 AM 3/27/2009 +0900, justin.allegak...@maptek.com.au wrote:
 Here's the preferred way of opening files along with the magic tr
 operator:
 
 use strict;
 use warnings;
 use Fatal qw( open );
 
 my $file = 'msinfo.txt';
 
 open my $FILE, '', $file;
 while ( $FILE )
 {
 tr/\x20-\x7f//cd;
 
 print $_\n;
 }
 close $FILE;
 
 
 __END__




 --
 REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
 ...ne cede malis

 0100

 ___
 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


RE: trouble understanding unicode

2009-03-26 Thread Justin Allegakoen
-8-
forgive my naivety here but ive never had to use Unicode before.

I learned many years ago how to open a simple ascii file using perls open.

   open (IN, ‘infile.txt’);

then read records out of the ascii file.

   while ($rec = IN) {
        print $rec;
   }

but today I wanted to write a perl script to evaluate the data from a text
file that gets created when one runs the Microsoft ‘msinfo32.exe’ program.

   msinfo32.exe /report msinfo.txt (this will dump vital system info to
a text file)
   
the problem here is that the ‘msinfo.txt’ file is not written in (single
byte per character, ascii) format.  instead the first two bytes of the file
happen to be (hexFF)(hexFE).  Beyond the first two bytes, each human
readable ascii character is represented with TWO BYTES, (hex-ascii character
value)(hex00)

I assume this is some form of Unicode encoding.  though I do not know the
type.  

if anyone out there knows what kind of encoding this is, it would be
wonderful to know the encoding type Microsoft has used here.

in addition, if anyone knows how to modify the following block so that I can
effectively, read the records of this file, and convert the read record into
‘plain old ascii’ encoding – I would be most appreciative.

essentially, this is what I am aiming to do;

   open (IN, ‘infile.txt’);
   while ($rec = IN) {
      
convert_$rec_from_its_current_encoding?_to_simple_ascii_encoding; 
the magic code would go here
        print $rec;
   }
-8-

Here's the preferred way of opening files along with the magic tr operator:

use strict;
use warnings;
use Fatal qw( open );

my $file = 'msinfo.txt';

open my $FILE, '', $file;
while ( $FILE )
{
tr/\x20-\x7f//cd;

print $_\n;
}
close $FILE;


__END__

There's a suitable one liner on perlmonks:
http://209.85.173.132/search?q=cache:eUhPlTjCV28J:www.perlmonks.org/%3Fnode_
id%3D619792+perl+tr+non+asciicd=2hl=enct=clnkgl=au

But being Windows it won't allow in place editing, hence the need for a
move.

Just in

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


OT: THANKS! (was Win32::FileSecurity problem)

2008-08-20 Thread Justin Allegakoen
Jan,

Thanks.

The Win32 modules are invaluable, FileSecurity and Lanman even more so
(here's anticipating good feedback to Howard's other e-mail).

Cheers

Just in




2008/8/21 Jan Dubois [EMAIL PROTECTED]

  I've fixed this problem for Win32-FileSecurity-1.08:



 http://code.google.com/p/libwin32/source/detail?r=433



 You should see it show up in the beta PPM repository within 2 days or so:



 http://ppm.activestate.com/beta/



 It will of course also be included in any upcoming ActivePerl releases.



 Cheers,

 -Jan



 *From:* [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] *On Behalf Of *Charles
 Manafa
 *Sent:* August 13, 2008 3:32 PM
 *To:* perl-win32-users@listserv.ActiveState.com
 *Subject:* Win32::FileSecurity problem



 Hi,



 Has anyone come across an issue with the Win32::FileSecurity module, that
 ships with Perl 10, that causes it to croak when trying to retrieve DACL for
 a folder for which one of the trustees is an unknown account (i.e account is
 represented by it's SID instead of the account name)?



 This doesn't appear to be an issue with the Win32::FileSecurity module from
 Dave Roth. Unfortunately, Dave Roth's module will only work with Perl 817
 and below.



 The specific code extract I'm using is:



   use Win32::FileSecurity qw(Get EnumerateRights);

   ...

   Get($folder,\%htrustees);

   while (($trustee, $mask) = each %htrustees) {

   ...



 The script croaks when it calls the Get function, and the error can not be
 trapped. I have tried eval to no avail.



 Any ideas, other than going back to 817, will be greatly appreciated.



 Thanks

 Charles





 ___
 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


Re: problem with print

2008-08-11 Thread Justin Allegakoen
2008/8/11 Brian Raven [EMAIL PROTECTED]

 Tobias Hoellrich  wrote:
  Try:
  $|++;
  to unbuffer STDOUT.
 
  Hope this helps - Tobias

 Not quite. pedant_mode That variable activates autoflush, which isn't
 quite the same as unbuffered output, on the currently selected
 filehandle, which may not actually be STDOUT (see 'perldoc perlvar').
 /pedant_mode

 Also, it is usually better to localise the use of such special
 variables. For example:

 print Doing stuff ;
 for (1..20) {
local $| = 1;
select undef, undef, undef, 0.5;
print .;
 }
 print \n;

 Also, consider a more 'sophisticated' alternative to ., that I
 sometimes use.

 print Doing some more stuff  ;
 my $i = 0;
 for (1..20) {
local $| = 1;
select undef, undef, undef, 0.5;
print \b . qw{| / - \\}[$i++ % 4]; } print \b \n;

 HTH

 --
 Brian Raven


 Visit our website at http://www.nyse.com


Or consider an OO approach, without the sneaky 3 undefs:-

package Spinner;

sub new
{
return bless { position = 0, picture = [ qw( | / - \ ) ] }, shift;
}

sub spin
{
my $obj = shift;

$obj-{position} = ( ++$obj-{position} ) % @{ $obj-{picture} };

print \b$obj-{picture}[ $obj-{position} ];
}

DESTROY
{
print \b \n;
}


package main;

use Win32;

local $| = 1;

print Doing even more stuff . . .  ;

my $spinner = new Spinner;

for ( 1 .. 26 )
{
$spinner-spin();

Win32::Sleep(50);
}




[OT]: Changed jobs then Brian?


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


Re: eval { $variable_regex_command }; seems not to work for me...

2008-06-08 Thread Justin Allegakoen
Greg,

im a humble bloke - such salutations are unnecessary - thanks anyway, i help
when i can.

strict and warnings when added dont do anything much to your code per se,
however it is good programming practise, and a mantra for all who advocate
Perl advise on this list and most of the others. you could safely remove
them from your code and still get it to execute accordingly.

that said the effect of predeclaring the variable outside the scope of the
eval braces makes that variable visible outside of the eval. all variables
(built in or not) are localised to their respective braces, turning strict
on enforces this. assigning a variable visible outside of the scope to the
value inside a scope has the benefit of making the data inside the scope
available outside. im sure you knew all of that anyway, i have a notion that
you code with some other language mainly.

Some points:-

   - the nature you describe with perl4 on win95 was a feature albeit a
   flawed one ; )
   - strict and warnings should always be the first 2 lines of your code -
   perl6 enables them by default - you wont have much choice
   - pre and post match regexp operators are expensive - dont use them if
   you dont have to
   - Tobias' use of qr (compiling the regexp) is the preferred method

cheers

Just in


2008/6/7 Greg Aiken [EMAIL PROTECTED]:

  sir, you are a god!  thanks so very much here for your insights.



 I would understand if you don't have much more time here for me.

 but if you might, it would help me to understand perl better if you could
 explain exactly why the code would not run as I originally coded it.



 why does including strict pragma and predeclaring the variables help in
 this case?


  --

 *From:* Justin Allegakoen [mailto:[EMAIL PROTECTED]
 *Sent:* Thursday, June 05, 2008 8:05 PM
 *To:* [EMAIL PROTECTED]
 *Cc:* perl-win32-users@listserv.activestate.com
 *Subject:* Re: eval { $variable_regex_command }; seems not to work for
 me...





 --8

 i would like to do a pattern match where the thing to be matched is a
 $VARIABLE, not a previously known value that could otherwise be simply
 'hard-coded' into the regex (as most regex users do).  I need to do
 something more dynamic than that…

 so i assign the regex program line to a scalar, then eval the scalar.

 on the surface, this should work. (and i can swear that in the very old
 days with perl 4.036 on win95, it actually did).  but now that i run
 activeperl 5.8.8 build 822 on xp this ability seems not to work for me.  of
 course, this could also be my mis understanding, or my mistake.  perhaps
 those with more expertise than myself can take a quick look at my code.

 here is simple code demonstrating what i am attempting to do:



 $word  = 'word2';
 $paragraph = 'word1 word2 word3';
 $block = \x24paragraph =~ \x2F$word\x2Fi;;

 print block to eval = $block\n;

 eval { $block }; warn $@ if $@;

 if ($') {
 print what follows the match = $'\n;
 } else {
 print why wasnt '$word' found in '$paragraph'\n;
 }

 running it displays clearly that 'word2' is not found within the string
 containing 'word1 word2 word3'.

 i dont understand why this simple example does not work.

 your help would be GREATLY appreciated.

 --8



 use strict;
 use warnings;



 my $post_match = 0;
 my $word  = 'word2';
 my $paragraph = 'word1 word2 word3';
 my $block = \x24paragraph =~ \x2F$word\x2Fi;;



 print block to eval = $block\n;



 eval { $paragraph =~ /$word/i; $post_match = $' };
 warn $@ if $@;



 if ($post_match)
 {
 print what follows the match = $post_match\n;
 }
 else
 {
 print why wasnt '$word' found in '$paragraph'\n;
 }



 __END__



 HTH,

 Just in






-- 
Justin Allegakoen
Vulcan Technical Services
Level 2, 190 Aberdeen St.
Northbridge, WA 6003
(08) 6211 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: hi, merge excel files into one

2008-04-06 Thread Justin Allegakoen

Carlos Diaz wrote:
 Help me please ! 
 Hello, I have some Excel files, I want to pass them to only one file, using
 win32::ole and perl . ( not cell by cell , loss the format).
 Thanks  a lot
   

I'm sure you want this to work on multiple files and sheets but the 
following will get you going:-

use strict;
use warnings;
use Win32::OLE;

my ($file1, $file2) = ('C:\Temp\file1.xls', 'C:\Temp\file2.xls');

my $excel = Win32::OLE-GetActiveObject('Excel.Application') || 
Win32::OLE-new('Excel.Application', 'Quit');
$excel-{Visible} = 1;

my $book1 = $excel-Workbooks-Open($file1);
my $sheet1 = $book1-Worksheets(1);

my $book2 = $excel-Workbooks-Open($file2);
my $sheet2 = $book2-Worksheets(2);

$sheet1-Copy({Before = $sheet2});

__END__



Note that $file2 needs to exists first - however creating a blank Excel 
file is trivial. $book-Worksheets can have its argument as a string to 
an actual sheet name rather than the default Sheet1

Think you could swing some Coronas my way? That's a great beer man.

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


Re: My first 2 Scripting Games commentaries are online now

2008-02-20 Thread Justin Allegakoen
--8---

Foo JH wrote:
 One thing I like about Perl is that you don't have to use the 
 forward-slash '\' just because you're writing for the Windows platform.

 --8---

\ is a backslash

/ is a forward slash

With reference to the above are you talking about the use of slashes as 
directory separators in path names?

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


RE: SFTP PPM package

2007-10-30 Thread Justin Allegakoen
-8---
Hello!  When I try to download the Net::SFTP it downloads a package called 
Net::SFTP-Foreign(see Below).  How do I go about getting the Net::SFTP using 
ppm?  
-8--- 

Its been a while since I tried so things may have changed - you'd need to add 
soulcage to your repository, and get a fresh install from there.

If you try to manually install some of the dependent modules (you may get 
problems with Math::Pari) without using the ppm package it won't work.

If you do get it to install there are some changes that you need to make -  sin 
the earch for Net::SFTP on the Activestate mailing archives.

YMMV but I couldn't get Net::SFTP to work and in the end settled for system 
calls to PuTTY

HTH,
Just in

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


RE: WMI Problem

2007-10-30 Thread Justin Allegakoen

---8-
You know, I seem to remember that it wasn't strict safe (from a long
time ago).  Since you think it is, please accept my apologies (Because
you are the expert when it comes to Win32-OLE, and I just use it).
---8-

You probably meant that Win32::OLE is not _thread_ safe

Just in

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


RE: Dynamically referencing a package variable

2007-08-23 Thread Justin Allegakoen
---8
I'd like to figure out how to access package variables at runtime. In 
other words, I may have a variable $class that contains the classname, 
and I want to set a value to the package reference by this variable. 
It'll be something like:

$class::Message = It works;
---8
Sounds like youre on the OOP path but don’t have an in depth understanding of 
it, at least not in a Perl sense.


---8
The problem now is that the package name is not known until runtime. I 
may either be writing to $Package1::Message or $Package2::Message.

Can anyone enlighten me on the proper syntax to use to do this?
---8
Run time binding and polymorphism are things that you should be evaluating.


---8
To complicate matters, what happens if I also want to assign values of 
variables which are known only at runtime? For example (pseudocode):

$class::$variable = It works;
---8
Looks as if youre unwittingly trying to use symbolic references. Mark Jason 
Dominus explains the donts here http://perl.plover.com/varvarname.html


As for the rest well perlboot and perltoot will point you in the right 
direction.

Just in

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


RE: Dynamically referencing a package variable

2007-08-23 Thread Justin Allegakoen
 Justin Allegakoen wrote:
  ---8
  I'd like to figure out how to access package variables at runtime. In
  other words, I may have a variable $class that contains the classname,
  and I want to set a value to the package reference by this variable.
  It'll be something like:
 
  $class::Message = It works;
  ---8
  Sounds like youre on the OOP path but don’t have an in depth
 understanding of it, at least not in a Perl sense.
 
 
  ---8
  The problem now is that the package name is not known until runtime. I
  may either be writing to $Package1::Message or $Package2::Message.
 
  Can anyone enlighten me on the proper syntax to use to do this?
  ---8
  Run time binding and polymorphism are things that you should be
 evaluating.
 
 
  ---8
  To complicate matters, what happens if I also want to assign values of
  variables which are known only at runtime? For example (pseudocode):
 
  $class::$variable = It works;
  ---8
  Looks as if youre unwittingly trying to use symbolic references. Mark
 Jason Dominus explains the donts here
 http://perl.plover.com/varvarname.html
 
 
  As for the rest well perlboot and perltoot will point you in the right
 direction.
 
  Just in
 
  ___
  Perl-Win32-Users mailing list
  Perl-Win32-Users@listserv.ActiveState.com
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 


 -Original Message-
 From: Foo JH [mailto:[EMAIL PROTECTED]
 Sent: Friday, 24 August 2007 10:40 AM
 To: Justin Allegakoen
 Cc: 'perl-win32-users@listserv.ActiveState.com'
 Subject: Re: Dynamically referencing a package variable
 
 Thanks Justin,
 
 I'm quite familiar with OOP. It's class variables that I'm interested in
 setting, not instance variables. In Perl, this is implemented as package
 variables like $MyPackage::MyVariable.
 
 I could've done this: $__PACKAGE__::MyVariable, but as I said, the
 package name is not determined at run time, so I need to use a variable
 in place of __PACKAGE__
 
 Hope you have some ideas on this. Thanks.


The way I read your post had the encapsulation bells ringing.

Again, symbolic references offer a possible solution:-

code

package Root;
$me = 'How much?';

package main;
use strict;
use warnings;

my $package = 'Root';
my $var_name = 'me';

# And ducking the rotten tomatoes he continues with
no strict 'refs';   
print 'I was quibbed with ' . ${${package}::$var_name} . qq{\n};

${${package}::$var_name} = 'For you? Ten dollars';

print 'So I replied ' . ${${package}::$var_name} . '';

/code

Typeglobs and aliasing may be more revered though.

Just in

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


RE: Truncating decimal number

2007-06-19 Thread Justin Allegakoen
8--
I'm trying to truncate a number, 10.25233006477356, to 6 decimal points. E.g. 
10.252330. 
I don't need to round the number, I just want it to drop everything after the 
6th decimal point. This should be easy, but I'm drawing a blank.
8--

In the spirit of TMTOWTDI, and the with the subtle elegance of one liners try:

use strict;
use warnings;

my $pi = 22 / 7;
print pi is about $pi\n;

$pi =~ s/^(\d+)\.(\d+)$/$1. . substr($2, 0, 6)/e;
print now pi is about $pi\n;
__END__




Just in

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