what is the difference between my and our in Perl?
I know what my is in Perl. It defines a variable that exists only in the scope of the block in which it is defined. What does our do? How does it differ from my? ...
I know what my is in Perl. It defines a variable that exists only in the scope of the block in which it is defined. What does our do? How does it differ from my? ...
Having volunteered to maintain a stagnant CPAN package (GnuPG) I'd like improve the install files such that they exit gracefully if the gpg binary (which GnuPG is a wrapper for) cannot be found. After a bit of seeking inspiration from other packages, I've come up with adding this to Makefile.PL: my @paths = grep { -x "$_/gpg" } split /:...
The log4j logs I have contain timestamps in the following format: 2009-05-10 00:48:41,905 I need to convert it in perl to millseconds since epoch, which in this case would be 124189673005, using the following gawk function. How do I do it in perl? I have little or no experience in perl, so appreciate if someone can post an entire sc...
I need to cut off the last seven characters of a string (a string that is stored in a hash). What is the easiest way to do that in perl? Many thanks in advance! ...
I have a perl script that interfaces with an existing database (type of database is unknown) through the DBI module, that I would like to access in python 2.6 on winXP. The perl code is: use DBI; my $DSN = "DBI:Proxy:hostname=some.dot.com;port=12345;dsn=DBI:XXXX:ZZZZZ"; my $dbh = DBI->connect($DSN); Can this be translated into a pyth...
I'm using DBD::Oracle in perl, and whenever a connection fails, the client generates a sqlnet.log file with error details. The thing is, I already have the error trapped by perl, and in my own log file. I really don't need this extra information. So, is there a flag or environment for stopping the creation of sqlnet.log? Thanks ...
Hi all, I do have to deal with very large plain text files (over 10 gigabytes, yeah I know it depends what we should call large), with very long lines. My most recent task involves some line editing based on data from another file. The data file (which should be modified) contains 1500000 lines, each of them are e.g. 800 chars long. ...
I have a multi-layered PSD, with one specific layer being non-rasterized text. I'm trying to figure out a way I can, from a bash/perl/python/whatever-else program: load the PSD edit the text in said layer flatten all layers in the image save as a web-friendly format like PNG or JPG I immediately thought of ImageMagick, but I don't t...
Hi all, from this string, (champs1 (champs6 donnee_o donnee_f) [(champs2 [] (champs3 _YOJNJeyyyyyyB (champs4 donnee_x)) (debut 144825 25345) (fin 244102 40647)), (champs2 [] (champs3 _FuGNJeyyyyyyB (champs4 donnee_z)) (debut 796443 190570) (fin 145247 42663))] [] [])., i would like to extract the first number after the word "debut", and...
I am writing a Perl script to access intranet page with authentication. Is there any Perl module to access intranet web page? ...
I have some 256-character strings of hexadecimal characters which represent a sequence of bit flags, and I'm trying to convert them back into a bitstring so I can manipulate them with &, |, vec and the like. The hex strings are written in integer-wide big-endian groups, such that a group of 8 bytes like "76543210" should translate to th...
I'm running DBI in Perl and can't figure out how, when I run a prepared statement, I can figure out if the returned row count is 0. I realize I can set a counter inside my while loop where I fetch my rows, but I was hoping there was a less ugly way to do it. ...
In python we can use multiprocessing modules. If there is a similar library in Perl and Ruby, would you teach it? I would appreciate it if you can include a brief sample. ...
I need to launch a server side process off a mysql row insert. I'd appreciate some feedback/suggestions. So far I can think of three options: 1st (least attractive): My preliminary understanding is that I can write a kind of "custom trigger" in C that could fire off a row insert. In addition to having to renew my C skills this would r...
Following up on this question, I need to get exactly n lines at random out of a file (or stdin). This would be similar to head or tail, except I want some from the middle. Now, other than looping over the file with the solutions to the linked question, what's the best way to get exactly n lines in one run? For reference, I tried this:...
Hi all, I have a queries that reside in multiple methods each (query) of which can contain multiple paramaters. I am trying to reduce file size and linecount to make it more maintainable. Below is such an occurence: $sql_update = qq { UPDATE database.table SET column = 'UPDATE!' WHERE id = ? ...
HI, I have a string that looks like /dir/dir1/filename.txt I want to replace the "filename.txt" with some other name leaving the "/dir/dir1" intact so after the replace the string would look like /dir/dir1/newfilename.txt how would I do that using RegExp in Perl considering that I don't know the value of "filename" Many Thanks...
Hi, I am getting a date field from the database in one of my variables, at the moment I am using the following code to check if the date is in "yyyy-mm-dd" format if ( $dat =~ /\d{3,}-\d\d-\d\d/ ) My question, is there a better way to accomplish this. Many Thanks ...
I'm working on a project for my company that uses a socket server (php) to gather data from a remote device. How can I make this perl program run directly on the stream instead of first having the server write to a tmp file then running this script on that file then writing out a csv file for insertion into a database? I thought about ...
Hi, I noticed that when I call a PL/PgSQL or PL/Perl function from a Perl script using DBI, it does not return a value if a RAISE NOTICE or elog(NOTICE) is used in the function. To illustrate: A simple table: CREATE TABLE "public"."table1" ( "fld" INTEGER ) WITHOUT OIDS; A simple function: CREATE OR REPLACE FUNCTION "public"."fun...