perl

How do I test if a perl command embedded in a bash script returns true?

So, I have a bash script inside of which I'd like to have a conditional which depends on what a perl script returns. The idea behind my code is as follows: for i in $(ls); do if $(perl -e "if (\$i =~ /^.*(bleh|blah|bluh)/) {print 'true';}"); then echo $i; fi; done Currently, this always returns true, and when I tried it ...

Should be there newSVuv intead newSVnv in perlxstut?

I'm just going through perlxstut and I found there newSVnv in EXAMPLE 5 and EXAMPLE 6 but I think that newSVuv should be more appropriate. Curiously newSVnv works too. What's going on? ...

In Perl, how do I safely create a temporary FIFO?

To compare with diff adjacent records from a file, I created two FIFOs, forked children to supply their write ends, and captured the output of diff -ub $previous $current where the scalars contain the FIFOs’ paths—kind of how bash process substitution works. This is not a program that needs to be bullet-proof, but if it were, how wou...

How do I get continuous tags with HTML::TokeParser

Hi, I have html that looks like this, <div> <span>Text <a href="example.html">ABC</a> <a href="example.html">DEF</a> <a href="example.html">HIJ</a> <a href="example.html">KLM</a> </span> <p class="Time"> 09/28/10 - 03:46 PM EDT</p> </div> I need to loop through the <a> tags between the <span> ...

Difference between Catalyst and Mason

Hi, I wanted to know how do Catalyst and Mason differ. Do they both do similar things? I have heard that amazon uses Mason for their websites. Can catalyst be used in similar manner? ...

Why can't my Perl script find the file when I run it from Windows?

I have a Perl Script which was built on a Linux platform using Perl 5.8 . However now I am trying to run the Perl Script on a Windows platform command prompt with the same Perl version. I am using this command perl rgex.pl however it gives me one whole chunk of errors which looks to me like it has already been resolved in the script it...

How do I output error for DNS resolve in Perl?

I have currently a DNS Reverse lookup script which works however there is a small little issue of the script being able to output the DNS system errors. The problems goes like this: User keys in false/wrong internet address name etc. "www.whyisthednsnothappening.com" The script would then clear the screen using system(clear) The scrip...

Is it ok to create shared variables inside a thread?

I think this might be a fairly easy question. I found a lot of examples using threads and shared variables but in no example a shared variable was created inside a thread. I want to make sure I don't do something that seems to work and will break some time in the future. The reason I need this is I have a shared hash that maps keys to ...

Is it possible for a Perl script running on a Unix/Linux platform to create Windows Shortcuts?

If I want to create a *nix symlink, I'll call symlink();, if i'm running a script on windows and I want to create a shortcut, I'd use Win32::Shortcut. But what if I want to create a Windows shortcut if running a script from a *nix machine? I'm accessing a SMB share on a Windows Server 2003 machine from my *nix machine. ...

check field formmail

Hi, i am trying to change this: foreach $require (@Required) { # If the required field is the email field, the syntax of the email # # address if checked to make sure it passes a valid syntax. # if ($require eq 'email' && !&check_email($Config{$require})) { push(@error,$require); } ...

Why doesn't my WWW::Mechanize submit a PayPal form work?

Nothing I've tried can get my code to submit correctly. Can anyone else figure this out? #!/usr/bin/perl use WWW::Mechanize; my $user = '[email protected]'; my $pass = 'hackswipe'; # Test account; don't worry my $browser = WWW::Mechanize->new(); $browser->get("https://www.paypal.com/"); $browser->form_with_fields("login_e...

How can I redirect STDOUT and STDERR to a log file in Perl?

Possible Duplicate: Can I send STDOUT and STDERR to a log file and also to the screen in Win32 Perl? I would to to redirect STDOUT, STDERR to temp_log and then to logfile.txt after the process is complete. The process runs for complete 20 minutes thus I would like to flock the temp_log in the time process runs. ...

How can I get started with Monte Carlo simulations for financial data in Perl?

I need to create a Monte Carlo simulator for some financial transactions. The inputs would be: the average percent of transactions that end up profitable the average profit per transaction the number of transactions per time period I've looked at the Math::Random::MT::Auto Perl module but am unsure how to formulate the inputs to the...

How can I update my Twitter status with Perl and only LWP::UserAgent?

I'm trying to update my status through the Twitter API and OAuth. I get stuck on the last step, the status update. Here's my code. The header: $ua->default_header('Content-Type' => "application/x-www-form-urlencoded"); $ua->default_header('oauth_signature' => "$signature"); $ua->default_header('Authorization' => '"OAuth realm="Twitter...

How can I quickly fix EBCDIC control characters in large files using Perl?

My apologies if this comes across as a newbie question. I'm not a Perl developer, but am trying to use it within an automation process, and I've hit a snag. The following command runs quickly (a few seconds) on my Linux system (Ubuntu 9.10 x64, Perl 5.10), but is extremely slow on a Windows system (Windows 2003 x86, Strawberry Perl 5.12...

How can I transfer a file using scp without a password from a Perl script?

I am writing a Perl script that needs to transfer files between computers using scp. I know about public key authentication, but I need the script to be fully automated, so I can't visit the machines to set up the keys before the script is run. Is there any way to either pass the password to scp from the Perl script or set up the keys f...

Is there a better way to achieve this using Perl?

I am writing a Perl script which does this : Reads the values of the environment variables a to z in a loop. Depending on the value of the environment variables, generates a result file similar to a - 1,2,3,4 b - a,b,c c - $234.34,$123.12 keyword1 %a% keyword2 %b% keyword3 %c% The point to note is that all the declarations have to c...

How can I set library and include paths for Makefile.PL for a single installation?

How can I tell CPAN to give Makefile.PL one specific argument in one specific installation? Specifically. I want to install XML::LibXML, and apt-get installed the library to /usr/lib/libxml2.so.2.6.32. Makefile.PL has problems with that and tells me: using fallback values for LIBS and INC options: LIBS='-L/usr/local/lib -L/usr/lib -l...

Perl sorting; dealing with $a, $b package globals across namespaces cleanly

Suppose I have a utility library (other) containing a subroutine (sort_it) which I want to use to return arbitrarily sorted data. It's probably more complicated than this, but this illustrates the key concepts: #!/usr/local/bin/perl use strict; package other; sub sort_it { my($data, $sort_function) = @_; return([sort $sort_fun...

How can I access values in a 2-D Perl array so I can have them in scalar variables?

I seem to recall (though can't find any reference now) to one being able to do something akin to my @a = ("foo","bar"); my ($item1, $item2) = @a; The above does not do what I want it to (obviously) but I seem to recall that there is some way to do this, where it loads the items associated with the order of the scalars in the parenthes...