Search Results

Search found 11458 results on 459 pages for 'perl thread'.

Page 2/459 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Why is Perl's smart-match operator considered broken?

    - by Sean McMillan
    I've seen a number of comments across the web Perl's smart-match operator is broken. I know it originally was part of Perl 6, then was implemented in Perl 5.10 off of an old version of the spec, and was then corrected in 5.10.1 to match the current Perl 6 spec. Is the problem fixed in 5.10.1+, or are there other problems with the smart-match operator that make it troublesome in practice? What are the problems? Is there a yet-more-updated version (Perl 6, perhaps) that fixes the problems?

    Read the article

  • How should I distribute a pre-built perl module, and what version of perl do I build for?

    - by Mike Ellery
    This is probably a multi-part question. Background: we have a native (c++) library that is part of our application and we have managed to use SWIG to generate a perl wrapper for this library. We'd now like to distribute this perl module as part of our application. My first question - how should I distribute this module? Is there a standard way to package pre-built perl modules? I know there is ppm for the ActiveState distro, but I also need to distribute this for linux systems. I'm not even sure what files are required to distribute, but I'm guessing it's the pm and so files, at a minimum. My next question - it looks like I might need to build my module project for each version of perl that I want to support. How do I know which perl versions I should build for? Are there any standard guidelines... or better yet, a way to build a package that will work with multiple versions of perl? Sorry if my questions make no sense - I'm fairly new to the compiled module aspects of perl. CLARIFICATION: the underlying compiled source is proprietary (closed source), so I can't just ship source code and the appropriate make artifacts for the package. Wish I could, but it's not going to happen in this case. Thus, I need a sane scheme for packaging prebuilt binary files for my module.

    Read the article

  • Python vs. Perl in ten years time

    - by Richard
    If you were starting learning a new language today, for scripting and doing "various stuff" with it (from making useful programs to it being glue to several command line programs), would you go with Python or Perl (or some third option, although the battle usually comes to these two)? I've never much used dynamic languages at all, having been able to do everything I needed in traditional static ones. Did some scripting in Perl a couple of years ago, but that was more of a momentary fling, than an attempt to learn it well. Now I've some free time, and have decided to go along with one of these two, and play a little with them. I like Perl's syntax, but Python does seem to be taking rather big steps on overtaking that area. What do you think, which one is more worth learning and why? Also, what do you think, what will be Python's future in about 10 years ... will it overtake Perl and other scripting languages's as a dominant tool for that kind of work (I more often than not find it being implemented in various applications I'm using - for internal scripting and automating loading of data and similar operations), or will it find a balance and coexist along others (Perl)? What is its current "momentum" - does it comes by default with Linux distributions, as Perl does, or does it needs to be installed separately every time? Is it a language which can be expected "to just be there"?

    Read the article

  • perl and sed how to combine if and unless in perl

    - by yael
    I have the two perl command perl -pe "s/\b$a\b/$b/g if m/param1 /" test and perl -pe "s/\b$a\b/$b/g unless /^#/" test how to use combine the if m/somthing/ and the unless /something/ for example [root@localhost tmp]# perl -pe "s/\b$a\b/$b/g if m/param1/ unless /^#/" test syntax error at -e line 1, near "m/param1/ unless" but its now work THX

    Read the article

  • Perl Scripts Seem to be Caching?

    - by Ben Liyanage
    I'm running a perl script via mod_perl with Apache. I am trying to parse parameters in a restful fashion (aka GET www.domain.com/rest.pl/Object/ID). If I specify the ID like this: GET www.domain.com/rest.pl/Object/1234 I will get object 1234 back as a result as expected. However, if I specify an incorrect hacked url like this GET www.domain.com/rest.pl/Object/123 I will also get back object 1234. I am pretty sure that the issue in this question is happening so I packaged up my method and invoked it from my core script out of the package. Even after that I am still seeing the threads returning seemingly cached data. One of the recommendations in the aforementioned article is to replace my with our. My impression from reading up on our vs my was that our is global and my is local. My assumption is the the local variable gets reinitialized each time. That said, like in my code example below I am resetting the variables each time with new values. Apache Perl Configuration is set up like this: PerlModule ModPerl::Registry <Directory /var/www/html/perl/> SetHandler perl-script PerlHandler ModPerl::Registry Options +ExecCGI </Directory> Here is the perl script getting invoked directly: #!/usr/bin/perl -w use strict; use warnings; use Rest; Rest::init(); Here is my package Rest. This file contains various functions for handling the rest requests. #!/usr/bin/perl -w package Rest; use strict; # Other useful packages declared here. our @EXPORT = qw( init ); our $q = CGI->new; sub GET($$) { my ($path, $code) = @_; return unless $q->request_method eq 'GET' or $q->request_method eq 'HEAD'; return unless $q->path_info =~ $path; $code->(); exit; } sub init() { eval { GET qr{^/ZonesByCustomer/(.+)$} => sub { Rest::Zone->ZonesByCustomer($1); } } } # packages must return 1 1; As a side note, I don't completely understand how this eval statement works, or what string is getting parsed by the qr command. This script was largely taken from this example for setting up a rest based web service with perl. I suspect it is getting pulled from that magical $_ variable, but I'm not sure if it is, or what it is getting populated with (clearly the query string or url, but it only seems to be part of it?). Here is my package Rest::Zone, which will contain the meat of the functional actions. I'm leaving out the specifics of how I'm manipulating the data because it is working and leaving this as an abstract stub. #!/usr/bin/perl -w package Rest::Zone; sub ZonesByCustomer($) { my ($className, $ObjectID) = @_; my $q = CGI->new; print $q->header(-status=>200, -type=>'text/xml',expires => 'now', -Cache_control => 'no-cache', -Pragma => 'no-cache'); my $objectXML = "<xml><object>" . $ObjectID . "</object></xml>"; print $objectXML; } # packages must return 1 1; What is going on here? Why do I keep getting stale or cached values?

    Read the article

  • Is there a way to avoid putting the Perl version number into the "use lib" line for Perl modules in

    - by Kinopiko
    I am trying to install some Perl modules into a non-standard location, let's call it /non/standard/location. In the script which uses the module, it seems to be necessary to specify a long directory path including the version of Perl, like so: #!/usr/local/bin/perl use lib '/non/standard/location/lib/perl5/site_perl/5.8.9/'; use A::B; Is there any use lib or other statement which I can use which is not so long and verbose, and which does not include the actual version of Perl, in order that I don't have to go back and edit this out of the program if the version of Perl is upgraded?

    Read the article

  • perl: Run remote perl script through SSH and query environment variables on remote machine

    - by kakyo
    I'm running a perl script through SSH, in the perl script I query environment variables using $ENV{MY_VAR_NAME} and it works fine when run locally. But through SSH, all environment variables become unset. I also tried to run system("source ~/.bash_profile"); at the beginning of my script to no avail. Any tips? EDIT: Rephrasing my question. I have machine A and B. I ran my perl on machine B, trying to get the environment variables on B and it worked. Then I ssh from A to B running the same script, i.e., using this code ssh user@B perl myscript.pl This time the environment variables on B are all blank. Any tips? UPDATE: I found that running the above script, ~/.bashrc on Machine B was invoked, but after setting environment variables in ~/.bashrc, run the above command again and still I don't see any environment variables. Also, if my perl script contains only echo $ENV{PATH} Then I get /usr/bin:/bin:/usr/sbin:/sbin

    Read the article

  • Uninstall Perl 5.10 and Install 5.8 on Ubuntu 10.04

    - by user48848
    I was using Ubuntu 8.04 with installed Perl 5.8.8. I had installed Bugzilla 3.4.4 with some custom scripts and it was working fine. I had to upgrade Ubuntu from 8.04 to 10.04 and automatically Perl is also upgraded from Perl 5.8 to 5.10. Now, accessing Bugzilla displays an error message related to Perl module. While trying to run checksetup.pl, I am getting the following error message: root@cvsnew:/var/www/bugzilla-3.4# perl checksetup.pl * This is Bugzilla 3.4.3 on perl 5.10.1 * Running on Linux 2.6.32-24-generic-pae #39-Ubuntu SMP Wed Jul 28 07:39:26 UTC 2010 Checking perl modules... Checking for CGI.pm (v3.33) ok: found v3.48 perl: symbol lookup error: lib/i486-linux-gnu-thread-multi/auto/Digest/SHA/SHA.so: undefined symbol: Perl_Tstack_sp_ptr Accessing Bugzilla throws : "500 Internal Server Error". I explored this issue and found that this issue has come up because upgrading Ubuntu upgrades Perl 5.8 to 5.10 automatically. It seems like Perl 5.10.1 isn't binary compatible with the previous. Now, I want to uninstall Perl 5.10.1 and Install Perl 5.8.8 on my Ubuntu 10.04 box. I will appreciate if someone has already done that or share the required steps/commands to do it.

    Read the article

  • Basic web architecture : Perl -> PHP

    - by Sunny Jim
    This is an architecture question. If there is a better forum, please redirect me. Apologies in advance. Essentially every website is built around a relational database, right? When a user uploads form data, that data is stored in a table. The problem is that the table structure(s) need to be modified whenever the website form is modified. Although I understand that modern web frameworks work around this problem by automatically building forms based on the table structure. For the last 20 years, I have been building websites using Perl. When I first encountered this problem, the easiest solution was to save serialized Perl objects as data BLOBS. After XML's introduction, this solution worked even better because XML is so effective for representing arbitrary data. This approach is consistent with the original Perl principles of Hubris, Laziness, and Impatience and I'm pretty committed to it. Obviously, the biggest drawback is that this solution locks me into the Perl interpreter. So instead, I've just completed a prototype of a universal RDB table. The prototype is written in Perl but porting it to PHP will be a good chance to develop those skills. The principal is based on the XML::Dumper module, which converts arbitrary Perl data structures into uniform XML. With my approach, each XML node is stored as a table record. I underestimated this undertaking and rolled something up myself. But the effort allows me to discuss the basic design instead of implementation details. As mentioned, I'm pretty committed to this approach of using flexible data structures. It's been successfully deployed on many websites, large, and complex. But are there any drawbacks I've overlooked? I rolled my own. Are other people taking a similar approach to their data? What kinds of solutions are available? I have not abandoned my dream of eventually contributing something useful to the worldwide community. In order to proceed, the next step would be peer review. How does one pursue that effort? Thanks! -Jim

    Read the article

  • How to kill main thread from sub thread in Jython

    - by JeffGoetz
    I have a script that creates a thread which after 60 seconds (this thread) needs to kill the main thread. I`m not sure what command I can use to kill the main thread. I'm using Jython 2.5.1 and Thread.interrupt_main doesn't work. Here is the code: import threading def exitFunct(): #exit code here t = threading.Timer(60.0, exitFunct) t.start() for i in range(1, 3000): print i

    Read the article

  • difference between thread.start() and executor.submit(thread)

    - by Mrityunjay
    hi, i am facing a problem regarding the thread. I am having a class which implements runnable, and i can use thread.start() method on that class. My question is i have one more class java.util.concurrent.ExecutorService in which i can call executor.submit(thread).. can anyone please tell me what is the difference between thread.start() and executor.submit(thread)...

    Read the article

  • Code to connect to remote server using perl

    - by user304852
    I'm written small code to connect to remote server using perl but observing error messages #!/usr/bin/perl -w use Net::Telnet; $telnet = new Net::Telnet ( Timeout=>60, Errmode=>'die'); $telnet->open('192.168.50.40'); $telnet->waitfor('/login:/'); $telnet->print('queen'); $telnet->waitfor('/password:/'); $telnet->print('kinG!'); $telnet->waitfor('/:/'); $telnet->print('vol >> C:\result.txt'); $telnet->waitfor('/:/'); $telnet->cmd("mkdir vol"); $telnet->print('mkdir vol234'); $telnet->cmd("mkdir vol1"); $telnet->waitfor('/\$ $/i'); $telnet->print('whoamI'); print $output; But while running i'm getting following errors C:\>perl -c E:\test\net.pl E:\test\net.pl syntax OK C:\>perl E:\test\net.pl command timed-out at E:\test\net.pl line 13 C:\> Help me in this regard.. i'm not much aware of perl

    Read the article

  • codepad.org Perl runner limitations

    - by Lemurik
    Sometimes I see people use http://codepad.org as a way to quickly run/test their Perl snippets (it supports doing that with a wide variety of languages, from C to Scheme to Perl). It's pretty obious that there must be some limitations as to what code/features can be tested with codepad - does anyone know what those limitations are for Perl runner? I'll get the ball rolling on my own observation: not every CPAN module is avialable :(

    Read the article

  • perl + export param in to perl syntax in shell script

    - by yael
    hi I have the following script that replace a param to b param and match only the c parameter in line how to change the perl syntax: "if /$c/" in order to export c param to the follwoing perl syntax !/bin/bash export a='@d&' export b='new text' export c='bla bla' echo $c | perl -pe 'next if /^#/; s/(^|\s)\Q$ENV{a}\E(\s|$)/$1$ENV{b}$2/ if /$c/'

    Read the article

  • Thread.Interrupt Is Evil

    - by Alois Kraus
    Recently I have found an interesting issue with Thread.Interrupt during application shutdown. Some application was crashing once a week and we had not really a clue what was the issue. Since it happened not very often it was left as is until we have got some memory dumps during the crash. A memory dump usually means WindDbg which I really like to use (I know I am one of the very few fans of it).  After a quick analysis I did find that the main thread already had exited and the thread with the crash was stuck in a Monitor.Wait. Strange Indeed. Running the application a few thousand times under the debugger would potentially not have shown me what the reason was so I decided to what I call constructive debugging. I did create a simple Console application project and try to simulate the exact circumstances when the crash did happen from the information I have via memory dump and source code reading. The thread that was  crashing was actually MS code from an old version of the Microsoft Caching Application Block. From reading the code I could conclude that the main thread did call the Dispose method on the CacheManger class which did call Thread.Interrupt on the cache scavenger thread which was just waiting for work to do. My first version of the repro looked like this   static void Main(string[] args) { Thread t = new Thread(ThreadFunc) { IsBackground = true, Name = "Test Thread" }; t.Start(); Console.WriteLine("Interrupt Thread"); t.Interrupt(); } static void ThreadFunc() { while (true) { object value = Dequeue(); // block until unblocked or awaken via ThreadInterruptedException } } static object WaitObject = new object(); static object Dequeue() { object lret = "got value"; try { lock (WaitObject) { } } catch (ThreadInterruptedException) { Console.WriteLine("Got ThreadInterruptException"); lret = null; } return lret; } I do start a background thread and call Thread.Interrupt on it and then directly let the application terminate. The thread in the meantime does plenty of Monitor.Enter/Leave calls to simulate work on it. This first version did not crash. So I need to dig deeper. From the memory dump I did know that the finalizer thread was doing just some critical finalizers which were closing file handles. Ok lets add some long running finalizers to the sample. class FinalizableObject : CriticalFinalizerObject { ~FinalizableObject() { Console.WriteLine("Hi we are waiting to finalize now and block the finalizer thread for 5s."); Thread.Sleep(5000); } } class Program { static void Main(string[] args) { FinalizableObject fin = new FinalizableObject(); Thread t = new Thread(ThreadFunc) { IsBackground = true, Name = "Test Thread" }; t.Start(); Console.WriteLine("Interrupt Thread"); t.Interrupt(); GC.KeepAlive(fin); // prevent finalizing it too early // After leaving main the other thread is woken up via Thread.Abort // while we are finalizing. This causes a stackoverflow in the CLR ThreadAbortException handling at this time. } With this changed Main method and a blocking critical finalizer I did get my crash just like the real application. The funny thing is that this is actually a CLR bug. When the main method is left the CLR does suspend all threads except the finalizer thread and declares all objects as garbage. After the normal finalizers were called the critical finalizers are executed to e.g. free OS handles (usually). Remember that I did call Thread.Interrupt as one of the last methods in the Main method. The Interrupt method is actually asynchronous and does wake a thread up and throws a ThreadInterruptedException only once unlike Thread.Abort which does rethrow the exception when an exception handling clause is left. It seems that the CLR does not expect that a frozen thread does wake up again while the critical finalizers are executed. While trying to raise a ThreadInterrupedException the CLR goes down with an stack overflow. Ups not so nice. Why has this nobody noticed for years is my next question. As it turned out this error does only happen on the CLR for .NET 4.0 (x86 and x64). It does not show up in earlier or later versions of the CLR. I have reported this issue on connect here but so far it was not confirmed as a CLR bug. But I would be surprised if my console application was to blame for a stack overflow in my test thread in a Monitor.Wait call. What is the moral of this story? Thread.Abort is evil but Thread.Interrupt is too. It is so evil that even the CLR of .NET 4.0 contains a race condition during the CLR shutdown. When the CLR gurus can get it wrong the chances are high that you get it wrong too when you use this constructs. If you do not believe me see what Patrick Smacchia does blog about Thread.Abort and List.Sort. Not only the CLR creators can get it wrong. The BCL writers do sometimes have a hard time with correct exception handling as well. If you do tell me that you use Thread.Abort frequently and never had problems with it I do suspect that you do not have looked deep enough into your application to find such sporadic errors.

    Read the article

  • How to check if Thread finished execution

    - by user295502
    I have following problem: I want to check (C#) if thread has finished execution, i.e. if the thread method returned. What I do now is call Thread.Join(1), but this gives 1 ms delay. Is there any way to simply check if thread finished. Inspecting Thread.ThreadState just seems too cumbersome.

    Read the article

  • still about perl vs python but (to me) slightly different from what has been asked [closed]

    - by B Chen
    Being a newbie to coding, I read from this site that Perl is still as viable as it has been, while Python, quoted from someone else's post, is good but just "snake oil" (not sure what this refers to exactly though). So from the responses in that post, I got the gist that Perl is good and worthy to learn. My question is - pardon me for phrasing it in this "non-programmer's" way - Which one should I learn FIRST? (I am actually currently learning R) Here below is the background info - (a) I will be using it mostly for data mining and statistics analysis (b) Will there be this "first" and "later" issue with learning either Perl or Python? That is, after I become competent with one language, would there be a need to learn the second one (for a similar task??) (c) If there should be circumstances where I must learn the second one, would learning Perl FIRST be better than learning Python? I hope to learn as much from exchanging info here, so please help provide with more than just "it depends" type of info. Great many thanks to all who choose to respond to my query.

    Read the article

  • Running a batch file from Perl (Activestate perl in Windows)

    - by Jithesh
    I have a Perl program which does something like below: #!perl use strict; use warnings; my $exe = "C:\\project\\set_env_and_run.bat"; my $arg1 = "\\\\Server\\share\\folder1"; my $arg2 = "D:\\output\\folder1"; my $cmd = "$exe \"$arg1\" \"$arg2\""; my $status = system("$cmd > c:\\tmp\out.txt 2>&1"); print "$status\n"; I am calling this Perl code in an eval block. When invoked, i get the status printed as 0, but the batch file has not actually executed. What would be the reason for this? Thanks, Jits

    Read the article

  • Installing Perl modules and dependencies with non-root and without CPAN [migrated]

    - by Eegabooga
    I have been writing Perl scripts for my work and the machine that I have been given to work on makes installing Perl modules difficult: We cannot have gcc on my machine for security reasons, so I cannot use CPAN to install modules, for most modules. I do not have access to the root account. Usually, when I want to install a module, I put in a request and I have to wait a day or two before it gets installed. I know that nobody would have a problem with me installing them myself, so to save everyone's time and my sanity I would like to install them myself. It's just an issue of how to best do that. I have talked to various people and they said to use an RPM to install them (to get around not having gcc). However, when trying to install modules from RPMs, it does not handle the dependencies so I would manually need to handle the dependencies, which could take a while. How can I best install Perl modules with these limitations?

    Read the article

  • Synchronization between game logic thread and rendering thread

    - by user782220
    How does one separate game logic and rendering? I know there seem to already be questions on here asking exactly that but the answers are not satisfactory to me. From what I understand so far the point of separating them into different threads is so that game logic can start running for the next tick immediately instead of waiting for the next vsync where rendering finally returns from the swapbuffer call its been blocking on. But specifically what data structures are used to prevent race conditions between the game logic thread and the rendering thread. Presumably the rendering thread needs access to various variables to figure out what to draw, but game logic could be updating these same variables. Is there a de facto standard technique for handling this problem. Maybe like copy the data needed by the rendering thread after every execution of the game logic. Whatever the solution is will the overhead of synchronization or whatever be less than just running everything single threaded?

    Read the article

  • Checking for cross-site scripting vulnerabilities in Perl web applications

    - by David Scholefield
    I'm putting together some notes for a dev team on how to write secure Perl code - especially taking into account the current OWASP top 10 web application vulnerabilities. For cross-site scripting I've included information on ensuring that all output to the browser is checked and escaped where necessary, but I'm looking for more automated mechanisms that would mean a developer doesn't have to think about every output statement and, potentially, miss one. Perl's 'taint' function sounds like it should be a help because it distrusts all user input, but it doesn't complain on tainted data being output to the browser. Apart from checking all output statements individually (probably by calling a generic sanitizing function) does anyone have any ideas on how Perl can help with this with existing libraries or techniques?

    Read the article

  • C# Thread Pool Cross-Thread Communication

    - by Goober
    The Scenario I have a windows forms application containing a MAINFORM with a listbox on it. The MAINFORM also has a THREAD POOL that creates new threads and fires them off to do lots of different bits of processing. Whilst each of these different worker threads is doing its job, I want to report this progress back to my MAINFORM, however, I can't because it requires Cross-Thread communication. Progress So far all of the tutorials etc. that I have seen relating to this topic involve custom(ish) threading implementations, whereas I literally have a fairly basic(ish) standard THREAD POOL implementation. Since I don't want to really modify any of my code (since the application runs like a beast with no quarms) - I'm after some advice as to how I can go about doing this cross-thread communication. ALTERNATIVELY - How to implement a different "LOGTOSCREEN" method altogether (obviously still bearing in mind the cross-thread communication thing). WARNING: I use this website at work, where we are locked down to IE6 only, and the javascript thus fails, meaning I cannot click accept on any answers during work, and thus my acceptance rate is low. I can't do anything about it I'm afraid, sorry. EDIT: I DO NOT HAVE INSTALL RIGHTS ON MY COMPUTER AT WORK. I do have firefox but the proxy at work fails when using this site on firefox. FURTHER EDIT: I DO NOT WANT TO CHANGE MY THREADING IMPLEMENTATION. AT ALL! - Accept to enable cross-thread communication....why would a backgroundworker help here!?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >