Re: pound sign trouble
On 08/07/2003 02:20:33 perl-win32-users-admin wrote: >Allegakoen, Justin Devanandan wrote: >> Peter, >> >> I was playing around with this earlier. Heres what I get:- >> >> Microsoft Windows XP [Version 5.1.2600] >> (C) Copyright 1985-2001 Microsoft Corp. >> >> C:\Perl\Programs>perl -e "print ord('£');" >> 163 >> C:\Perl\Programs>perl -e "print chr(163);" >> ú [snip] > >I know that I have to type Alt->156 (numeric keypad) to get a £ >into this message. I also know to do the same in my Vim editor, >I have to type ^V163. I also know that if I cut and paste from >Vim to my email it works fine too. I guess it's just magic. :) > >I would think that the 163 would be correct and the 156 scancode >is a Windoze keyboard/console thingy. No, it's a different codepage thingy. The command prompt window uses CP437 (?) or CP85x whereas Windows would use something like CP125x (sort of ISO Latin). >If you redirect that output >to a file and then look at the file with an editor (Vim in my case), This depends on the editor, DOS-based editors may interpret 156 as the pound sign whereas Windows-based ones (e.g. Notepad) will display 163 as the pound sign. perl -wle "print chr(156),chr(163)" > pound.txt If you "type pound.txt" you will see pound sign followed by accented u. Opening it with Notepad you'll see an o-e ligature (or a black box) and a pound sign. -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Embedding Perl (Mail::SpamAssassin) in a C program
On 07/07/2003 16:09:21 perl-win32-users-admin wrote: [snip] > >I am really hoping for the "fastest" solution and not necessarily the >easiest. >I'm wondering if I can do something like: > >eval_pv(use Mail::SpamAssassin); >eval_pv(my $spamobj = Mail::SpamAssassin->new()); >eval_pv(my $status = $spamobj->check_message_text($input)); >eval_pv(my $output = sprintf .. ); > >within C and then pass the "output" string back from Perl like you suggest? I think that (lots of individual eval_pv) won't work because e.g. $spamobj will not survive the end of second eval_pv. However, one big eval_pv might work : /* begin C code */ eval_pv("use Mail::SpamAssassin;" "my $spamobj = Mail::SpamAssassin->new();" "my $status = $spamobj->check_message_text($input);" "my $output = sprintf( ... );" ); /* end C code */ (This is really one line as far as Perl is concerned). Fetching the return value from the eval_pv above is well described in perlembed. I can't see how you can pass data to a chunk of code like that. > >I'm hoping to avoid calling an external *.pl file from C, for speed Try defining a subroutine with eval_pv, then calling it with call_pv: /* begin C code */ eval_pv("use Mail::SpamAssassin;" "sub check_for_spam{ "my $spamobj = Mail::SpamAssassin->new();" "my $status = $spamobj->check_message_text($input);" "my $output = sprintf( ... );" "}" ); // lots of code here from perlembed to manipulate the stack call_pv("check_for_spam", G_SCALAR) // lots of code here from perlembed to manipulate the stack /* end C code */ -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: question
On 16/06/2003 20:54:52 Michael Higgins wrote: >FARRINGTON, RYAN wrote: >> I think I bugged Bill enough so I'll ask the list... >> >> This was provided by Bill: >> >> my @sortlist = map { $_->[0] } >>sort { mysort ($field, $type, $case, $dir) } >>map { [ $_, split /\|/ ] } @lista; >> >> >> am I reading this correct: >> map returns an array for each value in @lista >> we then sort each value in this anonumous array according to our >> specifications >> what does map{$_->[0] } do? > >Ryan -- > >Basically, reading right to left, you're putting the value of $_ and the >values of splitting $_ from @lista into an anonymous array, sorting via >'mysort', then de-referencing the first value (the original value of the >array slice) from that anonymous array you created (as you are still >mapping against $_ from @lista. > This technique is known as the "Schwartzian transform". See "How do I sort an array by (anything)" in perldoc -q sort Basically it caches the result of split via the "bottom" map(), sorts on the cached values, then it throws away the cached values with the "top" map(). The simplistic approach would be to split inside the sort() as needed. Because each element needs to be compared more than once, this would result in repeated split() calls for the same element. Instead, the bottom map ensures that split() is called only once for each element and the result is ready to be used by sort(). -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: API call crashes if I pass parameters.
On 16/06/2003 22:57:22 perl-win32-users-admin wrote: >I am having trouble with API, similar to these posts: >http://aspn.activestate.com/ASPN/Mail/Message/732561 >http://aspn.activestate.com/ASPN/Mail/Message/perl-win32-users/753232 >Like those posts, I had API working. When I tried the API scrip many months >later (during which time I had upgraded to Perl 5.6.1) I found that it did >not work. After many tests I discovered that Perl would crash if: >1. _I_ wrote the dll, and >2. The dll function expected parameters. >I found that I could call _Microsoft_ dlls with parameters, but my own dlls >crashed Perl (even though they worked correctly when called from 'C'). In [snip] > >The crash (Unhandled exception) happens after the dll successfully completes >its GiveString function. (I don't have the Perl source so I couldn't debug >into Perl.) > >The Perl code is: >chdir 'D:\DLL\Debug'; >$function = new Win32::API('dllTest1', 'GiveString', [P], V); >if (! defined $function) { >die "Could not import GiveString\n"; >} else { >$function->Call("Test string"); >} > >The C code is: >extern "C" __declspec(dllexport) >void GiveString(char* string) >{ ; } // (Guts removed for simplification) > >Any help would be greatly appreciated. > I think the problem is that GiveString is declared "C". Most Windows API functions use the __stdcall convention; I suspect Win32::API to follow that calling convention by default at least. With the "C" calling convention, the caller cleans up the stack after the callee returns. With the __stdcall convention it is the callee's responsibility to remove the passed-in parameters (in that respect __stdcall is like the Pascal calling convention). Now you can imagine that if the calling conventions don't match, the stack is going to be mangled and soon afterwards a bogus value will be used as a subroutine return address. (If there are no parameters then it works because there is no mismatch). Try making all your functions __stdcall instead of "C". HTH, -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: How to convert OEM to ANSI?
On 04/06/2003 10:03:09 perl-win32-users-admin wrote: >Is there a function simply to convert an OEM string or file to an ANSI >string or file? > >I'm kinda new to Perl and one of my first programs reads rows from an >ASCII file that is OEM encoded and in order to load it via ADODB into my >MS-SQL database I need to convert the data into ANSI. > >Been searching ASPN and CPAN but have found nothing although I'm sure >there must exist something. Please can anybody give me a hint? - Thank you >in advance! > I think you need Encode (included by default in ActivePerl 5.8.0) #!perl -w use strict; use Encode 'from_to'; my $oem = ''; my $ansi; from_to( $ansi = $oem, 'cp437', 'cp1252' ); # fromto __END__ from_to converts the string in place, so it must be a variable, not a literal string. The assignment preserves the value of $oem (from_to operates on $ansi). CP437 is the original IBM PC codepage (US ascii) CP1252 is what Windows uses instead of ISO Latin1 (iso-8859-1) You could use CP850 as the source for W. Europe accented characters For Central Europe, CP852 -> CP1250 -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Development environments ...
On 03/04/2003 00:09:27 Daniel Gross wrote: >Thank you for the incoming IDE suggestions ... > >Its interesting to see that some Perl developers seem not to "require" >an interactive debugging environment, but are happy with power-text >editors, and (I would imagine) with the command line debugger. My >assumption was that an IDE with integrated debugging facilities would be >a big help during the code writing & testing cycles ... > > IMO, integrated debuggers are overrated (although "Edit and continue" is neat). Any decent OS capable of running more than one program allows a separate command window to launch/debug your script. If you don't like the commandline debugger, there's Devel::ptkdb. But Perl's built-in debugger is usable even for GUI-dependent types like myself :-) Is there a console-based debugger front-end ? (perhaps in curses or suchlike) A development environment MUST have: 1) Some kind of make integration, i.e. it has to capture the output of the build and offer the ability to open the editor at the line of the error. In case of Perl there's no "build" as such, but running "perl -c" after you edited the script catches typos early. 2) Keyword help, i.e. launching WinHelp, man, perldoc, etc., and pass the word under the cursor. This is why I use FTE (http://fte.sourceforge.net/) A development environment SHOULD have: 1) Syntax highlighting editor. 2) Editor with parens/brace matching ability 3) Source browsing or tags support 4) Some kind of macro language or programmability 5) Editable keybindings (I cannot use any editor which doesn't Save on F2, too much Borland :-) -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: reformatting perl compiler warning/errors
On 01/04/2003 11:39:36 "Stuart Arnold" wrote: >>On 01/04/2003 10:19:44 "Stuart Arnold" wrote: >Your date format looks funny. It looks like its Jan 4, 2003. You may want to >check that out. > perldoc perllocale P.S. Please do NOT CC me, I'm on the list. -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: CGI execution problem, was: (no subject)
On 01/04/2003 09:15:34 Glenn Linderman wrote: >On approximately 3/31/2003 1:58 PM, came the following characters from >the keyboard of BB: >> I have begun learning CGI from a book dated '96 which refers to UNIX as a >> platform. I am using Win32 and have a question about an example from the >> book, which I assume works on some system, just not mine, hehe. >> What I do using I.E. 6.x is: >> 1. Enter the CGI path and filename in the browser Location field and press >> the Enter key >> 2. Note: 'Internal Server Error' is received. >> 3. Apache error log says: >> [error] [client] The system cannot find the file specified. :couldn't >> spawn child process: path/trythis.cgi To BB: This sounds like a webserver setup problem (which is sort of offtopic). By default (i.e. the config which is shipped with the installation), Apache enables CGI execution in the cgi-bin directory _only_ . You cannot put the script just anywhere because it will be treated as a plain file. Hmm, that cannot be the problem; Apache clearly tried to execute the script... Please tell us EXACTLY 1) where Apache is installed (full path to ServerRoot), 2) where the script is 3) what URL did you type in the browser >> >> I suspect the '&' but can not find a ref to this functionality on Win32 with >> ActivePerl 5.8.0.805 >> >> #---trythis.cgi- >> #!c/perl/bin/perl.exe There might be a ':' missing there ( #!c:/perl/bin/perl.exe ) If perl.exe is in the path, then #!perl might be enough. >> # >> $data = 'C:/Apache2/Apache2/htdocs/counter.data'; >> $lockfile = 'C:/Apache2/Apache2/htdocs/counter.LOCK'; >> # main routine >> print "Content-Type: text/html\n"; >> print "&increment"; > >Indeed, according to the HTTP protocol, the above line is supposed to >print out an additional HTTP header, since you haven't yet terminated >the headers with a blank line. > >&increment > >is not a valid HTTP header... so that probably leads to the internal >server error. > [snip] I doubt this is the cause. Take a look at the error message provided above: "couldn't spawn child process" means that almost certainly the script itself was never executed, hence its content is irrelevant (yet :-) To BB: Free advice which doesn't solve your problem but might save you many headaches in the future: use CGI; CGI.pm takes care of outputting the correct headers, plus it has nice HTML formatting routines for dynamic pages. P.S. Please do _not_ CC me, I'm on the list. -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Sending a sequence of system commands?
On 27/03/2003 15:26:05 perl-win32-users-admin wrote: >> Hello world! >> >> Is there a way to execute a series of system commands? >> >> For example if you tried to do an FTP how could you pass it all the >> subsequent command lines? (I know you can do it using Net::FTP, but I'm >> trying to do something else). [snip] > >since the FTP is an application, you should be able to send in the >commands as STDIN. > >open FH "| ftp 1.2.3.4" or die "Cannot open ftp app: $!\n"; >print FHpassword >bin >get filename >EOF > Just because FTP is an application it doesn't mean that it has to read the password from STDIN. That would mean echoing the password in clear :-( -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: reformatting perl compiler warning/errors
On 29/03/2003 06:53:45 perl-win32-users-admin wrote: >On 3/27/2003 5:24 AM, Stuart Arnold wrote: >> I want to be able to somehow reformat the error/warn messages that perl >> dumps out so that I can format it (override it). [snip] > >perldoc perlvar > >"Certain internal hooks can be also set using the %SIG hash. The routine >indicated by $SIG{__WARN__} is called when a warning message is about to >be printed. The warning message is passed as the first argument." > Note that the parameter to that function already has the "at myfile.pl line xx" at the end. You probably need to rearrange it before printing. SVC.pm: ->8- package SVC; BEGIN{ $SIG{__WARN__} = sub { $_ = shift; s!(.*)at (.*?) line (\d+)!$2($3) : $1!; warn $_; }; } 1; ->8- Then run perl -MSVC -w yourscript.pl -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::EventLog
On 25/03/2003 14:59:21 perl-win32-users-admin wrote: >I actually noticed the typo sometime after posting to this board, and >replaced it with: >new("Application", 'MDS-APL') >Unfortunately that did not work either! >Also, does anyone know if this module only allows me to write to the >application log? I have tried (Locally) writing to the Security or System >log to no avail! > [snip] Create a new Win32::EventLog with the first parameter (SOURCENAME) as 'System' or 'SysEvent'. Then call the Report method with Source set to any of "Workstation", "Wmi", "Windows Script Host", "Windows File Protection", "Win32k", "UPS", etc, etc... Look in the registry under HKLM\SYSTEM\CurrentControlSet\Services\Eventlog\System, there is a REG_MULTI_SZ value named "Sources". P.S. Please don't CC me, I'm on the list. -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::EventLog
On 24/03/2003 22:24:37 perl-win32-users-admin wrote: >Hello all, > >I am having a terrible time trying to get the following script to write to a >remote EVENT LOG. What am I doing wrong? or am I going outside of the >boundaries the module is capable of? Whether local or remote it always writes >to my local Event Log?? Any info would be greatly appreciated. > > > >use Win32::EventLog; >$| = 1; > >my $msg = "TEST"; >my $src = "MYPC"; >my $handle = Win32::EventLog->new("Application, $ENV{'MDS-APL'}") >or die "Cant open LOG\n"; ^^ You are passing a single parameter to Win32::EventLog::new ! (everything in the quotes gets interpolated into a single value). If that's a typo and you really meant new("Application", $ENV{'MDS-APL'}) then are you sure you meant the contents of the environment variable named \\MDS-APL and not the computer named \\MDS-APL ? I think you need to lose the $ENV{} around 'MDS-APL'. -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: if your download doesn't start...
On 21/03/2003 16:33:55 perl-win32-users-admin wrote: >Hi, > >A lot of "download" websites wind up showing a page _and_ starting a >download, apparently concurrently. Is there a "standard" CGI way of >doing that? > >They usually include an alternative "if your download doesn't start >automatically, Click here". > I suspect most of them contain something like this in the page: http://etc.etc.etc/";> and a link for those who disabled meta refresh. This seems the easiest way and no CGI needed. -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: (no subject)
On 20/03/2003 12:12:27 JamesTillman wrote: >> -Original Message- >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >> Sent: Thursday, March 20, 2003 4:34 AM >> Cc: [EMAIL PROTECTED] >> Subject: RE: (no subject) >> >> >> >> >Try server\\new\$ >> > >> >> Don't. Try '\\server\new$' if you need to give it to cmd.exe >> ALWAYS use forward slashes with Perl. > >Did you test this? It doesn't work for me. From this: > >my $var = '\\webdev\d$'; >print $var . "\n"; >system("dir $var"); > >I get: > >\webdev\d$ >dir: \\webdev\\d$: No such file or directory > Nope. Serves me right :-( [snip] > >I have found this feature to be inconsistently applied throughout >Microsoft's systems (and the problem exists in places other than just >cmd.exe), which makes it not really worth using, doesn't it? If you can't >rely on it being applied everywhere, you might as well get used to counting >toothpicks: myserver\\d > >Admittedly, when I said "Win32" I should have said "Microsoft." My intent >was to convey the fact that Microsoft consistently breaks with tradition in >this case, just as it breaks with tradition by making everything under its >direct control (VB/VBScript, T-SQL, IIS, cmd.exe, etc.) case-insensitive. > I think that IS keeping a tradition from the ancestor of MS-DOS: CP/M. >> mkdir( 'C:/foo' ) will work just fine (provided your C drive >> is writable : > >And, of course, the reason this works is because Perl itself is smart enough >to handle the slashes. It has nothing to do with Win32. > No, it works because the API function CreateFile (what an intuitive name for a function used to open files!) *does* understand forward slashes. I did try this : #include #include int main(void) { HANDLE h = CreateFile( "C:/autoexec.bat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL); if( h != INVALID_HANDLE_VALUE ) { CloseHandle( h ); puts( "success !" ); } } and the open succeeded. (Note that OPEN_ALWAYS means that it either opens an existing file or creates a new one if it doesn't exist.) -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: puzzle: passing command line args to wperl
On 12/03/2003 14:44:30 perl-win32-users-admin wrote: >This must be the problem. I had associated a file extension of .wpl to >wperl and was executing "foo.wpl bar" but was seeing no arguments. > Open an Explorer window and go to View/Options (on NT4) or Options/File Types on Win2000 (these move around for each new release of Windows)-: Find the entry for pl and Edit file type. Edit the "Open" action and make sure it looks like this: --- Action: Open Application used to perform the action: .\bin\perl.exe "%1" %* --- Similarly for your .wpl but substitute wperl.exe The crunch is the %* (not no quotes around it!). %* means "all arguments". Without it the system will run "perl.exe %1" (%1 is the script name), which means that it DOES NOT pass anything as arguments to the script! I think ActiveState's installer [HINT, HINT] puts in an association for .pl with "perl.exe %1" as the program for "Open", resulting in the behaviour described (arguments lost) -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: puzzle: passing command line args to wperl
On 11/03/2003 23:23:46 perl-win32-users-admin wrote: [snip] > >However I have discovered that I cannot pass command line arguments to the >wperl script and this is very inconvenient. > [snip] > >wperl fails to see the command line if I use getopts() or if I just operate >directly against the ARGV array. > That's odd, because perl.exe and wperl.exe are byte-for-byte identical except for offset 12C (run "comp perl.exe wperl.exe"). If you have the sources and look for WPERLEXE in win32/Makefile, you'll see that wperl.exe is created by copying perl.exe and changing the application type from console to windowed via exetype.pl Running this command wperl -e"$,=qq(...); print @ARGV" foo bar baz | more produces the expected foo...bar...baz Your problem might lie elsewhere. -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: environment variable issues
On 11/03/2003 19:35:11 perl-win32-users-admin wrote: >I am having problems retrieving some of the environment variables using cgi.pm >here is the code that I am trying to use, what the heck is wrong > >Code >declarations: use strict; # just in case you forgot :-) >use CGI qw/:ALL/; >$cgi = new CGI; > >routine: >{ >if (($cgi->http('request_method)) ne 'POST'){ > die " invalid script call method $cgi->http('request_method'),\n >$cgi->http('script_name') MUST be called using POST" >} > >error: >invalid script call method CGI=HASH(0x11b21c8)->http('request_method'), >CGI=HASH(0x11b21c8)->http:('script_name') MUST be called using POST at >D:\pumaspalace\cgi-bin\feedback.cgi line 87. > > >I have no idea how to fix it, the code seems to be set up the way the CGI.PM >docs want it... but the output from the die command is not giving proper >information. > If $cgi->http('script_name') is really what you want, you need to save its return value and interpolate that into a string. "$cgi->http ('script_name')" is apparently too complicated for string interpolation :-( routine: { if (($cgi->http('request_method)) ne 'POST'){ my $method = $cgi->http('request_method'); my $scriptname = $cgi->http('script_name'); die " invalid script call method $method,\n $scriptname MUST be called using POST"; } >Another thing, do you folks have any idea how to check and make sure that and >email address is valid, by this i mean that it actually exists on a server?? > For that, see perldoc -q valid -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: How do I edit the tab of an Excel worksheet?
On 07/03/2003 20:06:49 "Joel Brockman" wrote: > >Csaba, >Thank you for your effort. ActiveState provided me with an html document >containing a link to OLE Browser. The link brings up a blank page. That should not happen. Is that C:\Perl\html\OLE-Browser\Browser.html ? If there is an error, there should be a yellow triangle in the IE status bar. Click on it to see the error message. > I looked >for an online version of the documentation and found "Using OLE With Perl" in >the ActivePerl User Guide. There was nothing there to answer my question. >Before reading your email I would not have thought to follow the link "Where do >I find documentation for the object models?", but I thought it might have >something to do with the "object library" you referred to. Indeed, it directed >me to find the object browser in the visual basic editor of Excel. From there >I followed your directions to look through the methods and properties of >Worksheet to find "Name". Even after knowing the answer, I don't see how to >figure it out from the object browser. Could you explain more please? > Which object browser are you talking about here, the VB one or the Perl one ? P.S. Please don't CC, I'm on the list. -- Csaba Ráduly, Software Engineer, Sophos Anti-Virus Email: [EMAIL PROTECTED], Tel: 01235 559933, Web: www.sophos.com Add live virus info to your website: http://www.sophos.com/link/vfeed ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Tk buttons?
On 29/11/2002 23:57:14 perl-win32-users-admin wrote: >>From: Beckett Richard-qswi266 <[EMAIL PROTECTED]> >>To: [EMAIL PROTECTED] >>Subject: Tk buttons? >>Date: Fri, 29 Nov 2002 15:53:27 - >> >> >>When you click on a button to do a task, the button should stay "pressed" >>until the task completes. Normally this happens. >> >>However, as the task takes so long, I have included a few messages in my >>status bar to let the user know what's going on, and that all is still >>working. >> >>To update my status bar, and also to prevent the contents of the window >>from >>being wiped out if another window is moved across it, I periodically do >>$main_window->update; s. > >Untested -- Try only updating the statusbar. >$statusbar->update; > That will not help if another window is moved across the Tk window. >> >>Unfortunately, when I do one of those, the button pops back up. I have >>managed to re-configure the button, so that it's a different colour, and >>the >>text changes to "working...", but I can't work out how to configure it to >>look as though it's still pressed in. That's not how push-buttons are supposed to work (at least on Windows). In fact, the button should stay "pressed" only as long as the mouse button is down inside the button's rectangle. On Windows you can get this behaviour with a checkbox (!) with the BS_PUSHLIKE style. I doubt that is an option with Tk because it has to be cross-platform. P.S. Please don't CC me, I'm on the list. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: :Telnet on Win2K
On 28/11/2002 03:23:01 perl-win32-users-admin wrote: >I think no one has got this to work yet because none of us has banged our >head hard enough onto the desk top. > >And all this just to remotely power down a Win2K box.:) >I'll post what I come up with. > use Win32; Win32::InitiateSystemShutdown( MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT ); -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Can arrays be used as scalars?
On 24/11/2002 08:06:35 RCTay wrote: >my( @dir, $free); >@dir =3D `dir`; >$free =3D $dir[$#dir]; > >This code was written by a friend of mine. "@dir" was declared as a array, but >in the second line it is used as a scalar. How is that possible? There are no >warnings given by the interpreter. Can you please explain why it can be used? Neither the second nor the third line is valid Perl. Bareword found where operator expected at -e line 1, near "3D" (Missing operator before D?) Backticks found where operator expected at -e line 1, near "D `dir`" (Do you need to predeclare D?) Or did you mean something else ? -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Excel to html format
On 25/11/2002 21:13:28 perl-win32-users-admin wrote: >Hello, > > I have an Excel spreadsheet that a person saves to a network drive >daily. I want to automate the task of opening the file and saving it as html >(the person can't do it themselves, their not technical enough! ). I know the >OLE modules can let you manipulate the data in a spreadsheet but can it save >the file as html? > If I were you, I'd extract the data from the spreadsheet and write the HTML from Perl. The $expletive produced by Excel claiming to be HTML is just awful (and Office 2000 is even worse). If you do save from Excel, make sure you run the resulting file through HTML Tidy. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Regular Expression Problem
On 20/11/2002 13:06:29 Lee Cullip wrote: >Thanks for replying Joe, >maybe if you see a bit more code you can get an idea for what I'm trying to >do : > >use Net::Telnet; >use IO::File; > >$prmpt =~ /^(.*:\/home\/oracle[:=>]{1,2})/; [snip] > >I still get the following error message though : > >bad match operator: opening delimiter missing: ^(.*:/home/oracle[: =>]{1,2}) >at C:\Documents and Settings\lcullip\My >Documents\programming\perl\oracheck.pl line 41 > >WTH am I doing wrong ? > You are not giving us the exact script, perhaps because you are re-typing instead of copy&paste. I pasted the above regex into perl -pwe "s/^(.*:\/home\/oracle[:=>]{1,2})/<<<$1>>>/" and it duly replaced :/home/oracle: with <<<:/home/oracle:>>> -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Browsing for SMB machines using a network broadcast? (Peter McGowan)
On 14/11/2002 11:17:57 Geoffrey Leeming wrote: >Thanks for the reply. Unfortunately that tells me what the PDC thinks is >there, rather than what necessarily *is* there :-) One of the many reasons I >run this script is to check for unauthorised machines on our physical network, >so I need to explicitly check every machine that's pingable inside our firewall. > If it's a SMB machine (Windows, Samba, etc) it's sure to emit the usual "NETBIOS chatter". Listening to that with e.g. Ethereal (NIC in promiscuous mode) would yield a list of IP addresses. You could do something like this: Put NIC in promiscuous mode; # Perhaps the difficult bit, libpcap might help Listen to everything on the network Record source addresses (perhaps a hash) Check source addresses -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: [PMX:##] Hello Hello
On 04/11/2002 20:52:02 Joseph P. Discenza wrote: >Scott Carr wrote, on >: The problem. I have a Hex string like >: 54686973206973206120746573740d0a546f2073656520686f772077656c6c20 >: >: I want to convert it to its binary representation. I am using a >: command like pack("H*", $hexstring) to get the binary from this string. >: >: The issue. Instead of having your normal Carriage Return Line Feed as >: designated by the 0d0a hex code, I am seeing 0d0d0a returned by >: pack. It is adding another Carriage Return to the string. > >Where does this string come from? And where is it going to that you "see" >the extra CR? > >Perl does the "right thing" by translating any "end of line" ("\n", usually) >to a Windows "end of line" ("\r\n") when outputting to a file. If you don't >want that, you have to binmode(OUTFILE) after opening your output file, but >before writing to it. > Congratulations to Joseph P. Discenza for a working implementation of PSI::ESP. There is no mention of writing to a file anywhere in the original mail, yet he still managed to correctly diagnose the trouble spot. Please post your implementation to CPAN :-) -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::Registry - Why won't this work??
On 04/11/2002 20:23:12 Steve Silvers wrote: >The below snippet gives me the error: "Can't call method Open on an >undefined value". > >#!/Perl > >use Win32::Registry; > >$reg = $HKLM->Open('SOFTWARE\\Microsoft\\Office'); > die "Registry open failed: $!, $^E" unless defined $reg; ># print out all subkeys of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office ># and their default values > >sub prt { >print $_[0]->Path,' = ',$_[0]->GetValue(''),"\n"; >} > >$reg->FindKey(\&prt); > >Any Suggestions? Yes. Always, yes ALWAYS check the return value from functions which interact with the system (i.e. the rest of the world). -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Terrible at my logic - some more inputs
On 25/10/2002 15:37:16 Krisna, Hari wrote: >forgot to include the print statement > >print OUTPT "$ln54_1 $ln54_2 $ln54_3 $ln54_4 $ln54_5 $ln54_6 $ln54_7 $ln54_8"; > change this to: print OUTPT "$ln54_1!$ln54_2!$ln54_3!$ln54_4!$ln54_5!$ln54_6!$ln54_7!$ln54_8!"; You separate the columns with spaces and your input also contains spaces, this makes it difficult to distinguish between the two ("is that space from the input or is it a separator ?"). Use the exclamation marks as eye-catchers; you'll be able to see what's going on. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Catching what is travelling from and to your browser
On 19/10/2002 09:35:23 perl-win32-users-admin wrote: >Greetings to all, > >I would like to write a simple Perl script (for Win32) able to catch >what my browser is sending and receiving (especially the headers) during >a particular http transaction. It sounds to me that what you want is a HTML proxy. Google for "Tony Finch htmlf" htmlf is a HTTP proxy which filters out certain HTML bits. You can ignore that and concentrate on the proxy behaviour. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: working with array references.
On 13/10/2002 01:30:18 perl-win32-users-admin wrote: >Hi list, > >given an array reference in a hash, how can I append an item to the end of >that array? Or find the length so that I can assign it using $ref-[$n] >type notation? > >I have tried various comboes... > >$hash{$key} holds a reference to an array in the sample code presented. > [snip] > >...but I don't like the idea of _having_ to use those extra lines of code >there, there should be a way to append an item to a list reference in ^^ >one single operation. > You can't. A list reference is a scalar, you can't append to it (not in the array sense, anyway). If $hash{$key} is a reference to an array, then @{$hash{$key}} is the array, $hash{$key}->[-1] gives the last element and push @{$hash{$key}}, 11 extends the array. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: What is the HTTP REFERER story?
On 06/10/2002 23:19:46 perl-win32-users-admin wrote: >Some browsers do not send the referer header. This variable seems so >useful, I'm wondering why it is being left out. Is it an error? Is it Some people consider REFERER a privacy leak (and have written browsers which don't send it by design !) If the browser doesn't send HTTP_REFERER, there's little the server can do (apart from refusing to serve up the page). -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Regualr Expression Again...
On 11/09/2002 14:53:05 Barlow, Neil wrote: > >I am looking to match \ at the end of the line - >Have tried $scandir=~/\\$/ and am still not getting a match >My input is C:\ > Run your script with perl -Mre=debug yourscript.pl That will show you what the regular expression engine is doing (make sure you redirect stderr, there's lots of output). -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: URGENT...need special system call...URGENT
On 10/09/2002 20:56:39 perl-win32-users-admin wrote: >I am having problems with a system call. I used perl2exe with a -gui >option, which means that no command prompt will pop up during execution and >the compiled script remains hidden. The problem is...Now that I did that, >my system call to an external exe no longer works. My system call is >currently set up in my script like this: > >$result = `$commandline`; # where $commandline is say, for example, >'blat.exe file.txt -body "body"' (this is just an example...the actual call >is MUCH longer) > Did you check the result ? unless( defined $result ) { # backticks return undef on failure die "command execution failed: $!, $^E" } >When using the -gui switch when compiling my perl script to an exe with >perl2exe, all STDIN and STDOUT is hidden, and for some reason this is >prohibiting my compiled perl script from running this system call. This is >BAD! I think this is a red herring at best. I don't know what perl2exe does, but I doubt it would prohibit running external programs. Run your script with 'wperl.exe' instead of 'perl.exe' and redirect both stdout and stderr: wperl script.pl 1>111 2>222 Do the same with the compiled program: script.exe 1> 2> Check the content of the generated files. > >Unfortunately, I have to keep the compiled script 'hidden', so I need >another way to call this external program. > >I don't know how to do PIPES. This is the first time it's ever come up in >any of my programs. Using pipes is simple :-) open( PIPE, "$commandline |" ) or die "Could not open the pipe: $!, $^E"; # always check result of open while( <> ) { # process the output line-by-line } close( PIPE ) or die "close failed: $!, $^E" # always check result of close, especially if using pipes (see perlipc) > Is there a way to open a PIPEOUT to the external >program and get the result of the program from a PIPEIN? I need to store >the entire result of the external program to $result so that I can do some >error checking. That's not what you were doing. With backticks you can only read the output of the external program. With pipes you can choose whether to read or write. Check out the perlipc documentation. In principle, you cannot do both at the same time (but see the IPC::Open2 package, recommended in perlipc). > >This is very high priority, so if anyone has ANY ideas at all, helpful or >not, please feel free to respond! Thanks! > For every complicated problem there's an answer which is simple, neat, and wrong. :-) Disclaimer: I just typed these lines in, not tested them. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Regualr Expression
On 10/09/2002 15:55:14 perl-win32-users-admin wrote: >> oops, do that and you'll confuse it. swap that for >> >> $dir=~s'\'/'g; #not interpolated with single quotes > >Huh? I've never heard of that. It doesn't work for me either. What version >of Perl are you using, and where is this documented? > The "not interpolated with single quotes" is documented in "Quote and quote-like operators" in perldoc perlop. This won't affect the fact that backslash needs backslashing. Turning "backslash followed by n" into a newline is interpolating and can be turned off. Removing the special meaning of the next character is not interpolating and cannot be turned off. You need that if you want to write s'\''`'; # a perverse way of turning apostrophes into backticks. s' \' ' ` 'x; # slightly more legible You'll always need a backslash to turn ' from a delimiter to a plain ol' character. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Regualr Expression
On 10/09/2002 15:37:44 perl-win32-users-admin wrote: >>$dir=~s!\!/!g; #should work better, no ambiguity with slashes > > >oops, do that and you'll confuse it. swap that for > >$dir=~s'\'/'g; #not interpolated with single quotes > >~or~ > >$die=~s!\\!/!g; > There's also: $die =~ tr!\\!/!; -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Current directory path
On 04/09/2002 11:51:33 Tillman, James wrote: >> >> [EMAIL PROTECTED] wrote: >> > >> > >> > Hi! >> > >> > There is some way to get the current directory path of perl script? ^ >> >> Try core Cwd module. > >That actually returns the current directory, which may or may not be the >directory of the script when it is run. FindBin may be a better choice in >this case. Also a core module, and mentioned in the docs. > The original question was ambiguous. The word "current" suggests something that changes. The path of the script doesn't change during runtime, hence I would have thought that the initial poster wanted Cwd. It seems that between you and $Bill all possibilities have been covered. And I learnt about FindBin. I would have thought of $0 for that case. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[PMX:#] RE: Collections in 'Scripting.FileSystemObject': in works, ->Item(...) doesn't -- why?
On 28/08/2002 13:07:51 perl-win32-users-admin wrote: >On 28/08/2002 12:00:58 I wrote: > >>> Hi, Jan suggested I post this here. Maybe the first question is >>> why I would need the 'Scripting.FileSystemObject' in Perl, but >>> I have my reasons. I was actually testing the Win32 intellisense >>> in Visual Perl, but found I could write a realistic app. >>> >>> Currently the intellisense works on things like >>> >>> my $fso = Win32::OLE->new('Scripting.FileSystemObject'); >>> my $path = 'c:\WINNT\System32'; >>> my $folder = $fso->GetFolder($path); >>> my $len = $folder->SubFolders->{Count}; >>> my $subfolder = $folder->SubFolders->Item(0); >^^^ > >The Item property is 1-based, i.e. the *first* one is Item(1), not Item(0) >Index 0 is not valid. > Whoops, I spoke too soon. Item(1) doesn't work either. Maybe Item is broken :-( I tried the VB equivalent of the above and that failed too. Get yourself an enumerator, or replace the last line with my @subfolders = in $folder->SubFolders; my $subfolder = $subfolders[0]; Note: this is a workaround. It shouldn't be needed if Item worked. It's also inefficient (it fetches all the items at once from the collection). -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Collections in 'Scripting.FileSystemObject': in works, ->Item(...) doesn't -- why?
On 28/08/2002 12:00:58 perl-win32-users-admin wrote: >> Hi, Jan suggested I post this here. Maybe the first question is >> why I would need the 'Scripting.FileSystemObject' in Perl, but >> I have my reasons. I was actually testing the Win32 intellisense >> in Visual Perl, but found I could write a realistic app. >> >> Currently the intellisense works on things like >> >> my $fso = Win32::OLE->new('Scripting.FileSystemObject'); >> my $path = 'c:\WINNT\System32'; >> my $folder = $fso->GetFolder($path); >> my $len = $folder->SubFolders->{Count}; >> my $subfolder = $folder->SubFolders->Item(0); ^^^ The Item property is 1-based, i.e. the *first* one is Item(1), not Item(0) Index 0 is not valid. Blame VisualBasic :-) -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: best way to list/remove network connections
Brian Gibson wrote: > Does anyone know of a module you can use to list all of the current > connections to remote shares (whether they be to a UNC path or to a > drive letter) so they can be disconnected? > > I thought Win32::LanMan could do this but when I run "install > Win32::Lanman" from PPM I cannot download it. On 21/08/2002 17:15:45 Steven Manross wrote: >Win32-Lanman can do this. > You didn't seem to rad his post to the end... Brian, in the meantime, try this: #!perl -wl use strict; my @sessions = `net session`; foreach( @sessions ) { chomp; next unless /(\S+)/; print "Disconnecting $1 ..."; system( "net session $1 /DELETE" ); } --- -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: if & unless inverses ???
On 20/08/2002 17:23:11 perl-win32-users-admin wrote: >Cleaning up some inherited code and I ran into this: > >if ( ! $m_rkCfgTable->{Trace} eq "true") { >$m_nTraceLevelMin = -1; >return 0; >} > >For the life of me, I cannot fathom why this is *not* identical? > >unless ($m_rkCfgTable->{Trace} eq "true") { >$m_nTraceLevelMin = -1; >return 0; >} > >What am I missing? > eq has a very low precedence. The ! applies to $m_rkCfgTable->{Trace}, not the result of eq. !"false" is 0 (same as !"true", of course), which is never eq "true". -- If it ain't broke, don't break it. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: trying to understand how regex works
On 13/08/2002 06:26:59 perl-win32-users-admin wrote: >Hi all, >I guess it must be a simple problem, but it's a >mystery to me. [snip question involving regex] > >Anybody cares to explain this to me? Try running your script with perl -re=debug scriptname.pl 2>re_debug Make sure you redirect stderr to a file, as there's plenty of it. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::OLE: Language of error message?
On 31/07/2002 12:34:14 perl-win32-users-admin wrote: >- Original Message - >From: "Dr. Thomas Bruns" <[EMAIL PROTECTED]> > >> >> Win32::OLE(0.1502) error 0x80020010: "Aufgerufener ist ungAültig" >> in METHOD/PROPERTYGET "myMethod" at myModule.pm line 123 >> >> I am German, but this messages makes no sense to me! Ah, brings back memories of "Nicht bereit reading Laufwerk A:"... >> So, I'd rather like this messages to be in English, since all the docs >> are English, too. >> >> Can anybody tell me, how to get the (generic) message and not the >> (no-(n-)sense) translation?? >> > >Can you identify where the German part of the message originates ? >ie does it come from perl, or from windows, or from the Win32::OLE module, >or from the software you are trying to access ? > Use the source, Luke: Everything except the "Aufgerufener ist ungültig" part is generated by Win32::OLE in ReportOleError. In order to get the system error message for the error code, it is calling FormatMessage with the locale ID set to the variable lcidSystemDefault ( 2<<10 ). Hence the German text for the errorcode-dependent part. It would seem that you need to either change your system locale, or recompile Win32::OLE. Apparently Win32::OLE used language-neutral locale in the past, using the system default might have been a recent change. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: how to match '*'
On 09/07/2002 22:12:58 perl-win32-users-admin wrote: >I am trying to match the '*' character and am having trouble getting anything. >Basically, I have some lines that I want to extract only if they start with a >'*'. > >Seems easy enough. > >if ($line =~ /^\*/) >{ > print "Match! $line\n"; >} > >No deal. Tried faking it out by putting it in a $var (with an without >double-quotes) and then match that, but perl is too smart for that non-sense. > >Any help greatly appreciated. > Run your script with -Mre=debug That will show you what the regexp really compiles to, and what happens at runtime. Redirect stderr, because it generates lots of output. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Help!
On 13/06/2002 17:47:01 Chris Anderson wrote: [snip] > >What is my problem: > >It work: No, it doesn't , unless you have a program with a VERY interesting name in C:\winnt, called "system32 sh.exe" (including the linebreak !) >Win32::Process::Create($ProcessObj, > 'c:\\winnt\\system32\rsh.exe', ^^ Hint: that's not an 'r', there. ^^ Please use forward slashes in the future, unless you are constructing a commandline for CMD.EXE, COMMAND.COM, or any of the legacy commands (XCOPY, etc). Every component of Win32 understands forward slashes '/' as path separator, except for the command interpreter. > 'rsh x.x.x.x -l compname sh account', > 0, > NORMAL_PRIORITY_CLASS, > '.'); >$ProcessObj->Wait(2000); > >:) > >IT DON'T WORK ! >Win32::Process::Create($ProcessObj, > 'c:\\winnt\\system32\rsh.exe', > 'rsh x.x.x.x -l compname sh account >account.log', > 0, > NORMAL_PRIORITY_CLASS, > '.'); >$ProcessObj->Wait(2000); > >WHY? > "It don't work" is not good enough as a description of a problem. What do you expect to happen ? What is happening instead ? -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Send email in ActivePerl using SMTP
On 06/06/2002 22:00:09 Yi Zhang wrote: >I tried the following to use SMTP to send email: > > >use Net::SMTP; >$optServer = 'luxn.com'; >$optFrom = "[EMAIL PROTECTED]"; >$optTo = "[EMAIL PROTECTED]"; >$smtp = Net::SMTP -> new ("luxn.com"); >$smtp -> mail($optFrom); [snip rest of script] >What might be wrong here? > The fact that you didn't check if new() succeeded. Obviously, it did not. You need to find out why it didn't connect. Try this in place of your line with new : $smtp = Net::SMTP->new( 'luxn.com', Debug => 1 ) or die "Cannot connect: $!"; -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: use lib failing on IIs
On 06/06/2002 22:24:36 perl-win32-users-admin wrote: >Group, > >I got all my stuff run on my local box with perl/apache/mysql and then I >went to move everything to the main IIs server. However. when I ran my >scripts that worked before in the same directory structure on my local box I >got the following: > >Can't locate STDLIB.pm in @INC (@INC contains: ../ C:/Perl/lib >C:/Perl/site/lib .) at D:\web\cgi-bin\scripts\admin\admin.pl line 35. >BEGIN failed--compilation aborted at D:\web\cgi-bin\scripts\admin\admin.pl >line 35. > >my script looks like this: > [snip Perl code including a "use STDLIB"] It sounds as if STDLIB.pm was not installed on the IIS box, only the local box. Does it actually exist in those directories listed by @INC ? P.S. Please don't CC me, I'm on the list. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Win32::API and GetOpenFileName
On 06/06/2002 00:42:42 Dax T Games wrote: >Anyone been able to import the GetOpenFileName API from comdlg32.dll. > >So I don't need to reinvent the wheel? I have been trying but have had no >success. > GetOpenFileName puts up a dialog box. You might need a message loop. (I think Perl.exe is a console application). Maybe you could use Tk. -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Determining Default 'My Documents' folder path
On 30/05/2002 15:24:40 perl-win32-users-admin wrote: >I have been looking for a way to determine the path of the 'My Documents' >folder for a PC. I assume this is a registry setting. I did a search for >this through MY registry and the only potential references I can find refer >to a shell32.dll,9227. I don't have a clue as to what that means. > Forget that. For Windows 2000, look in the registry under HKCU/Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders - HKEY_CURRENT_USER (there's a space character there)---^ You'll find entries for "Administrative Tools", "Desktop", "Favourites", "Start Menu", etc. Look for either "My Documents" or "Personal". -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Regex matching pairs?
Run this: perldoc -q balanced -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
ActivePerl help file
Is there an ActivePerl.chm with a working index ? The one in build 630 has a completely empty index :-( -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Archive Zip Help
On 30/04/2002 18:40:35 Joseph Jongquist wrote: >Hello Carter, > >Try these suggestions: > >>my $dir = "C:/tmp2"; >CHANGE TO: >my $dir = "C:\\tmp2"; > AARGH ! Please don't ever suggest that. Perl is perfectly capable of understanding "C:/tmp2" Even Windows understands "C:/tmp2". The only thing that can't cope with "C:/tmp2" is command.com and the commandline DOS utilities. As long as Archive::Zip doesn't run zip.exe via system(), "C:/tmp2" should be perfectly adequate. There's no need to use backslashes as path separator in Perl, ever. People tend to forget to double them. There's no such danger with forward slashes, plus it makes the script possibly cross-platform. >>my $member = $zip->addDirectory('$dir'); This will try to add a directory whose name contains a literal $ character. >CHANGE TO: >my $member = $zip->addDirectory($dir); >OR: >my $member = $zip->addDirectory("$dir"); > > -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Basic Perl question
On 22/04/2002 06:49:52 perl-win32-users-admin wrote: >Dear All, >I have seen one perl code with the following stuff > >sub func_name($$$) >{ >$a = @_; >} > >My question is , > >What is the purpose of $$$ in the function definition. > It tells Perl that func_name expects three scalars. Check out prototypes towards the end of perldoc perlsub -- Csaba Ráduly, Software Engineer Sophos Anti-Virus email: [EMAIL PROTECTED]http://www.sophos.com US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs