I've always wondered this. I have a habit of always adding
use strict;
use warnings;
use Data::Dumper;
to the top of every script I write. Does this add overhead if I don't even use the Dumper function? Also, in most cases Data::Dumper was called earlier in another package but I need it in this package so I include it again. In thi...
A little known built-in Perl feature is attributes. However, the official documentation is doing a rather bad job introducing newbies to the concept. At the same time, frameworks like Catalyst use attributes extensively which seems to make many things easier there. Since using something without knowing the implications sucks a bit, I'd l...
This piece of Perl is telling me that a file in ClearCase doesn't exist when it does;
$x = "PATH/TO/FILE"
if (-e $x) {
print "This file exists on the file system";
} else {
print "I can't see this file";
}
Has anyone seen this before?
Some files return fine. Got me stumped.
Clearcase view is dynamic, hosted on unix.
This piec...
I ran Perl::Critic on one of my scripts, and got this message:
Regular expression without "/x" flag at line 21, column 26. See page 236 of PBP.
I looked up the policy information here, and I understand that writing regular expressions in extended mode will help anyone who is looking at the code.
However, I am stuck as how to convert ...
I have a text file (basically an error log with date, timestamp and some data) in the following pattern:
mm/dd/yy 12:00:00:0001
This is line 1
This is line 2
mm/dd/yy 12:00:00:0004
This is line 3
This is line 4
This is line 5
mm/dd/yy 12:00:00:0004
This is line 6
This is line 7
I'm new at Perl and need to write a script that se...
I need to search for a pattern and write that line as well as the next 3 lines into a file (FILE). Is this a correct way to do it? Thanks.
print FILE if /^abc/;
$n=3 if /^abc/;
print FILE if ($n-- > 0);
...
If so can you provide the code. I am able to do almost everything else from creating new pages, modifying page attributes etc.. But I cannot seem to add attachments. I have read the official conflunce Perl XML-RPC site and discussions but all the code fragments they show there don't seem to work for me. Here is my hacked up attempt at i...
I had assumed it would be as simple as $ENV{TZ}, but the TZ environment variable is not set, and yet the date command still knows I am in EDT, so there must be some other way of determining timezone (other than saying chomp(my $tz = qx/date +%Z/);).
...
I'm parsing an XML file with LibXML and need to sort the entries by date. Each entry has two date fields, one for when the entry was published and one for when it was updated.
<?xml version="1.0" encoding="utf-8"?>
...
<entry>
<published>2009-04-10T18:51:04.696+02:00</published>
<updated>2009-05-30T14:48:27.853+03:00</updated>
<ti...
I am trying change the stdout of the system function using select. But it does not seem to be working. The system output is getting displayed on console rather than getting redirected to the file.
use strict;
use warnings;
chdir "C:\\Documents and Settings\\" or die "cannot open the dir\n";
open FH, ">out.txt" or die "cannot open out.t...
I tried:
cpan> i /xls2csv/
No objects found of any type for argument /xls2csv/
cpan> install xls2csv
Warning: Cannot install xls2csv, don't know what it is.
Try the command
i /xls2csv/
to find objects with matching identifiers.
I haven't had any problems installing registered modules, e.g.
cpan> install DateTime
It is just the ...
So far I have written a Perl server that runs constantly in the background, when it receives inbound connections a process is forked and that then handles that one connection. What I ultimately want it to be able to do is accept inbound php connections through the socket of course run these commands and then relay and information back. S...
How can I remove a substring from a string using Perl? For example, $URL contains http://xyz.com/Main#abcd.aspx
And I want to check and strip out 'Main#' from $URL Can anyone help me out?
Well first I need to check that whether the string Main# exist or not.
If it exists, then strip it; otherwise nothing needs to be done. So only an i...
I'm building a webcrawler in Perl/LWP. How can the webcrawler follow a link in a ASP.NET grid like this:
<a id="ctl00_MainContent_listResult_Top_LnkNextPage" href="javascript:__doPostBack('ctl00$MainContent$listResult$Top$LnkNextPage','')">Next</a>
...
I have a mathematical set in a Perl array: (1, 2, 3). I'd like to find all the subsets of that set: (1), (2), (3), (1,2), (1,3), (2,3).
With 3 elements this isn't too difficult but if set has 10 elements this gets tricky.
Thoughts?
...
In Net::SCP at which point do I need DSC or RSA keys (i.e when do I use the get or put functions)?. I would like to know the scp service is available without transferring the file.
...
Hi,
I have a header file in which there is a large struct. I need to read this structure using some program and make some operations on each member of the structure and write them back.
For example I have some structure like
const BYTE Some_Idx[] = {
4,7,10,15,17,19,24,29,
31,32,35,45,49,51,52,54,
55,58,60,64,65,66,67,69,
70,72,76,7...
How can I read the URL parameter in a Perl CGI program?
...
I have been working with the Microsoft stack, and would like to get a little bit of experience with alternative stacks, like LAMP, in my spare time.
The P in LAMP, is usually "PHP", but can be Perl (or Python, but I am considering Perl or PHP above Python.). I am gravitating towards Perl, because it looks like it would be useful in othe...
Ok, I have a bit of an issue here. I realize that I don't need to set a $handle to *::HTML to get this snippet to work, however this code is taken out of context from its use and I do in fact need this to work with the $handle. The output I am receiving is below the snippet however the output I want is for the file.html to contain "what\...