Search Results

Search found 168 results on 7 pages for 'cpan'.

Page 6/7 | < Previous Page | 2 3 4 5 6 7  | Next Page >

  • Does a Perl module know where it is installed?

    - by CoffeeMonster
    Hi Perl programmers, I have started creating a Perl package that contains a default email template. The MANIFEST looks something like: SendMyEmail.pm SendMyEmail/defualt_email.tt Currently I know where the module (and the template) are - but does the module itself know where on disk it is? So could the module find the default template without my help? # This is what I would like to do. package SendMyEmail; sub new { my ($self, $template) = @_; $template ||= $dir_of_SendMyEmail .'/SendMyEmail/default_email.tt'; # ?? } Is there a better way of including a templates text, or a better place to put the template? Any references to CPAN modules that do something similar would be welcome. Thanks in advance.

    Read the article

  • perl Date::Manip array problem

    - by medalto
    im using Date::Manip http://search.cpan.org/~sbeck/Date-Manip-6.11/lib/Date/Manip.pod for a variety of things and want to create an array of days of the month i think I need @date = &ParseRecur("2010:4:0:0:0:0:0"); but it doesnt do it . ive read & reread the man page but cant get the syntax. @date = &ParseRecur("2010:4:0:1:0:0:0"); @date = &ParseRecur("2010:4:0:1*:0:0:0"); dont work either !

    Read the article

  • Ruby: Parse Excel 95-2003 files?

    - by Larry K
    Is there a way to read Excel 97-2003 files from Ruby? Background I'm currently using the Ruby Gem parseexcel -- http://raa.ruby-lang.org/project/parseexcel/ But it is an old port of the perl module. It works fine, but the latest format it parses is Excel 95. And guess what? Excel 2007 will not produce the Excel 95 format. John McNamara has taken over duties as the maintainer for the Perl Excel parser, see http://search.cpan.org/~jmcnamara/Spreadsheet-ParseExcel-0.55/lib/Spreadsheet/ParseExcel.pm The current version will parse Excel 95-2003 files. But is there a port to Ruby? My other thought is to build some Ruby to Perl glue code to enable use of the Perl library itself from Ruby. Eg, see http://stackoverflow.com/questions/451636/whats-the-best-way-to-export-utf8-data-into-excel/620612#620612 (I think it would be much faster to write the glue code than to port the parser.) Thanks, Larry

    Read the article

  • Is there a way to test if a scalar has been stringified or not?

    - by Yobert
    I am writing a thing to output something similar to JSON, from a perl structure. I want the quoting to behave like this: "string" outputs "string" "05" outputs "05" "5" outputs "5" 5 outputs 5 05 outputs 5, or 05 would be acceptable JSON::XS handles this by testing if a scalar has been "stringified" or not, which I think is very cool. But I can't find a way to do this test myself without writing XS, which I'd rather avoid. Is this possible? I can't find this anywhere on CPAN without finding vast pedantry about Scalar::Util::looks_like_number, etc which completely isn't what I want. The only stopgap I can find is Devel::Peek, which feels evil. And also, just like JSON::XS, I'm fine with this secenario: my $a = 5; print $a."\n"; # now $a outputs "5" instead of 5)

    Read the article

  • Perl date function/module able to understand full unabbreviated months.

    - by s2cuts
    Let's say I read in a string from somewhere that contains a date, and it's date format doesn't abbreviate the month. Is there a module that can handle reading it in, and then outputting it to whichever format I choose? I've taken a quick look through CPAN, and every date module I looked at didn't seem to accommodate an unabbreviated month. Thanks for any help EDIT: As an example, say we have a string like this; "2 February 1988". Now we want to convert it into "1988-02-02" (YYYY-MM-DD).

    Read the article

  • Getting Perl DBD::mysql working on OS X 10.7?

    - by Bart B
    I can't seem to get Perl & MySQL to talk to each other on OS X 10.7 Lion. I did all the installs by the book, I used Oracle's PKG installer for the latest MySQL Community Server, and I installed DBI and DBD::mysql via CPAN. There were not problems at all during the install, but, when I try to USE DBD::mysql to connect to my local DB server I get the following error: install_driver(mysql) failed: Can't load '/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle, 1): Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib Referenced from: /Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Reason: image not found at /System/Library/Perl/5.12/darwin-thread-multi-2level/DynaLoader.pm line 204. at (eval 3) line 3 Compilation failed in require at (eval 3) line 3. Perhaps a required shared library or dll isn't installed where expected After a lot of googling all I could find were suggested hacks, so I gave this one a go: http://arkoftech.wordpress.com/2011/02/10/fixing-dbdmysql-for-mysql-5-5-89-under-macos-10-6-x/ I had to update some of the paths in the instructions since on Lion it's Perl 5.12 not 5.10. After doing that I got a new error: dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Expected in: flat namespace dyld: Symbol not found: _mysql_init Referenced from: /Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle Expected in: flat namespace Trace/BPT trap: 5 There must be a simple way to get MySQL & Perl working on OS X? - HELP!

    Read the article

  • Perl Curses::UI

    - by user353211
    I am trying to use the library Curses:UI from http://search.cpan.org/dist/Curses-UI/ to build a UI on linux karmic. I can create a simple user interface e.g.: #!usr/usr/bin/perl use strict; use Curses; use Curses::UI; $ui = new Curses::UI(-color_support=1,-clear_on_exit=1,-intellidraw=1); my $window = $ui-add('window', 'Window',intellidraw=1); my $message = $window-add(-text="Hello!",-intellidraw=1); $window-focus(); $ui-mainloop(); Question: I need some way to communicate informatio to the UI i.e. I have a loop which will wait for message to come and change the text in window. Once this message comes a popup will be displayed. Attempt: my $ui = new Curses::UI(-color_support=1,-clear_on_exit=1,-intellidraw=1); my $window = $ui-add('window', 'Window',intellidraw=1); my $message = $window-add(-text="Hello!",-intellidraw=1); pseudocode while(true) #implemented a function to wait { popup($window-text("Hello how are you?")); } $window-focus(); $ui-mainloop(); Problem: The above does not work. I am given a dark screen where my message is displayed. I have read the documentation and when I relocate : $ui-mainloop() above the while loop I am given the user interface but now nothing communicates to the window. Coincise Question: I need some way of displaying the user interface wait for inputs and display messages. Could anyone please help me on this? Thank you!

    Read the article

  • Perl Lingua giving weird error on install

    - by user299306
    I am trying to install perl Lingua onto a unix system (ubuntu, latest version). Of course I am root. when I go into the package to install using 'perl Makefile.pl' I get this dumb error: [root@csisl27 Lingua-Lid-0.01]# perl Makefile.PL /opt/ls//lib does not exist at Makefile.PL line 48. I have tried playing with the path on line 48, nothing changes, here is what line 48-50 looks like: Line 48: die "$BASE/lib does not exist" unless -d "$BASE/lib"; Line 49: die "$BASE/include does not exist" unless -d "$BASE/include"; Line 50: die "lid.h is missing in $BASE/include" unless -e "$BASE/includ/lid.h"; The variable $BASE is declared as this: $BASE = "/opt/ls/" if ($^O eq "linux" or $^O eq "solaris"); $BASE = "/usr/local/" if ($^O eq "freebsd"); $BASE = $ENV{LID_BASE_DIR} if (defined $ENV{LID_BASE_DIR}); Now the perl program I am trying to write simply look like this (just my base): #!/usr/bin/perl use Lingua::LinkParser; use strict; print "Hello world!\n"; When I run this trying to use Lingua, here is my error: [root@csisl27 assign4]# ./perl_parser_1.pl Can't locate Lingua/LinkParser.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/5.10.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl .) at ./perl_parser_1.pl line 3. BEGIN failed--compilation aborted at ./perl_parser_1.pl line 3. Tried insalling this from cpan, still doesn't properly work.

    Read the article

  • Singleton Roles in Moose

    - by mjn12
    I am attempting to write a singleton role using Perl and Moose. I understand a MooseX::Singleton module is available but there is always resistance when requiring another CPAN module for our project. After trying this and having a little trouble I would like to understand WHY my method is not working. The singleton role I have written is as follows: package Singleton; use Moose::Role; my $_singleInstance; around 'new' => sub { my $orig = shift; my $class = shift; if (not defined $_singleInstance ){ $_singleInstance = $class->$orig(@_); } return $_singleInstance; }; sub getInstance { return __PACKAGE__->new(); } 1; This appears to work find when only one class uses the singleton role. However when two classes (ClassA and ClassB for example) both consume the Singleton role it appears as they are both referring to a shared $_singleInstance variable. If I call ClassA-getInstance it returns a reference to a ClassA object. If I call ClassB-getInstance sometime later in the same script it returns a reference to an object of type ClassA (even though I clearly called the getInstance method for ClassB). If I dont use a role and actually copy and paste the code from the Singleton role into ClassA and ClassB it appears to work fine. Whats going on here?

    Read the article

  • Is there a Standard or Best Practice for Perl Programs, as opposed to Perl Modules?

    - by swestrup
    I've written any number of perl modules in the past, and more than a few stand-alone perl programs, but I've never released a multi-file perl program into the wild before. I have a perl program that is almost at the beta stage and is going to be released open source. It requires a number of data files, as well as some external perl modules -- some I've written myself, and some from CPAN -- that I'll have to bundle with it so as to ensure that someone can just download my program and install it without worrying about hunting for obscure modules. So, it sounds to me like I need to write an installer to copy all the files to standard locations so that a user can easily install everything. The trouble is, I have no idea what the standard practice would be for this. I have found lots of tutorials on perl module standards, but none on perl program standards. Does anyone have any pointers to standard paths, installation proceedures, etc, for perl programs? This is going to be complicated by the fact that the program is multi-platform. I've been testing it in Linux, but its designed to work equally well in Windows.

    Read the article

  • Should a Perl constructor return an undef or a "invalid" object?

    - by DVK
    Question: What is considered to be "Best practice" - and why - of handling errors in a constructor?. "Best Practice" can be a quote from Schwartz, or 50% of CPAN modules use it, etc...; but I'm happy with well reasoned opinion from anyone even if it explains why the common best practice is not really the best approach. As far as my own view of the topic (informed by software development in Perl for many years), I have seen three main approaches to error handling in a perl module (listed from best to worst in my opinion): Construct an object, set an invalid flag (usually "is_valid" method). Often coupled with setting error message via your class's error handling. Pros: Allows for standard (compared to other method calls) error handling as it allows to use $obj->errors() type calls after a bad constructor just like after any other method call. Allows for additional info to be passed (e.g. 1 error, warnings, etc...) Allows for lightweight "redo"/"fixme" functionality, In other words, if the object that is constructed is very heavy, with many complex attributes that are 100% always OK, and the only reason it is not valid is because someone entered an incorrect date, you can simply do "$obj->setDate()" instead of the overhead of re-executing entire constructor again. This pattern is not always needed, but can be enormously useful in the right design. Cons: None that I'm aware of. Return "undef". Cons: Can not achieve any of the Pros of the first solution (per-object error messages outside of global variables and lightweight "fixme" capability for heavy objects). Die inside the constructor. Outside of some very narrow edge cases, I personally consider this an awful choice for too many reasons to list on the margins of this question. UPDATE: Just to be clear, I consider the (otherwise very worthy and a great design) solution of having very simple constructor that can't fail at all and a heavy initializer method where all the error checking occurs to be merely a subset of either case #1 (if initializer sets error flags) or case #3 (if initializer dies) for the purposes of this question. Obviously, choosing such a design, you automatically reject option #2.

    Read the article

  • Tailing 'Jobs' with Perl under mod_perl

    - by Matthew
    Hi everyone, I've got this project running under mod_perl shows some information on a host. On this page is a text box with a dropdown that allows users to ping/nslookup/traceroute the host. The output is shown in the text box like a tail -f. It works great under CGI. When the user requests a ping it would make an AJAX call to the server, where it essentially starts the ping with the output going to a temp file. Then subsequent ajax calls would 'tail' the file so that the output was updated until the ping finished. Once the job finished, the temp file would be removed. However, under mod_perl no matter what I do I can's stop it from creating zombie processes. I've tried everything, double forking, using IPC::Run etc. In the end, system calls are not encouraged under mod_perl. So my question is, maybe there's a better way to do this? Is there a CPAN module available for creating command line jobs and tailing output that will work under mod_perl? I'm just looking for some suggestions. I know I could probably create some sort of 'job' daemon that I signal with details and get updates from. It would run the commands and keep track of their status etc. But is there a simpler way? Thanks in advance.

    Read the article

  • Is there a Standard or Best Practice for Perl Progams, as opposed to Perl Modules?

    - by swestrup
    I've written any number of perl modules in the past, and more than a few stand-alone perl programs, but I've never released a multi-file perl program into the wild before. I have a perl program that is almost at the beta stage and is going to be released open source. It requires a number of data files, as well as some external perl modules -- some I've written myself, and some from CPAN -- that I'll have to bundle with it so as to ensure that someone can just download my program and install it without worrying about hunting for obscure modules. So, it sounds to me like I need to write an installer to copy all the files to standard locations so that a user can easily install everything. The trouble is, I have no idea what the standard practice would be for this. I have found lots of tutorials on perl module standards, but none on perl program standards. Does anyone have any pointers to standard paths, installation proceedures, etc, for perl programs? This is going to be complicated by the fact that the program is multi-platform. I've been testing it in Linux, but its designed to work equally well in Windows.

    Read the article

  • Perl: Process Communcation

    - by Shiftbit
    Can anyone explain how I can successfully get my process communicating. I find the perldoc on IPC confusing. What I have so far is: $| = 1; $SIG{CHLD} = {wait}; my $parentPid = $$; if ($pid = fork();) ) { if ($pid == 0) { pipe($parentPid, $$); open PARENT, "<$parentPid"; while (<PARENT>) { print $_; } close PARENT; exit(); } else { pipe($parentPid, $pid); open CHILD, ">$pid"; or error("\nError opening: childPid\nRef: $!\n"); open (FH, "<list") or error("\nError opening: list\nRef: $!\n"); while(<FH>) { print CHILD, $_; } close FH or error("\nError closing: list\nRef: $!\n"); close CHILD or error("\nError closing: childPid\nRef: $!\n); } else { error("\nError forking\nRef: $!\n"); } First Question is what does Perldoc pipe mean by READHANDLE, WRITEHANDLE? Second Questions is can I implement a solution without relying on CPAN or other modules?

    Read the article

  • How can I filter a Perl DBIx recordset with 2 conditions on the same column?

    - by BrianH
    I'm getting my feet wet in DBIx::Class - loving it so far. One problem I am running into is that I want to query records, filtering out records that aren't in a certain date range. It took me a while to find out how to do a "<=" type of match instead of an equality match: my $start_criteria = ">= $start_date"; my $end_criteria = "<= $end_date"; my $result = $schema->resultset('MyTable')->search( { 'status_date' => \$start_criteria, 'status_date' => \$end_criteria, }); The obvious problem with this is that since the filters are in a hash, I am overwriting the value for "status_date", and am only searching where the status_date <= $end_date. The SQL that gets executed is: SELECT me.* from MyTable me where status_date <= '9999-12-31' I've searched CPAN, Google and SO and haven't been able to figure out how to apply 2 conditions to the same column. All documentation I've been able to find shows how to filter on more than 1 column, but not 2 conditions on the same column. I'm sure I'm missing something obvious - hoping someone here can point it out to me? Thanks in advance! Brian

    Read the article

  • How can I use `pipe` to facilitate interprocess communication in Perl?

    - by Shiftbit
    Can anyone explain how I can successfully get my processes communicating? I find the perldoc on IPC confusing. What I have so far is: $| = 1; $SIG{CHLD} = {wait}; my $parentPid = $$; if ($pid = fork();) ) { if ($pid == 0) { pipe($parentPid, $$); open PARENT, "<$parentPid"; while (<PARENT>) { print $_; } close PARENT; exit(); } else { pipe($parentPid, $pid); open CHILD, ">$pid"; or error("\nError opening: childPid\nRef: $!\n"); open (FH, "<list") or error("\nError opening: list\nRef: $!\n"); while(<FH>) { print CHILD, $_; } close FH or error("\nError closing: list\nRef: $!\n"); close CHILD or error("\nError closing: childPid\nRef: $!\n); } else { error("\nError forking\nRef: $!\n"); } First: What does perldoc pipe mean by READHANDLE, WRITEHANDLE? Second: Can I implement a solution without relying on CPAN or other modules?

    Read the article

  • Can I use POSIX signals in my Perl program to create event-driven programming?

    - by Shiftbit
    Is there any POSIX signals that I could utilize in my Perl program to create event-driven programming? Currently, I have multi-process program that is able to cross communicate but my parent thread is only able to listen to listen at one child at a time. foreach (@proc) { sysread(${$_}{'read'}, my $line, 100); #problem here chomp($line); print "Parent hears: $line\n"; } The problem is that the parent sits in a continual wait state until it receives it a signal from the first child before it can continue on. I am relying on 'pipe' for my intercommunication. My current solution is very similar to: http://stackoverflow.com/questions/2558098/how-can-i-use-pipe-to-facilitate-interprocess-communication-in-perl If possible I would like to rely on a $SIG{...} event or any non-CPAN solution. Update: As Jonathan Leffler mentioned, kill can be used to send a signal: kill USR1 = $$; # send myself a SIGUSR1 My solution will be to send a USR1 signal to my child process. This event tells the parent to listen to the particular child. child: kill USR1 => $parentPID if($customEvent); syswrite($parentPipe, $msg, $buffer); #select $parentPipe; print $parentPipe $msg; parent: $SIG{USR1} = { #get child pid? sysread($array[$pid]{'childPipe'}, $msg, $buffer); }; But how do I get my the source/child pid that signaled the parent? Have the child Identify itself in its message. What happens if two children signal USR1 at the same time?

    Read the article

  • Why are references compacted inside Perl lists?

    - by parkan
    Putting a precompiled regex inside two different hashes referenced in a list: my @list = (); my $regex = qr/ABC/; push @list, { 'one' => $regex }; push @list, { 'two' => $regex }; use Data::Dumper; print Dumper(\@list); I'd expect: $VAR1 = [ { 'one' => qr/(?-xism:ABC)/ }, { 'two' => qr/(?-xism:ABC)/ } ]; But instead we get a circular reference: $VAR1 = [ { 'one' => qr/(?-xism:ABC)/ }, { 'two' => $VAR1->[0]{'one'} } ]; This will happen with indefinitely nested hash references and shallowly copied $regex. I'm assuming the basic reason is that precompiled regexes are actually references, and references inside the same list structure are compacted as an optimization (\$scalar behaves the same way). I don't entirely see the utility of doing this (presumably a reference to a reference has the same memory footprint), but maybe there's a reason based on the internal representation Is this the correct behavior? Can I stop it from happening? Aside from probably making GC more difficult, these circular structures create pretty serious headaches. For example, iterating over a list of queries that may sometimes contain the same regular expression will crash the MongoDB driver with a nasty segfault (see https://rt.cpan.org/Public/Bug/Display.html?id=58500)

    Read the article

  • How can a SVN::Error callback identify the context from which it was called

    - by Colin Fine
    I've written some fairly extensive Perl modules and scripts using the Perl bindings SVN::Client etc. Since the calls to SVN::Client are all deep in a module, I have overridden the default error handling. So far I have done so by setting $SVN::Error::handler = undef as described in [1], but this makes the individual calls a bit messy because you have to remember to make each call to SVN::Client in list context and test the first value for errors. I would like to switch to using an error handler I would write; but $SVN::Error::handler is global, so I can't see any way that my callback can determine where the error came from, and what object to set an error code in. I wondered if I could use a pool for this purpose: so far I have ignored pools as irrelevant to working in Perl, but if I call a SVN::Client method with a pool I have created, will any SVN::Error object be created in the same pool? Has anybody any knowledge or experience which bears on this? [1]: http://search.cpan.org/~mschwern/Alien-SVN-1.4.6.0/src/subversion/subversion/bindings/swig/perl/native/Core.pm#svn_error_t_-_SVN::Error SVN::Core POD

    Read the article

  • excel graphs using perl

    - by user1822725
    i amfacing problem when i ran the script its giving error like Can't locate object method "add_chart" via package "Spreadsheet::WriteExcel" at chart_column.pl line 33. May i know what is the problem here? And i am using perl, v5.8.5 built for x86_64-linux. #!/usr/bin/perl -w ############################################################################### # # A simple demo of Column charts in Spreadsheet::WriteExcel. # # reverse('©'), December 2009, John McNamara, [email protected] # use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new( 'chart_column.xls' ); my $worksheet = $workbook->add_worksheet(); my $bold = $workbook->add_format( bold => 1 ); # Add the worksheet data that the charts will refer to. my $headings = [ 'Category', 'Values 1', 'Values 2' ]; my $data = [ [ 2, 3, 4, 5, 6, 7 ], [ 1, 4, 5, 2, 1, 5 ], [ 3, 6, 7, 5, 4, 3 ], ]; $worksheet->write( 'A1', $headings, $bold ); $worksheet->write( 'A2', $data ); ############################################################################### # # Example 1. A minimal chart. # my $chart1 = $workbook->add_chart( type => 'column' ); # Add values only. Use the default categories. $chart1->add_series( values => '=Sheet1!$B$2:$B$7' ); # Insert the chart into the main worksheet. $worksheet->insert_chart( 'E2', $chart1 );

    Read the article

  • How to handle building and parsing HTTP URL's / URI's / paths in Perl

    - by Robert S. Barnes
    I have a wget like script which downloads a page and then retrieves all the files linked in img tags on that page. Given the URL of the original page and the the link extracted from the img tag in that page I need to build the URL for the image file I want to retrieve. Currently I use a function I wrote: sub build_url { my ( $base, $path ) = @_; # if the path is absolute just prepend the domain to it if ($path =~ /^\//) { ($base) = $base =~ /^(?:http:\/\/)?(\w+(?:\.\w+)+)/; return "$base$path"; } my @base = split '/', $base; my @path = split '/', $path; # remove a trailing filename pop @base if $base =~ /[[:alnum:]]+\/[\w\d]+\.[\w]+$/; # check for relative paths my $relcount = $path =~ /(\.\.\/)/g; while ( $relcount-- ) { pop @base; shift @path; } return join '/', @base, @path; } The thing is, I'm surely not the first person solving this problem, and in fact it's such a general problem that I assume there must be some better, more standard way of dealing with it, using either a core module or something from CPAN - although via a core module is preferable. I was thinking about File::Spec but wasn't sure if it has all the functionality I would need.

    Read the article

  • Why does my Perl CGI program fail with "Software error: ..."?

    - by kiran
    When I try to run my Perl CGI program, the returned web page tells me: Software error: For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error. Here is my code in one of the file: #!/usr/bin/perl use lib "/home/ecoopr/ecoopr.com/CPAN"; use CGI; use CGI::FormBuilder; use CGI::Session; use CGI::Carp (fatalsToBrowser); use CGI::Session; use HTML::Template; use MIME::Base64 (); use strict; require "./db_lib.pl"; require "./config.pl"; my $query = CGI-new; my $url = $query-url(); my $hostname = $query-url(-base = 1); my $login_url = $hostname . '/login.pl'; my $redir_url = $login_url . '?d=' . $url; my $domain_name = get_domain_name(); my $helpful_msg = $query-param('m'); my $new_trusted_user_fname = $query-param('u'); my $action = $query-param('a'); $new_trusted_user_fname = MIME::Base64::decode($new_trusted_user_fname); ####### Colin: Added July 12, 2009 ####### my $view = $query-param('view'); my $offset = $query-param('offset'); ####### Colin: Added July , 2009 ####### #print $session-header; #print $new_trusted_user; my $helpful_msg_txt = qq[]; my $helpful_msg_div = qq[]; if ($helpful_msg)

    Read the article

  • How can I make hundreds of simultaneously running processes communicate with a database through one

    - by Olfan
    Long speech short: How can I make hundreds of simultaneously running processes communicate with a database through one or few permanent sessions? The whole story: I once built a number crunching engine that handles vast amounts of large data files by forking off one child after another giving each a small number of files to work on. File locking, progress monitoring and result propagation happen in an Oracle database which all (sub-)processes access at various times using an application-specific module which encapsulates DBI. This worked well at first, but now with higher volumes of input data, the number of database sessions (one per child, and they can be very short-lived) constantly being opened and closed is becoming an issue. I now want to centralise database access so that there are only one or few fixed database sessions which handle all database access for all the (sub-)processes. The presence of the database abstraction module should make the changes easy because the function calls in the worker instances can stay the same. My problem is that I cannot think of a suitable way to enhance said module in order to establish communication between all the processes and the database connector(s). I thought of message queueing, but couldn't come up with a way of connecting a large herd of requestors with one or few database connectors in a way so that bidirectional communication is possible (for collecting the query result). An asynchronous approach could help here in that all requests are written to the same queue and the database connector servicing the request will "call back" to submit the result. But my mind fails me in generating an image clear enough so that I can paint into code. Threading instead of forking might have given me an easier start, but this would now require massive changes to the code base that I'm not prepared to do to a live system. The more I think of it, the more the base idea looks like a pre-forked web server to me only that it doesn't serve web pages but database queries. Any ideas on what to dig into, and where? Sample (pseudo) code to inspire me, links to possibly related articles, ready solutions on CPAN maybe?

    Read the article

  • How do I efficiently parse a CSV file in Perl?

    - by Mike
    I'm working on a project that involves parsing a large csv formatted file in Perl and am looking to make things more efficient. My approach has been to split() the file by lines first, and then split() each line again by commas to get the fields. But this suboptimal since at least two passes on the data are required. (once to split by lines, then once again for each line). This is a very large file, so cutting processing in half would be a significant improvement to the entire application. My question is, what is the most time efficient means of parsing a large CSV file using only built in tools? note: Each line has a varying number of tokens, so we can't just ignore lines and split by commas only. Also we can assume fields will contain only alphanumeric ascii data (no special characters or other tricks). Also, i don't want to get into parallel processing, although it might work effectively. edit It can only involve built-in tools that ship with Perl 5.8. For bureaucratic reasons, I cannot use any third party modules (even if hosted on cpan) another edit Let's assume that our solution is only allowed to deal with the file data once it is entirely loaded into memory. yet another edit I just grasped how stupid this question is. Sorry for wasting your time. Voting to close.

    Read the article

  • Which Perl moudle can handle variety of date formats with unicode characters ?

    - by ram
    My requirement is parsing xml files which contains wide varieties of timestamps based on the locales at which they are written. They may contain Unicode characters in case of Chinese or Korean locales. I have to parse these timestamps and put then in a standard format something like 2009-11-26 12:40:54 to put them in a oracle database. Sometimes I may not even know the locale and yet I have to parse the timestamps. I am looking for a module that automatically detects the timestamp format (including unicode characters for am and pm in their local language) and converts in to epoch time so that I can convert it back to what ever way I like to. I have gone through similar questions in this forum. Few suggested DateFormat module, and Date::Parse module. The perl distribution I am using is 5.10 so Date::Manip doesn't come as a core module. As I am supposed to use just the basic core modules and few CPAN modules(on request I cannot ask for all), I request you to kindly suggest me a good module that suffices all my requirements. Thanks in advance

    Read the article

< Previous Page | 2 3 4 5 6 7  | Next Page >