unix perler needs win32 API perl snippet


dear perl experts---I hope this is a request for a one-liner. I usually run linux or OSX, but I now am in need of automating some OCR on Windows. (The OCR vendors only sell affordable software on Windows in their ...
Posted On: Sunday 25th of November 2012 10:05:26 PM Total Views:  160
View Complete with Replies

RELATED TOPICS OF Perl PROGRAMMING LANGUAGE




parser project needs C++ programmer

I'd like to know if anyone of you would be interested in being payed ($$$) to program a BNF like parser. Intermediate to advanced programmer skills required because the project deals allot with pointers and memory updates and inter-mixes c/c++/perl code. Anyone interested visit http://www.angelfire.com/cppcode/blog/spec_0.txt for futher details cvv3@yahoo.com
VIEWS ON THIS POST

137

Posted on:

Wednesday 3rd October 2012
View Replies!

using unix command issue...

all, Any time I run a unix command where I initiate a variable > use the variable as an arg in the unix command > pipe it to another unix command, I get an error. This is the error I get: --------------------------------------- ../test.1.pl Use of uninitialized value in concatenation (.) or string at ./test. 1.pl line 8. sh: syntax error at line 1: `|' unexpected 512 --------------------------------------- -----Here is the contents of the perl script-------- #!/usr/bin/perl -w check_LANon () ; $utadm_l = "/opt/SUNWut/sbin/utadm -l" ; sub check_LANon { $LANstat = system(" $utadm_l | grep On") ; print "$LANstat\n" ; } ------------------------------------------------------------ How can I run this succesfuly I have other scripts that I need to do this with as well, but I can't since I always get this error. If I substitute $utadm_l with the actual command, it works fine. Only barfs when I use a variable.
VIEWS ON THIS POST

149

Posted on:

Tuesday 16th October 2012
View Replies!

XS PM needs big data file (~80mb) to operate

Thank you for your reply! It's a readonly binary file with model coeficients. Jan
VIEWS ON THIS POST

127

Posted on:

Tuesday 16th October 2012
View Replies!

Devel::SmallProf claims "return 1" needs much time !?

I'm trying to do some profiling on DBM:eep. I started with Devel:Prof and Devel::Profile but for some subs I had no idea *why* they took long, so I tried Devel::SmallProf for additional detail. Much of what I see makes sense but results like this puzzle me (these are the subs that do the low-level disc read and write): count wall tm cpu time line 0 0.00000 0.00000 103:sub print_at { 314000 0.96161 3.67000 104: my $self = shift; 314000 0.88398 3.34000 105: my $loc = shift; 0 0.00000 0.00000 106: 314000 1.51351 3.89000 107: local ($/,$\); 0 0.00000 0.00000 108: 314000 1.07561 3.94000 109: my $fh = $self->{fh}; 314000 4.39820 7.83000 110: if ( defined $loc ) { 0 0.00000 0.00000 111: seek( $fh, $loc + $self- 0 0.00000 0.00000 112: } 0 0.00000 0.00000 113: 314000 3.46850 6.32000 114: print( $fh @_ ) or die "Internal Error 0 0.00000 0.00000 115: 314000 6.65324 9.86000 116: return 1; 0 0.00000 0.00000 117:} 0 0.00000 0.00000 118: 0 0.00000 0.00000 119:sub read_at { 500507 1.43996 6.05000 120: my $self = shift; 500507 1.60207 5.78000 121: my ($loc, $size) = @_; 0 0.00000 0.00000 122: 500507 2.44265 7.01000 123: local ($/,$\); 0 0.00000 0.00000 124: 500507 1.43653 5.88000 125: my $fh = $self->{fh}; 500507 7.14111 11.73000 126: if ( defined $loc ) { 0 0.00000 0.00000 127: seek( $fh, $loc + $self- 0 0.00000 0.00000 128: } 0 0.00000 0.00000 129: 500507 1.41859 6.08000 130: my $buffer; 500507 4.36185 8.77000 131: read( $fh, $buffer, $size); 0 0.00000 0.00000 132: 500507 7.96107 12.04000 133: return $buffer; 0 0.00000 0.00000 134:} Much of the time is spent in "seek", "print" and "read" -- as expected (although I'm surprised it's only tenths of microseconds per call -- I suppose disc caches work their wonders...). But even more time is spent in the two "return" statements, and I don't know why! I thought that maybe they contain the overhead of function calling/returning but coudn't verify that in a simple testscript. Is this an artifact of the perl debugger Or what else is the cause for this
VIEWS ON THIS POST

83

Posted on:

Tuesday 16th October 2012
View Replies!

Perl equivalent of the unix time command

Hi all, Is there a perl equiavelnt of the unix time command to find out how long a given process takes to run google search revealed no help. The only thing I found was the times command, but I don't think it does what I want. (Basically I want to find out how long a given process takes to run
VIEWS ON THIS POST

59

Posted on:

Tuesday 16th October 2012
View Replies!

unix-like 'exec' in perl?

Hi , I want to be able to restart a script under certain conditions, and I was thinking of how I would do this using exec in ksh. exec as I understand it is 'replace the current process with the specified program', where in perl it seems to be 'run the specified program but dont wait for it to finish or care what it does', i.e. it doesnt appear to replace the currently running prog. Am I close fork/exec seems to be a tad different in perl - though probably I'm just not understanding.
VIEWS ON THIS POST

67

Posted on:

Tuesday 16th October 2012
View Replies!

A site for all ypur programming language needs

A complete tutorial for all your programming language needs such as Java, .Net and many more. A one shop site for all your programming language needs http://www.computenetwork.blogspot.com
VIEWS ON THIS POST

99

Posted on:

Tuesday 16th October 2012
View Replies!

creating perl binary using PAR module , execution error under unix

Hai all, I have created a perl executable application using PP,the application includes Curses:UI modules. ###Created the binary file by using the following command $pp myscript.pl ## produces the file a.out ###When I run this file by using command below $a.out ##gives the following error message Can't open Curses/UI/Language/english.pm: No such file or directory at Curses/UI/Language.pm line 96 ## I also tried to compile with -M option $PP -M Curses/UI/Language/english.pm myscript.pl ## produces the file a.out ##when running a.out it also gives the same error message. $ ldd a.out ## shows the following a.out needs: /usr/lib/libsocket.so.2 /usr/lib/libm.so.1 /usr/lib/libc.so.1 /usr/lib/libsocket.so.2 needs: /usr/lib/libresolv.so.1 using perlcc I could compile and run the program without any problem but its not portable. Help me to to comple my perl progam with PP This is perl, v5.8.0 , Curses::UI-0.96, PAR 0.977
VIEWS ON THIS POST

153

Posted on:

Wednesday 17th October 2012
View Replies!

perl and unix command

, I am writting a perl scipt in unix and I will invoking some unix commands in my script. If the first command takes a few minutes to process, how do I make sure the second command do not start until the first command is finished
VIEWS ON THIS POST

76

Posted on:

Saturday 20th October 2012
View Replies!

Re: RE: setting unix command through perl script

On Sat, Apr 19, 2008 at 12:14 AM, Mike Flannigan wrote: > > What ever happened to trimming the posts to a reasonable > number of quoted messages In the old days regulars > would have made your life miserable for this kind of > transgression. I guess since this is a beginners list we > are much more tolerant nowadays. > > > Mike snip > What ever happened to trimming the posts to a reasonable > number of quoted messages In the old days regulars > would have made your life miserable for this kind of > transgression. I guess since this is a beginners list we > are much more tolerant nowadays. > > > Mike snip Yes, this is a beginner's list. It is supposed to be a kinder gentler place. We try to avoid attacking people for style issues. A gentle reminder like "please don't top post" or "duplicate content is unnecessary", however, is occasionally warranted. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read.
VIEWS ON THIS POST

68

Posted on:

Sunday 4th November 2012
View Replies!

can you write to a dos format while in unix

My users are will be uploading a file from unix. I'm trying to save a step by formatting the file while in unix so they don't have to format it with "perl -p -e 's/\r/\r\n/' < $infile > $dosfile" The resulting file after copied to windows did not have a readable format. Is this a process that can only be done after the file transfer Mike
VIEWS ON THIS POST

119

Posted on:

Sunday 4th November 2012
View Replies!

How to perform unix command within perl script?

You can use system() command.See for example:http://www.tek-tips.com/viewthread.cfmqid=1563006http://www.tek-tips.com/viewthread.cfmqid=1551952 , Hi Feherke
VIEWS ON THIS POST

47

Posted on:

Wednesday 7th November 2012
View Replies!

Newbie needs help with IO::Socket (maybe IO::Select)

Hi all I'm playing around with IO::Socket and try to build a small Client/Server App. The Serverpart is working as it's supposed to, but I have some problems with the Clientpart. So I have a couple of Questions: 1. How can a Client react to a Servermessage (Server prints to Socket), when it's not expecting a Servermessage (For example another client connects to the server and kicks the first one or the server is beeing shutdown). If I use the IO::Select approach like in the Serverpart, the Client is blocked and the User can't interact with it anymore. 2. Why does $socket->connected still return the peer-address, eventhough the server is shutdown I'm sure there is a solution for this (probably by using IO::Select), but I can't find any examples of Clientcode using this. Here's what I have (simplified... the "real" Client is using Tk): ------ Star Serverpart ------- #!perl -w use strict; use IO::Socket; use IO::Select; use Data:umper; our $socket; my %users; my $port = 9901; #Socket erstellen my $main_socket = IO::Socket::INET->new(LocalPort => $port, Type => SOCK_STREAM, Reuse => 1, Listen => 1) or die "Kann kein TCP-Server an Port $port sein: @!\n"; my $lesbar = new IO::Select(); $lesbar->add($main_socket); #Pruefen ob ein Client connectet while(1) { my ($neu_lesbare) = IO::Select->select($lesbar, undef, undef, undef); foreach $socket(@{$neu_lesbare}) { if ($socket == $main_socket) { #Neue Verbindung kommt rein... my $neues_socket = $socket->accept(); $lesbar->add($neues_socket); } else { # Hier drin passiert Zeug mit dem Client my $buf = ; if ($buf) { chomp($buf); my @args = split(',', $buf); if ($args[0] eq "AUTH") { auth($args[1], $args[2]); } else { print "Nicht unterstuetzter Command\n"; } } else { # print "Client hat Socket geschlossen\n"; $lesbar->remove($socket); close ($socket); foreach (keys %users) { if ($socket eq $users{$_}{socket}) { print localtime().": User [$_] disconnected\n"; delete $users{$_}; } } } } } } #---- Subroutinen ---# sub write2socket { my $socket = shift; my $text = shift; my $length = sprintf("%04d", length($text)); my $newstring = $length.$text; print $socket "$newstring"; } sub auth { my $usr = shift; my $pass = shift; #Na wer ists denn... my $iaddr = inet_ntoa($socket->peeraddr()); my $rem_host = gethostbyaddr($socket->peeraddr(), AF_INET); my $rem_port = $socket->peerport(); print localtime().": Neue Verbindung von Host: $rem_host [$iaddr:$rem_port]\n"; if (($usr eq "boerni") or ($usr eq "admin")) { if ($users{$usr}) { write2socket ($socket,"User $usr ist bereits verbunden ($users{$usr}{host}:$users{$usr}{port})"); } else { write2socket ($socket,"Verbindung mit User $usr akzeptiert"); $users{$usr}{socket} = $socket; $users{$usr}{host} = $rem_host; $users{$usr}{port} = $rem_port; } } else { write2socket ($socket, "Verbindung abgelehnt"); $lesbar->remove($socket); $socket->shutdown(2); close ($socket); } #print Dumper \%users; #print Dumper \%sockets; foreach (keys %users) { my $handle = $users{$_}{socket}; write2socket($handle, "User $usr hat sich verbunden"); } } ------ End Serverpart ------- ------ Star Clientpart ------- #!perl -w use strict; use IO::Socket; use IO::Select; my $socket; my $usr = "admin"; my $pw = "pass"; my $remote_host = 'localhost'; my $remote_port = 9901; my $svrmsg; my $lesbar = new IO::Select(); $lesbar->add($socket); while () { chomp; if ($_ eq "connect") { connect2server(); } elsif ($_ eq "man_move") { man_move("up"); } elsif ($_ eq "check") { check_status(); } else { print "Nicht unterstuetzt\n"; } } #---- Subroutinen ----# sub connect2server { #---- Socket aufbauen ----# $socket = IO::Socket::INET->new(PeerAddr => $remote_host, PeerPort => $remote_port, Proto => "tcp", Type => SOCK_STREAM) or die "Konnte Verbindung zu $remote_host:$remote_port nicht herstellen: @!\n"; print $socket "AUTH,$usr,$pw\n"; $svrmsg = read_from_sock($socket); print "FROM SERVER: [$svrmsg]\n"; } sub man_move { return if ! $socket; my $direction = shift; print $socket "man_move,$direction\n"; $svrmsg = read_from_sock($socket); print "FROM SERVER: $svrmsg\n"; } sub read_from_sock { my $socket = shift; my $length = 0; my $data; $socket->read($length, 4); $socket->read($data,$length); return $data; } sub check_status { if (! $socket) { print "CHECK: No socket\n"; } elsif ($socket->connected()) { print "CHECK: Connected with ".inet_ntoa($socket->peeraddr())."\n"; } else { print "CHECK: Not connected"; } } ------ End Clientpart -------
VIEWS ON THIS POST

96

Posted on:

Wednesday 7th November 2012
View Replies!

Executing a unix command using file-handle

Dear List I am facing the following problem.While running the below mentioned code open(WHO, "who|")or die "can't open who: $!"; @arr = ; close(WHO); print $arr[2]."\n"; I am getting this output --- root tty3 2008-02-24 12:58 . But when i ...
VIEWS ON THIS POST

70

Posted on:

Saturday 10th November 2012
View Replies!

module needs to know its own path

, within a perl module, I need to access content included with this module, but stored in separate files (WSDL definitions in my case). If my module lies in /usr/lib/perl5/xxx/MyModule.pm, the WDSL files could be stored in /usr/lib/perl5/xxx/MyModule/WSDLs/*.wsdl or similar. ...
VIEWS ON THIS POST

98

Posted on:

Sunday 11th November 2012
View Replies!

FTP ing under unix

all, Trying to use automated FTP in unix. I get the following error: Can't locate Net/FTP.pm in @INC (@INC contains: /usr/perl5/5.6.1/lib/ sun4-solaris-64int /usr/perl5/5.6.1/lib /usr/perl5/site_perl/5.6.1/ sun4-solaris-64int /usr/perl5/site_perl/5.6.1 /usr/perl5/site_perl / usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int /usr/perl5/vendor_perl/ 5.6.1 /usr/perl5/vendor_perl .) Where do I find and how ...
VIEWS ON THIS POST

36

Posted on:

Thursday 15th November 2012
View Replies!

DBD:Excel on unix machine

folks. Is anyone know if its possible to use Excel DBD on unix machine, I tried to do it, after installation of all packges i ran the most popular sctipt in the net: use DBI; $hDb = DBI->connect("DBI:Excel:file=test.xls") or ...
VIEWS ON THIS POST

30

Posted on:

Thursday 15th November 2012
View Replies!

To Jan Dubois, owner of the libwin32 module

Jan, I downloaded your module to my WindowsXP system, because I needed the Win32::Process module and the function KillProcess. Because I found out that the TerminateProcess Win32 API function does not work for every process I made some changes ...
VIEWS ON THIS POST

68

Posted on:

Thursday 15th November 2012
View Replies!

getting 804.027 for win32?

Question: Someone suggested www.bribes.org/perl/ppms/ for getting this version of the module. Problem is, even after adding it to ActivePerl in the ppm repositories, I can't seem to get it to upgrade the 804.026. The 'install' command is saying it's up ...
VIEWS ON THIS POST

59

Posted on:

Thursday 15th November 2012
View Replies!

Re: win32 SDL

Golgi ! writes: >Do any of the SDL or OpenGL Perl scripts work for Windows My OpenGL tests worked on Windows. >The test scripts >that come with the packages always fail, "Can't locate loadable object...," >if I simply copy ...
VIEWS ON THIS POST

55

Posted on:

Monday 19th November 2012
View Replies!