Re: testing if XML is well-formed
Brian Gibson wrote: This might sound like a dumb question but does anyone know of a module or script that simply checks an XML file to see if it is well-formed or not (the validity of the XML is not an issue, but if there is an easy way to check that too then I am all for it!) My search around CPAN got pretty frustrating. You can use XML::Parser to do a simple well-formedness check, like this: require XML::Parser; my $p1 = new XML::Parser(ErrorContext = 3); eval{$p1-parse($xml)}; # assume document in $xml print Not well formed!\n$@ if $@; # fatal error HTH -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Exe2perl - the C version
Sisyphus wrote: Allegakoen, Justin Devanandan wrote: List, I know there's exe2perl, but a while back I remember there being a thread with a link to a C program that can extract Perl from an executable. Anyone know where it is? Thanks It was written by Chetan Ganatra [EMAIL PROTECTED]. I forget where the source is, but I compiled the executable and you can get it from: http://robgil.hypermart.net/w32perl/Exec2pl.exe His claim is that it works on executables generated by Perl2Exe Ver 5.03 for win32. Usage: exec2pl [exefile] [plfile]. Let me know if it works, btw. No-one has yet confirmed that it does - though someone did confirm that it *doesn't* work with applications built with perlapp. A quick google turned up this: http://www.derkeiler.com/Mailing-Lists/Securiteam/2002-01/0105.html HTH -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Hash of arrays
Daniel Gross wrote: Seems to work. It doesn't generate a syntax error. So, value elements within a hash are always references? no, but they are always scalars :) BTW, in your opinion would this also work when $dirHash{$prefix} is undefined (i.e. when no key was defined yet?) perl has a feature called autovivification, that usually Does The Right Thing to create whatever you are trying to create. Here is a tested full example from your original post: code #!/usr/bin/perl use strict; use warnings; my @dirArray = qw( abcdStuff1 acdeStuff1 abcdStuff2 Stuff2 acdeStuff2 Stuff1 ); my %dirHash = (); foreach my $item(@dirArray) { my $prefix = substr($item, 0,4); push @{$dirHash{$prefix}}, $item; } use Data::Dumper; print Data::Dumper-Dump([EMAIL PROTECTED], \%dirHash], [qw(*dirArray *dirHash)]); /code -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Importing Win32 Symbolic Constants
Steve wrote: In the Win32 docs at http://search.cpan.org/author/JHI/perl-5.8.0/lib/Win32.pod in the item for Win32::SetChildShowWindow it says: [EXT] The following symbolic constants for SHOWWINDOW are available (but not exported) from the Win32 module: SW_HIDE, SW_SHOWNORMAL, SW_SHOWMINIMIZED, SW_SHOWMAXIMIZED and SW_SHOWNOACTIVATE. But when I specify use Win32 and use strict and then try something like Win32::SetChildShowWindow(SW_SHOWMINIMIZED) I get a bareword error. If I put the argument in quotes, nothing hapens. I guess, then, I must need to import these constants. However the only docs I can find about importing symbolic constants are in Win32::OLE which I don't think applies here, probably. Can anyone tell me how to do it? try this: Win32::SetChildShowWindow(Win32::SW_SHOWMINIMIZED) -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: socket application
Jeff Slutzky wrote: I am attempting to make a socket server running on a Win98 platform and have a socket client connecting from a SCO Unix platform. What happens is that I start the server and it sits waiting, I then connect from the SCO server with the client socket app and I detect a connection on the Windows box. What doesn't happen is the client sends a Hello string to the server and the server does not read what's going through the socket. I'm attaching the code, and it is pretty plain jane. If anyone can point me in the right direction I would appreciate it. ++ sockets.pl - running on a Win98 box. use IO::Socket; my $sock = new IO::Socket::INET (LocalHost = '192.168.2.39', LocalPort = '7801', Proto = 'tcp', Listen = 1, Reuse = 1,); die Could not create socket: $!\n unless $sock; my $new_sock = $sock-accept(); print accept\n; while($new_sock) { print $_; } close($sock); how about using the recv method on $new_sock: $new_sock-recv($inbuf,$inbuf_length,0) or croak $0 - can't recv: $!; -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: [PMX:#] Perl MVC pattern proyect
Fernando Freire Baez (Medicare) wrote: Hello, I am coding some sites in my job and I will guide my proyect in an MVC (Model, View, Controller) envairoment. I will like to know if someone know if exist already a tutorial for MVC in perl. I know the implementation of MVC in other language like Java and C++ but I want to know if there is something in perl. Thanks in advance. The proyect is for some websites and I will use Perlis for the www Deamon. a quick google turned up 6,970 hits for [Model, View, Controller perl] http://www.google.com -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: bless question
Burak Gürsoy wrote: Can anyone explain this? is this a bug or feature? what were you expecting #!/usr/bin/perl -w use strict; package Test::One; sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } package Test::Two; sub new { my $class = shift; my $test_it = shift; #$text_it == $test_one my $self= $test_it; #$self == $test_one bless $self, $class; # $test_one now object of Test::Two return $self; } package main; my $test_one = Test::One-new(); print [Before] ref(\$test_one) = ,ref($test_one),\n; my $test_two = Test::Two-new($test_one); print [After ] ref(\$test_one) = ,ref($test_one),\n; does what I would expect... -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: bless question
Burak Gürsoy wrote: But I dont use bless on the first object, create a clone of it an use bless on the second one and return this second one. It looks like a bug to me. ok, let me try again. #!/usr/bin/perl -w use strict; package Test::One; sub new { my $class = shift; my $self = {}; # here an anonymous hash is created. bless $self, $class; # here that hash is blessed into package Test::One return $self; # and the blessed thingie is returned } package Test::Two; sub new { my $class = shift; my $test_it = shift; my $self= $test_it; bless $self, $class; return $self; } package main; my $test_one = Test::One-new(); print [Before] ref(\$test_one) = ,ref($test_one),\n; print $test_one\n; # I added this to show what $test_one refers to. when I ran this # I got this: Test::One=HASH(0x1abf0ac) # this shows the hash at '0x1abf0ac' has been blessed into # package Test::One. my $test_two = Test::Two-new($test_one); # when the Test::Two::new method is called, you are # passing it the reference to the blessed anonymous hash. # the Test::Two::new method reblesses that anonymous hash # into the package Test::Two. print [After ] ref(\$test_one) = ,ref($test_one),\n; print $test_two\n; # again, let's see what $test_two contains. on my system, I # got: Test::Two=HASH(0x1abf0ac) # this shows the hash at '0x1abf0ac' has been blessed into # package Test::Two. # I say again, this is what I expect. # have a look at the perl documentation for references and # objects: http://www.perldoc.com/perl5.8.0/pod/perlref.html http://www.perldoc.com/perl5.8.0/pod/perltoot.html # HTH -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: bless question
Alan Dickey wrote: Burak Gürsoy wrote: But I dont use bless on the first object, create a clone of it an use bless on the second one and return this second one. It looks like a bug to me. maybe I can be more helpful. To clone the first hash in the second constructor, try this: package Test::Two; sub new { my $class = shift; my $test_it = shift; my $self= {%$test_it}; bless $self, $class; return $self; } -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Execution Problem
Krishna, Hari wrote: Hi friends, I am executing the following program from my C:\ drive and I get the following error. The database(Sql server) is on a different machine but in the same domain as I am. I execute the program on the SQL Server, the program just executes perfectly. But I execute it from my PC, it throws error. #!C:\perl\bin\perl.exe use Win32::ODBC; my($db) = new Win32::ODBC(DSN=XXX;UID=YYY;PWD=~!@#$%^*); $db-Sql(Delete from Inet_Job);- this is line 6 $db-close(); The error is: Can't call method Sql on an undefined value at C:\Inet_Delete.pl line 6. Any ideas as what am I doing wrong? from the ODBC documentation: quote new: Returns a handle to the database on success, or undef on failure /quote -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:afdickey;intac.com VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: While
I have a question regarding to an aplication I am working on with an ulimited while cicle While (1) { #code } This cicle keeps asking until one of the exit functions appears to finish the cicle. My problem is that the cicle consumues 100% of the CPU's resources, making things slower on my server. Does someone knows how to avoid or prevent the cicle from consuming my CPU's resources. thanks christian [EMAIL PROTECTED] try this: while(1) { # your code sleep(1); # give up cpu for 1 second } -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:afdickey;intac.com VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Object Question
Kevin, try this: $temp = member; $stmt = print \$config-get_$temp;; eval($stmt); -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:afdickey;intac.com VOX: 908-273-3232 Cell: 908-334-0932 Kevin wrote: Hello, I have an object with a number of functions. I am trying to call a function based on a dyanic variable, as in the following example print $config-get_member... prints Tom I need a variation of the following that works - if it is possible: $temp = member; print $config-get_$temp Is this possible? Kevin ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Determining if a Windows Server?
Hawley, Eric wrote: I need to be able to determine whether or not the computer that a script is running on is a Windows NT or 2000 server or if it is not. Does anyone know how to do this? I tried looking at Win32::GetOSVersion() but this won't work. I have tried searching on CPAN but haven't found anything. how about $^O (see perldoc perlfunc) -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Determining if a Windows Server?
Tony White wrote: Whew! I thought this was an easy one, but I just spent nearly an hour finding out *any* way to find this out. And here it is: Look at the contents of the following registry value: HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions/ProductTy pe It will have one of 3 values: WinNT -- Workstation (or Professional for Win2K) ServerNT-- Server LanmanNT-- Advanced Server (but I found this on an NT PDC, too) Thanks, Tony! As a summary for those interested, I put together this little script: -- use Win32; # compare various OS info: print \$^O = '$^O'\n; my @osinfo = Win32::GetOSVersion(); print Win32::GetOSVersion() = '@osinfo'\n; @osinfo = Win32::GetOSName(); print Win32::GetOSName() = '@osinfo'\n; use Win32::TieRegistry; my $producttype = $Registry-{'HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ProductOptionsProduct Type'}; print HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions\\ProductType = '$producttype'\n; -- on my machine (W2K Professional SP3) this produces: $^O = 'MSWin32' Win32::GetOSVersion() = 'Service Pack 3 5 0 2195 2' Win32::GetOSName() = 'Win2000 Service Pack 3' HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/ProductOptions\ProductType = 'WinNT' Cheers. -- Alan F. Dickey - Interaction and Realization http://www.intac.com/~afdickey mailto:[EMAIL PROTECTED] VOX: 908-273-3232 Cell: 908-334-0932 ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs