RE: lame question \\\\.\\pipe\\pipename vs '\\.\pipe\pipename'
There's a pretty good explanation of it here: http://en.wikibooks.org/wiki/Perl_Programming/Strings Specifically this part: * The sequence \' yields the character ' in the actual string. (This is the exception we already discussed above). * The sequence \\ yields the character \ in the actual string. In other words, two backslashes right next to each other actually yield only one backslash. * A backslash, by itself, cannot be placed at the end of a the single-quoted string. This cannot happen because Perl will think that you are using the \ to escape the closing '. The following examples exemplify the various exceptions, and use them properly: 'I don\'t think so.'; # Note the ' inside is escaped with \ 'Need a \\ (backslash) or \?'; # The \\ gives us \, as does \ 'You can do this: \\'; # A single backslash at the end 'Three \\\'s: \';# There are three \ chars between In the last example, note that the resulting string is Three \'s: \\\. If you can follow that example, you have definitely mastered how single-quoted strings work! Instead of unreadable backslash escapes, Perl offers other wayshttp://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators of quoting strings. The first example above could be written as: q{I don't think so};# No \ needed to escape the ' From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg Aiken Sent: Wednesday, October 20, 2010 10:10 AM To: perl-win32-users@listserv.activestate.com Subject: lame question .\\pipe\\pipename vs '\\.\pipe\pipename' forgive my ignorance here, but I thought single quoted, or apostrophized [however you call this character] (') text strings were supposed to be interpreted by perl in an unaltered manner. sample code, indicating how to reference a named pipe in the Win32::Pipe module, shows something like this... .\\pipe\\pipenamefile:///\\pipe\pipename (note enclosed in quotes) I thought the excessive quantities of backslashes seemed silly, so I instead used single quotes and tried... '\\.\pipe\pipename' (note enclosed in apostrophies) only to find that my client pipe program did not work. I then did a simple test print program; print '\\.\pipe\pipename'; and I was surprised to see what actually printed to the screen was instead; \.\pipe\pipename (note the first \ is not shown in output!) this explained why my client pipe program was working... but it left me scratching my head to ask, why is the backslash character being interpreted as a special perl operator when it is found within apostrophies? I thought that only happened when the backslash is found within quotes, such as (print \x43), which should print a capital C thanks in advance to anyone who can explain this to me. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Determining if a file is open
Excuse me for being in a rush and not having time to develop a sample, but I think what you want to do can be determined using WMI, in the CIM_Datafile class, there is a property named InUseCount: http://msdn.microsoft.com/en-us/library/aa387236(VS.85).aspx http://www.slideshare.net/ddn123456/win32-perl-wmi (Haven't checked that one out, but it says it is an introduction to using Perl and WMI) http://forums.cacti.net/about5816.html (Contains an example of using WMI in Perl). Almost all properties of windows objects can be found in some WMI class. You can also connect to remote machines and run WQL queries against those machines, so it is not just for local machines. If needed, I'll see if I can provide an example when I get off work today. Hopefully, this gets you going in the right direction. From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Jason Lowder Sent: Thursday, February 18, 2010 7:20 AM To: perl-win32-users@listserv.ActiveState.com Subject: Re: Determining if a file is open And yes, this is under Windows. (Vista) Jason On 2/18/2010 8:38 AM, Jason Lowder wrote: Hello, Is there anyway to determine if a file is currently open by another process? I want to look at a file that is being generated by another program (sometimes a very large file) and determine when it is finally closed. I see the file attributes for things like size, owner, type etc. but nothing to really determine it's state. Thanks, Jason ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.commailto:Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs No virus found in this incoming message. Checked by AVG - www.avg.comhttp://www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2693 - Release Date: 02/17/10 01:35:00 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Advice requested, porting unix perl app to windows
Just piggybacking on this a little bit with one more option, if you don't mind using a windows command, there is a utility in Windows 2003 and higher, and in Windows Vista and higher, and downloadable for lower versions named 'Robocopy'. It's very good for unreliable connections or high latency connections because it will allow restartable mode, automatic retries, and multi-threaded copies. If should be pretty easy to compose the string for the system call to robocopy. -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Mark Leighton Sent: Wednesday, June 03, 2009 9:06 AM To: perl-win32-users@listserv.ActiveState.com Subject: Re: Advice requested, porting unix perl app to windows If running on Windows, the best practice for transferring files would simply be through the native SMB filesystem. The script should run under a user context (domain is easiest) that has inherent rights to copy files to the second machine (because maintaining username and password credentials in the script would be a security vulnerability). If these are the case, then transferring the file is as simple as: use File::Copy; copy( 'file.dat', '//SERVER2/SHARENAME/file.dat' ); Otherwise, you can use: system( 'net.exe use ...' ); or: Win32::NetResource::AddConnection() to map a drive first. Cheers, Mark --- Mark Leighton CLIC LAN Supervisor, Information Commons, University of Toronto E-mail: mark{DOT}leighton{AT}utoronto.ca Original Message Subject: Advice requested, porting unix perl app to windows From: Dennis Daupert ddaup...@csc.com To: perl-win32-users@listserv.ActiveState.com Date: Wednesday, June 03, 2009 10:42:03 AM Hello group, Most of my perl programming is on unix; my windows knowledge is limited. So, please be gentle ;-) I have an app that produces data files on one unix machine, then uses scp to move those over to another machine for further processing. The system architecture dictates the two-machine arrangement. Management has asked me to port that app to a windows-based system with the same two-machine architecture. I don't know of a free (as in both beer and non-beer) windows equivalent to scp OR sftp. I'm seeking advice on a solid, dependable, and secure way to move files between machines without incurring additional expense. I've wondered whether there may be Perl modules that will map drives and copy files across that would do so on an automated schedule, and I've been searching CPAN. But before heading too far down that path, I thought I'd ask the list for advice. best, /dennis Dennis Daupert, PhD Senior Systems Development Professional -- CSC Account CSC GOS | o: 1.317.298.9499 | ddaup...@csc.com | www.csc.com This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. ___ 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: New to Perl and stuck
Just in the simplest and most general of terms, what it sounds like you want to do is an opendir on the folder, then use readdir to get each of the file names. Store each filename in a variable, and use it in the open command to open the file. You might want to put the code that actually extracts the lines you want into a separate subroutine, and just call that subroutine for each file you open (or for each filename if you open the file in the subroutine). After you process your file, then use the close to close the file so you can move on to the next one and process it. It sounded from your description like you were looking for what opendir does. To get an explanation, do this: perldoc -f opendir See if that gets you started. Ask back if you need more specifics. Steve Howard -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Bryan Keller Sent: Tuesday, March 03, 2009 9:45 AM To: perl-win32-users@listserv.ActiveState.com Subject: New to Perl and stuck Hi all, The following gets me the lines I need for any single txt file. #!usr/bin/perl use warnings; use strict; my @output = ; print $ARGV; print (\nESTIMATION\n); print @output[18,21..24,28..31,206..208]; print \nPOPULATION\n; print @output[220,223..226,229..233,424..426]; These txt files are in groups of 25 (in folders). My goal is to automate this so that after specifying a folder, Perl will pull the specified lines from each of the 25 txt files in that folder and write them to a single output file. I would greatly appreciate any help or suggestions! Bryan - Bryan Keller, Doctoral Student/Project Assistant Educational Psychology - Quantitative Methods The University of Wisconsin - Madison ___ 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: Commaring Two dates or month
Just a suggestion Why not use the Date::Calc package and use the Delta_Days function? I used to use that all the time for things like what I understand you to want to do. There are a lot of great date functions built into that package that save a lot of time in development. Steve From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Perl Perl Sent: Tuesday, February 24, 2009 10:08 AM To: perl-win32-users@listserv.activestate.com Subject: Commaring Two dates or month Dear All, I have to compare two dates. And populate the result based on that. First date I have received from previous script, which in this form 5-Feb-09. And I have to compare this date with current date, locatime() . With the localtime() I will get the current Day (24),Month (2) year (2009 ) I will split the old date as below and get the result as below. $Old_Day = 5; $Old_Month = Feb. And then I convert Feb to 2 ( Month number ) by using scalar veriable. ( The thing repeated for all months ). if( $Old_Month eq Feb) { $Old_Month = 2; } elsif($Old_Month eq Mar ) { $Old_Month = 3; } . elsif($Old_Month eq Dec ) { $Old_Month = 13; } And in current month, which I got from localtime function as, $Current_Month , which will be 2 ( not sure this is a string or a numric ). so while substracting or comparing as below, if (($current_Month - $Old_Month 10) ) { print Some operation ; } Here if I compare with current month with the old_month (Feb) then the result is fine. but if the old_month is something like Jan or Jun something, then I am not getting the properl result. Please let me know how can I compare and Substract two months or two dates in above scenario. Thanks a lot for your kind help. Regards, Mujju ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Reading hash arrays in the order it was written
Not inherent in the hash. You could store the ordinal value as one of the values in a hash of arrays, and then sort on that when you retrieve the values, but there is really no way to guarantee the order in which it will be retrieved from the hash is the same order in which it was inserted. To preserve your order, you need to use an array. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fish, David Sent: Wednesday, November 19, 2008 7:58 AM To: [EMAIL PROTECTED]; perl-win32-users@listserv.ActiveState.com; [EMAIL PROTECTED] Subject: Reading hash arrays in the order it was written Hello! The problem I am having is I am pulling data from a table in a certain order and loading it into the hash array but when I read the hash array it comes out in a different order than it is written. What I have done as a work around, is the read the data from a file that has it in the correct order. Is there away to build the hash so that it reads in the order it was created? Key creation and hash build: select statement ordering by certain columns .. $key = sprintf(%04d%07d%07d,$chk_num,$trans_seq,$dtl_seq); $midtlinfo{$key} = sprintf(%d|%d|%s|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%0.2f|%0. 2f|%0.2f, $se_chk_mi_seq, $obj_num, $business_date, $chk_num, $trans_seq, ); Reading of the hash: foreach $mk (keys %midtlinfo) @mrec = split(/\|/,$midtlinfo{$mk}); } David Fish Senior Systems Analyst Property Systems Services Work (301) 380-3331 Fax (301) 644-7521 BlackBerry (301) 646-8985 [EMAIL PROTECTED] ___ 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: WIN32::OLE help
I'll type this directly in so I might make a typo. You should be able to set the state in the application object: $Excel-{WindowState} = -4140; To set back to normal mode: $Excel-{WindowState} = -4143; The way to find this is to record a macro in Excel, and do what you want to see. Then view the macros and see what was done. In this case, the macro uses constants xlMinimized, and xlNormal. You can use the object browser to see the values of those constants. They're probably in the constants you have imported as well, so it would probably be better to use them there rather than the literal values. See if this helps. Steve From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Neson Maxmelbin (RBEI/EMT4) Sent: Thursday, August 14, 2008 4:30 AM To: perl-win32-users@listserv.ActiveState.com Subject: WIN32::OLE help Hello , I am using WIn32::OLE to Read contents of an Excel sheet. There is no issues on reading, but the problem is that Excel file opens on the screen, during the time the script processes the file. I don't need this. One solution was to make it not visible ($Excel-{'Visible'} = 0;). But this had some other problems. In some cases, when this Excel sheet was open for viewing, its contents were hidden ! , when we move the mouse over the cells, then we see it .. might be a Excel Bug. Due this we cannot make the Excel sheet invisible during the runnign of the script. What I need now is to minimise the sheet once it is opened. How do we do it ? My code extract - use Win32::OLE::Const 'Microsoft Excel'; $Excel = Win32::OLE-GetActiveObject('Excel.Application')|| Win32::OLE-new('Excel.Application', 'Quit'); $Excel-{'Visible'} = 1; $xlFile = 'C:\HWEConfig.xls'; eval { $Book = $Excel-Workbooks-Open($xlFile); }; ... then the reading Thanks and Regards Maxmelbin Neson ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: trouble accessing fully qualified $main::variable contents
Use our instead of my our $var = value; Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Aiken Sent: Monday, July 07, 2008 5:01 PM To: perl-win32-users@listserv.ActiveState.com Subject: trouble accessing fully qualified $main::variable contents can anyone please explain why when I am in the subroutine, and I attempt to print a variable that's been declared and assigned a value in the main package - why I am unable to print the value of the main package's variable (despite that I am using the fully qualified variable name)? is this my fault or a bug? it seems to work in some instances, but not work in others... ## use strict; use warnings; my $var = value; subroutine; sub subroutine { print value of main package's main::var is $main::var\n; } when above program is run, std out shows C:\perlsrctest.pl Name main::var used only once: possible typo at C:\perlsrc\TEST.PL line 9. Use of uninitialized value in concatenation (.) or string at c:\perlsrc\TEST.PL line 9. value of main package's main::var is ___ 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: reading the Network Interface Card(NIC) name
You can access WMI via Perl pretty much the same way you would any other automation object. I haven't used it to enumerate the NICs the way you want to do, but a quick and dirty example of using WMI in Perl is one I wrote to enumerate drives. You can probably use the windows scripting help to find the objects for the NICs. An example of using Perl with WMI: #!perl use Win32; use Win32::OLE qw( in ); *error = *Win32::OLE::LastError; my $wmi = Win32::OLE-GetObject(Winmgmts:); die error() if error(); our $drives = $wmi-ExecQuery(Select * from Win32_LogicalDisk); die error() if error(); foreach my $drive (in( $drives )) { print drive name: $drive-{Name}\n; print filesystem: $drive-{FileSystem}\n; print Drive size: $drive-{Size}\n; print Drive freespace: $drive-{FreeSpace}\n; print Drive type: $drive-{DriveType}\n; print \n\n; } From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ankit Mehrotra Sent: Monday, August 27, 2007 2:48 AM To: Foo JH Cc: perl-win32-users@listserv.ActiveState.com; [EMAIL PROTECTED] Subject: Re: reading the Network Interface Card(NIC) name I am not very well versed in wmi. Is there some other means of doing it preferably using perl !! Ankit Foo JH [EMAIL PROTECTED] 08/27/2007 12:37 PM To Ankit Mehrotra [EMAIL PROTECTED] cc perl-win32-users@listserv.ActiveState.com, [EMAIL PROTECTED] Subject Re: reading the Network Interface Card(NIC) name If you're doing this via Windows, you can go via WMI. Google: wmi win32_networkadapter Ankit Mehrotra wrote: Hi all, I want to read the names of the NIC's of a blade server. Is there any ready made package through which I can read them ? Thanks Ankit =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ForwardSourceID:NT00013B6E =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: a simple program
I'm having a little trouble understanding the question. Are you expecting Perl to compile into an executable program like C would do? If so, Perl doesn't do that. Perl is an interpreted language, and compiles when called, then executes. The script is loaded by the interpreter, and must have the interpreter to run. It also sounds like you are looking for a Perl debugger. There are many available, but what is available changes regularly. Komodo is an IDE and works well from what I understand (but it has been a long time since I have used it). If you're looking for a freeware IDE with a debugger, you might try searching using your favorite search engine, or maybe someone has a suggestion on what is currently available in the freeware world. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of prapulla rani Sent: Wednesday, August 08, 2007 1:21 AM To: perl-win32-users@listserv.ActiveState.com Subject: a simple program hi am learning c language . in the same time i am learning perl lanuage so i want one perl program to compile with debugging in cygwin . including each step is running debugging commands also i want. please send me reply as early as possible ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Perl Ole book?
Can anyone give recommend a site, or a book that is a good single source for Perl programming with OLE? In particular with Excel? I have no problems with the very basics like creating spreadsheets, inserting or extracting data, sending e-mails etc. but I do not seem to be able to find a source where I can learn much more in-depth than those most basic items. I've had some very limited success with translating VB scripts to Perl, but I've never been a VB programmer, and would rather find a source for Perl if such a source exists. Any help on such a source? Thanks, Steve H.
RE: ppm install tk Didn't work!
I had the problem a while back where PPM suddenly stopped working at home, but still worked fine from work. I went through most of the steps you did, and got it back working again. I wrote to Activestate.com about this and the explanation was that the configuration in the XML file that came with the version I was using at home pointed to a repository that no longer existed. He gave me the fix to edit the XML file, however, i was already past this point at this time. The explanation for the rest of your problems is that the newer version of PPM which I (and apparently you) installed while fixing this is dependent on the newer version of the soap-lite module which you discovered and installed. But yes, it has been a problem to others. Steve H. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Kuhnibert Sent: Wednesday, July 04, 2001 4:09 AM To: [EMAIL PROTECTED] Subject: Re: ppm install tk Didn't work! hi, had the same problem with PPM! trying to be smart i upgraded the SOAP module from CPAN, and the error message happily changed to .. unexpected call to get_serializer with undef at D:/Perl/site/lib/SOAP/TypeMapp er.pm line 38. which was also not really satisfying, so i fetched the whole new PPM module from CPAN but now the 'fresh' ppm came upd with a SOAP-Lite not found message (the elder version didn't appear to require this). eventually, after installing SOAP-Lite as well, ppm is back to life now (but i'm still wondering what might have caused this conflict all of a sudden) HTH till - Original Message - Hi, I tried to intall tk using ppm. I get this message not well-formed at line 1, column 17, byte 17 at E:/Perl/site/lib/SOAP/Parser.pm line 73 what the hell does this mean. Yes, im connected to the internet. Also I did search tk and it didn't work the first few times but it did after a while and it seemed to find all kinds of tk related stuff, but it was scrolling too fast to read. now that doesnt work? what's going on? Thanx ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
RE: what editor do you use?
A nice, light IDE that I use at work is Perl Builder available from www.solutionsoft.comIt's not free, but it has everything I need, and it's performance is much better than the alternatives I've tried. Steve Howard -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Mark Bergeron Sent: Tuesday, June 26, 2001 6:00 PM To: Debbie Thomson; [EMAIL PROTECTED] Subject: Re: what editor do you use? If you want it for free... Note Tab Light If you want to pay... Multi-Edit 9.0 If your a developer... Komodo (from Active State free/pay) a bit slow though )-8 -Original Message- From: Debbie Thomson[EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Tue Jun 26 09:17:21 PDT 2001 Subject: what editor do you use? All- It occurs to me now that I seem to be spending much of my day writing Perl that I need a better programming environment than Notepad. What do you use? Thanks, Deb /~_. _ | _ _ _ _ \_/|(_||| | |(_)| | _| ___ GO.com Mail Get Your Free, Private E-mail at http://mail.go.com ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users