perl

How can I extract a string between two characters + do it RECURSIVELY ?

I have a string: 123 + FOO1[ccc + e_FOO1 + ddd + FOO2[b_FOO2]] = 123 Now, I need to check that the FOO1 shows along with the e_. That is, there can't be situation like this: 123 + FOO1[ccc + e_FOK1 ...] My simple question is how can I tell Perl to catch the FOO1 word for example ? I thought to search between 2 characters: " " an...

"Can't call method "dir_path" on an undefined value" when running Mason component on the command line

Greetings, I'm trying to develop some tests for Mason components which requires running them on the command line instead of the web server. When I try this, I get an error: perl -MHTML::Mason::Request -MHTML::Mason::Interp -I./lib \ -e '$int = HTML::Mason::Interp->new( data_dir => "/home/friedo/cache", comp_root => "/home/friedo/comps"...

In Perl, how can I get the fields in this CSV string into an array without spaces?

Hi, if I have a string, say: my $string = "A, B,C, D , E "; How can I put this into an array in Perl without the leading and trailing spaces? So what I want is only a single letter in each array element. What I currently do is this: my @groups = split /,\s*/, $string; But this is obviously not enough, as the trailing spaces are st...

What does this if statement containing very similar regular expression matches do?

What does this line of Perl mean? if (/ile.*= (\d*)/ || /ile.*=(\d*)/ ) { I am particularly interested in what the "/ile" means, and why both sides of the || are identical. ...

moving a perl script/dbm to a new server, and shifting out of dbm??

I've been tasked with mirroring a site onto a new server. The old site has a few Perl scripts that, as far as I can see internally (i know nothing about Perl, though I have a pretty good understanding of coding generally, and specifically PHP/js/etc) aren't reliant on the old server. That said, when I try to run this script, which looks ...

Preventing DBIx::Class from calling everything related to a new, not-yet-inserted row?

I have a parent/child relationship in my schema. I'd like to use very similar code to modify an existing parent as to create a new one. The edit case is easy to find the children: my $parent = $resultset->find($parent_id); my @children = $parent->children->all However, in the new case, something weird happens: my $parent = $resultset...

Use PHP or Perl to properly rotate JPEG images

I used F-Spot on Ubuntu to rotate some photos (JPEG files) before I FTPed them up to my website. This seemed to work just fine. However, if those images are opened in a web browser, they do not show as rotated. Nor do they if I download them to a Windows Vista machine and open them with any standard program there. I suspect that F-Spot r...

Why does my XSD file fail to parse with XML::LibXML?

I am trying to validate an XML against schema using LibXML::Schema Validator CPAN module. In that same script am using XML::DOM CPAN module to parse the XML. I want my script to take XML file validate it against XSD and parse it. When I try to run the script, after validating against xsd it exits and does not parse XML. I want it parse...

Matching a string against a list of words

Say I have the string "i zipped the fezz and it blipped like a baa" and I have an array of words (moo, baa, zip, fjezz, blaa) that I wanted to test to see it they're contained in the string, is there a way of doing so without either using | in the regex or iterating over each word? TIA ...

perl subroutine call

I have a Perl file like this: use strict; f1(); sub f3() { f2(); } sub f1() {} sub f2() {} In short, f1 is called before it is defined. So, Perl throws a warning: "f1 called too early to check prototype". But same is the case with f2, the only diff being that it is called from inside another subroutine. It doesn't throw a warning fo...

How can I use sockets in Perl? Is there a module?

How to do socket programing in Perl? Is there any module for it? I am trying to do socket programming in Perl. I want to know if there are any modules to do this. And another one question: Is it possible to do the multiple servers listen to one port, or multiple client listen to one port through socket programming? ...

How to automate perl script in Delphi?

Currently, I am working in a delphi application. I need to run perl script from the delphi application. To be more clear, manually we are executing the perl script in unix window. Now I need to automate the execution of that perl script from the application. I tried using ShellExecute: ShellExecute(Handle, 'open', PChar('C:\loaderperl...

Perl CGI Hook is not working as expected.

Hi all, I have problems using the perl cgi hook. It seems that after I pressed the "send" button my perl script is not called instandly but after the file is uploaded completely. That might be because of a server setting. Was anyone faced with this problem before? Update: The reason was the pre installed: Apache Security Module Th...

How do I create then use long Windows paths from Perl?

I have part of a build process that creates a hideously long path in Windows. It's not my fault. It's several directories deep, and none of the directory names are abnormally long; they're just long and numerous enough to make it over MAX_PATH (260 chars). I'm not using anything other than ASCII in these names. The big problem is that t...

Is there a Perl substitute for the cut and paste shell commands?

I saw once a quick and dirty Perl implementation for the cut and paste linux commands. It was something like perl 'print "$F1"' filename to substitute a cut -f1 filename command Can someone tell me how was this Perl way? Specifically, I'm interested because this, unlike cut/paste, will work the same also in Windows environments. ...

How can I find all matches to a regular expression in Perl?

I have text in the form: Name=Value1 Name=Value2 Name=Value3 Using Perl, I would like to match /Name=(.+?)/ every time it appears and extract the (.+?) and push it onto an array. I know I can use $1 to get the text I need and I can use =~ to perform the regex matching, but I don't know how to get all matches. ...

How can I remap the keyboard with Perl on Win32?

I want to remap the keyboard with Perl on Win32 system. Is there any option to do that? If yes, could you provide an example? Remapping the keyboard means form example when the user presses a, he gets b or something else according to the remapping). ...

Perl mail message error handling

I'm trying to quickly process inbound messages through a postfix mail server. I need a way to log and classify bounced mails. I want to determine the error code from the message to tell if it was a mailbox full or host unknown. Is there a perl module that can parse the message and give me the error code? ...

How can I disable terminal-polling for cpan used from crontab?

I'd like to have all the installed CPAN modules updated automatically every night, so I've placed the following command in the crontab: @daily cpan -i $(cpanp -o | perl -lane 'print $F[3]') However, whenever this is run I get the following error message: Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work. The COLUMNS and L...

Odd Perl conditional operator behavior

I'm doing some work in Perl and I ran across an odd result using the conditional operator. The code in question: ($foo eq "blah") ? @x = @somearray : @y = ("another","array"); Trying to compile this code results in the error "Assignment to both a list and a scalar at XXX line YY, near ');'". In trying to pinpoint the source of the er...