I am inserting 2-dimensional array references into my heap in Perl.
How should I define the 'elements' attribute when constructing my heap so that I can properly use my comparator function?
my $heap = Heap::Simple->new( order => \&byNumOrStr,
elements => [Array => 0]
);
...
How do I get the header and footer not to print on the first page?
...
I'm creating a CGI form to update a Sybase stored procedure.
qq {execute procedure test(123,45,date,'$note');};
the $note variable is information obtained from a textbox that contains trouble ticket log information. As such people who enter such information can, and most likely will use special characters such as '|"{} etc. Im curious...
I am trying to return the output of a file replacing newlines with \n without using CPAN
Here is what I have so far
#! /usr/local/bin/perl
if ( $#ARGV = "1" ) {
print "$ARGV[0]\n";
my $file = "$ARGV[0]";
my $document = do {
local $/;
open my $fh, "<", $file
or die "could not open $file: $!"...
This question has been asked about PHP both here and here, and I have the same question for Perl. Given a function that returns a list, is there any way (or what is the best way) to immediately index into it without using a temporary variable?
For example:
my $comma_separated = "a,b,c";
my $a = split (/,/, $comma_separated)[0]; #not va...
Hello,
I maintain a local intranet site that among other things, displays movie poster images from IMDB.com. Until recently, I simply had a perl script download the images I needed and save them to the local server. But that became a HUGE space-hog, so I thought I could simply point my site directly to IMDB servers, since my traffic i...
Hi, the code below prints nothing. Please help me out in the same.
use Cvs;
my $obj = new Cvs cvsroot => ":pserver:pramodh\@129.227.152.22:/data/cvs" or die $Cvs::ERROR;
$obj->checkout(package) || print "ERROR";
my @modules = $obj->module_list();
print "@modules";
If I work on the command line it works fine with these commands:
[ro...
How can I set up cperl mode in Emacs so that the indentation after brackets, e.g.
has 'name' => (
is => 'rw',
isa => 'Str',
required => 1,
);
(default indentation) becomes more like that seen in, for example, the Moose manual, e.g.
has 'password' => (
...
Hi
I have a file that has some entries like
--ERROR--- Failed to execute the command with employee Name="shayam" Age="34"
--Successfully executed the command with employee Name="ram" Age="55"
--ERROR--- Failed to execute the command with employee Name="sam" Age="23"
--ERROR--- Failed to execute the command with employee Name="yam" Ag...
$selected = ' selected="selected"'
# or
$selected = qq( selected="selected")
is returned as:
selected="selected"
which is an invalid HTML attribute, ofcourse.
How do I fix it?
Edited to add:
<select name="alignment" class="select"
<%== param('feature') ? '' : 'disabled'; %>
>
% foreach (keys %al) {
% my $selected...
How would you explore and write to windows shared directories in perl ?
Note: I don't have the right for network drive creation on the concerned workstation.
I tried (without results) the following :
my $ROOTDIR1 = 'c:/';
my $ROOTDIR2 = '//server/dir1/dir2/';
sub dtest {
my $ROOTDIR = shift;
warn "Testing '$ROOTDIR'.";
opendir( SH...
Data Format:
attribname: data
Data Example:
cheese: good
pizza: good
bagel: good
fire: bad
Code:
my $subFilter='(.+?): (.+)';
my @attrib = ($dataSet=~/$subFilter/g);
for (@attrib)
{
print "$_\n";
}
The code spits out:
cheese
good
pizza
good
[etc...]
I was wondering what an easy Perly way to do this is? I am parsing the dat...
I have a form, not unlike the post question/comment on this site that I want to post to a field in a database.
However if someone where to put special characters such as @#;"| either fails or does not insert correctly. Is there a way to insert said data into a database without Perl trying to treat certain characters as operators?
...
I have an interesting situation where I have a perl watcher script (using Linux::Inotify2) watch for files to be dropped in a certain directory, then hand them off to a PHP script for processing. The watched directory and the files in it are not owned by the user the watcher script is running under, but the entire directory tree the fil...
Before, I had defined my elements entry as just Array in H::S because I did not need a secondary sort.
After implementing a secondary sort and a function for defining the elements to insert array references into a heap I made, the runtime of my insertions increased (alot!). This is covered in the documentation for Heap::Simple under ht...
I am doing a Perl OO example (mainly to reacquaint myself with Perl) and using
inheritance, it seems that the SUPER works in the subclass when calling the superclass constructor and that
the superclass variables don't bind to the subclass object. Why would this be?
################################################
## Package : Person ...
I recently downloaded Moose. Experimentally, I rewrote an existing module in Moose. It seems to be convenient way to avoid writing lots of repetitive code. I ran the tests of the module, and I noticed it was a bit delayed. I profiled the code with -d:DProf and it seems that just including the line
no Moose;
in the code increases the r...
I need to know if there is some way to replace any string as @ or * or ? or & without to put the "\" before it
Example
perl -pe 'next if /^#/; s/\@d\&/new_value/ if /param5/' test
in this example need to replace the @d& with new_value
but I need to put the "\" before @ or &
can be other way without to put the "\" because I have r...
hi I have the following file How to remove by sed all FILE NAME lines except the first uniq FILE NAME For example need to remove all FILE NAME lines from the file except the first:
FILE NAME: /dir1/dir2/dir3/dir4/dir5/file
FILE NAME: /dirA/dirB/dirC/dirD/dirE/file
the file:
FILE NAME: /dir1/dir2/dir3/dir4/dir5/file
PARAMETER NAME: b...
How do I use map with the split function to trim the constituents: $a, $b, $c and $d; of $line?
my ($a, $b, $c, $d, $e) = split(/\t/, $line);
# Perl trim function to remove whitespace from the start and end of the string
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
...