I am writing a perl script, and in the part where I am checking the options that the user supplied on the command line, I want to exit with an error explaining what was wrong with the options. In this case, there is no need for a stack trace to go along with this error message. So what is the best way to die with an error message but no ...
I am using IxHash to remember the insertion order of a hash. but when using clone to copy a hash i get an empty hash.
use strict;
use Switch;
use Data::Dumper;
use Clone qw(clone);
use Tie::Autotie 'Tie::IxHash';
our %h_basic_values;
my $t = tie our(%h_inner_hash), "Tie::IxHash";
my $t1 = tie our(%h_inner_hash1) , "Tie::IxHash";
%h_in...
I have written a script that gets a file name and insert the file content to a Text widget. Now when I close the script window, I need it to write the text onto the Unix screen.
How can I get the Text widget content?
My text widget insertion sorce code is:
open(FILE, $file_name);
foreach my $line (<FILE>) {
$text->insert('end', $l...
Seriously, I'm lost in the UTF-8 world. Here is my situation (everything is happening on a mac):
I get a web service response with perl+lwp and store it in mysql database; response is encoded in UTF-8 and I use DBI module to store data in Mysql UTF-8 table (urf8_general_ci encoding);
when I get strings from database with CI model; outp...
How do i create the main pages layout in jifty? I did not find that information in the documentation.
I guess there has to be a Template::Declare reference that is used to wrap the page content. Where do i find that wrapper code or where do i create a template to override it?
...
I'm attempting to use the XML::Simple CPAN module to convert output from our database into a simple XML structure. The problem is that the output being returned isn't what I was hoping for no matter what options I attempt to pass to XML::Simple.
The database table we're trying to output is just a bunch of items with the definition:
CRE...
I'm not sure why perl isn't recognizing the Heap's method add. Getting message given in question title. Here are the most relevant files.
#!/usr/bin/perl -w
use strict;
use Util;
use Heap;
use HuffTree;
my $heap = Heap->new;
my $test = 3;
$heap->add($test); # <--------ERROR HERE-----------
package Heap;
use strict;
use warnings;
...
I have a php script that handles a form input. For design reasons both a bit out of my control, and which I do not entirely wish to change, I have to call a perl script with the parameters specified in the html form.
I sanitized all inputs and then output them to a file called input, which is read by the perl script named, for sake of ...
All over the place, especially in DBI, I see this message come up all the time. It's confusing, because the first thing that comes to mind is that the arguments I'm passing the function are set to undef (or something similar), but it's clearly not the case.
Given a module and a corresponding script...
Module: ./lib/My/Module.pm
packag...
In perl, for numerical comparison, we have +/- inf as numbers that are greater/less than every other number. Are there also strings that are gt/lt any other string?
The reason I ask is that I'd like to tack one or the other on the end of a list of strings to ensure that a loop will terminate before the end of the list.
...
i'm having problems with the HTTP:Cookies extract_cookies() method, i have a HTTP::Header object with multiple cookies in it under a single field name and the method is only extracting a single cookie. The solution is possibly to have each cookie under a separate 'Set-Cookie" field, but from which i can see HTTP::Headers does not allow y...
I have perl scripts starting with #!/usr/bin/perl or #!/usr/bin/env perl
First, what does the second version mean?
Second, I use Ubuntu. All the scripts are set as executables. When I try to run a script by simply invoking it's name (e.g. ./script.pl) I get : No such file or directory. when I invoke by perl ./script.pl it runs fine.
W...
Hi ,
i am using mason 1.0 and want to redirect the page to another URL.
Is there any way to redirect ?
Alternatively..
I have written following code in dbhandler which is giving error stating that $r undefined. Can you please help.
$r->method('GET');
$r->headers_in->unset('Content-length');
$r->content_type('text/html');
$r-...
Hi everybody,
I am going to create a corporate site with around 150-200 pages. Several pages have three category levels (I mean a URL like products/myproduct/overview)
The client's employees should be able to edit all the pages very easily, manage the navigation and left blocks as well.
What CMS (opensource, if possible) can I use? PHP...
I want to match dates that have the following format:
2010-08-27 02:11:36
i.e. yyyy-mm-dd hh:mm:ss.
Right now I am not very particular about the date being actually feasible, but just that it is in the correct format.
Possible formats that should match are (for this example)
2010
2010-08
2010-08-27
2010-08-27 02
2010-08-27 02:11
20...
when I use the following command in command line it's giving list of non integrated change lists.
p4 interchanges -t $branch1 @$date1, @$date2 $branch2 > changes.txt
But when I use this command in a Perl script as below it's not giving output:
$cmd = system ("p4 interchanges -t $branch1 @$date1, @$date2 $branch2 > changes.txt");
Th...
@temp = split(/\./, $_);
$val = $temp[1];
$val =~ s/\D//;
What is the correct syntax to write a single statement instead of these three statements in Perl?
($val = split(/\./, $_)[1]) =~ s/\D//;
gives me
syntax error at test.pl line 126, near ")["
Execution of test.pl aborted due to compilation errors.
...
I want to change some Perl code into C++. I need to know how to implement nested Perl hashes in C++. I thought of STL as a good choice and used maps. With the help of maps I can create only a simple hash but I do not know how to create a nested hash structure.
My Perl hash is like this:
%foo = (
"bar1" => {
Default => 0,
...
I am using syntax checking to see whether my Perl script is being used in the correct way. If the syntax is not correct, I display a message saying what the correct syntax is and then end the execution of the program.
Out of
print "Please use the following syntax: ...";
exit 1;
and
die("Please use the following syntax: ...");
whic...
EDIT
Sorry for the confusion, here is my updated question.
I am using FindBin in my perl script like this:
use FindBin qw($Bin);
use lib "$Bin/../lib";
use multi_lib qw(say_hello_world);
This works:
multi_lib::say_hello_world();
but this does not:
say_hello_world();
EDIT 2
This is how multi_lib.pm looks:
package multi_lib;
u...