What is the historical reason to that last is called that in Perl rather than break as it is called in C?
The design of Perl was influenced by C (in addition to awk, sed and sh - see man page below), so there must have been some reasoning behind not going with the familiar C-style naming of break/last.
A bit of history from the Perl 1....
I have a bot that replies to users. But sometimes when my bot sends its reply, the user or their email provider will auto-respond (vacation message, bounce message, error from mailer-daemon, etc). That is then a new message from the user (so my bot thinks) that it in turn replies to. Mail loop!
I'd like my bot to only reply to real e...
New to OOP with Perl, and just had a quick question. I have this function in a class:
sub Print{
my $text = shift;
print "my text is", $text;
}
I try to print the text out, by doing this:
my $object = ObjectName->new();
$object->Print("Print this text")
It prints this:
my text isObjectName=SCALAR(0x1289df0)
My question is...
Alrighty, coding in Perl and just had a quick question. I have class created called SubtitleSite which is basically an abstraction, and a class called podnapisi that inherits SubtitleSite like this:
@ISA = qw(SubtitleSite);
My question is, do I have to use:
use SubtitleSite;
in order to have access to all the methods in SubtitleSit...
I am looking for a CPAN module that will allow me to store possible exceptions/errors in a database and internationalize my error messages. Currently I have subclassed Exception::Class but its a bit of a hack and I would like to use something that is production quality. It would be great if it integrates with Exception::Class or even Err...
Is it possible to use Haml instead of a templating engine with the Catalyst web framework?
...
I have a $map{k1}{k2}{k3}{k4}.
How can I write the loop correctly to print all values? The following does not work.
for my $k1 (sort keys %tripletsCountMap) {
for my $k2 (sort keys %$tripletsCountMap{k1}){
for my $k3 (sort keys %$tripletsCountMap{k1}{k2}) {
for my $k4 (sort keys %$tripletsCountMap{k1}{k3}{k3}){
pr...
How would you take a reference to an array slice such that when you modify elements of the slice reference, the original array is modified?
The following code works due to @_ aliasing magic, but seems like a bit of a hack to me:
my @a = 1 .. 10;
my $b = sub{\@_}->(@a[2..7]);
@$b[0, -1] = qw/ < > /;
print "@a\n";
# 1 2 < 4 5 6 7 > 9 10
...
I would like to properly understand hashes in Perl. I've had to use Perl intermittently for quite some time and mostly whenever I need to do it, it's mostly related to text processing.
And everytime, I have to deal with hashes, it gets messed up. I find the syntax very cryptic for hashes
A good explanation of hashes and hash references...
I need to construct a file path inside a Perl script. Which path separator should I use to allow my script to work on both Windows and Unix?
Keep in mind that Windows needs a drive letter.
...
I would like to get solution for a issue on in perl program.
$parallel_on=='YES'? my $pid = $pm->start and next; :0;
I want being the statement like this. but I am not getting solved.
Can please any one solve this?
...
If inside my code I'll have calls like:
__PACKAGE__->method;
will this limit the usability of this module, if this module is inherited?
...
By default, perl prints \r\n in a win32 environment. How can I override this? I'm using perl to make some changes to some source code in a repository, and I don't want to change all the newline characters.
I tried changing the output record separator but with no luck.
Thanks!
Edit: Wanted to include a code sample - I'm doing a search ...
I have a CGI (perl) script that is attempting to call curl using the open command:
@curl = ('/usr/bin/curl', '-S','-v','--location', $url,
'-H', 'Content-Type:'.$content_type,
'-H', "Authorization: $authorization",
'-H', "X-Gdata-Key:$gdata_key",
...
I am running a script which requires the Curl.pm lib in order to work. I used YUM to install the library and now I am trying to have my script use it, but I keep getting the error
Can't locate WWW/Curl.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.6/x86_...
When I type the following in the command line:
rpm -ql curl
I ge...
I'm sure someone could answer this very quickly, but I'm just new to perl...
I'm trying to modify demarc (a simple network monitoring tool) to do a system call to a simple script. The script itself does nothing, I'm just trying to do a 'proof-of-concept' because I keep getting an internal server error. Permissions to the script have bee...
I have a hash and I am trying to insert its values into database. Hash is defined as follows:
my %hash = (
1 => 'First Word',
2 => 'Second Word is correct',
0 => 'Third word does not exist',
);
I do not know how to insert values in a database using hashes. I notice my question i...
How could I access the symbol table for the current package an object was instantiated in? For example, I have something like this:
my $object = MyModule->new;
# this looks in the current package, to see if there's a function named run_me
# I'd like to know how to do this without passing a sub reference
$object->do_your_job;
If in the...
Is there an easier way to grab only one element out of a match other than doing the followng:
my $date = ($xml_file =~ m/(\d+)-sys_char/)[0];
# or
my $date = $1 if $xml_file =~ /(\d+)-sys_char/;
Is there a flag to specify that m doesn't return an array but just one concatenated value of all the $# matches, so I can do:?
my $date = ($...
As a non-English native, I used to make a lot of English grammatical and idiomatic mistakes. For example, I would write "I will can climb Mt Everest." instead of "I will be able to climb Mt Everest" and "students learn more knowledge in school" instead of "students lean more in school". Now I'm learning Perl as my first programming langu...