perl

How can I enter a password using Perl and replace the characters with '*'?

I have a Perl script that requires the user to enter a password. How can I echo only '*' in place of the character that the user types, as they type it? I'm using Windows XP/Vista. ...

How can I fix Net::Amazon::MechanicalTurk's failing tests?

I'm using Perl 5.10.0 on Debian Linux (testing) and trying to install the Perl module Net::Amazon::MechanicalTurk version 1.01. When I run the module's test suite, I get errors such as the following: t/01-ListOperations.......................Can't locate object method "new" via package "Net::Amazon::MechanicalTurk::Transport::RESTTran...

How can I create a directory if one doesn't exist using Perl?

Currently, my Perl output is hard-coded to dump into the following UNIX directory: my $stat_dir = "/home/courses/".**NEED DIR VAR HERE**; The filename is built as such: $stat_file = $stat_dir . "/".$sess.substr($yr, 2, 2)."_COURSES.csv"; I need a similar approach to building UNIX directories, but need to check if they exist first b...

How can I handle secondary authentication in Google Mail from Perl?

This is a pure Google Mail question. I am accessing Google Mail via Perl's Net::SMTP::SSL module. From time to time the authentication fails not because of a bad password, but because of some additional password check. The only way to unlock it is via the web interface with an additional entry of text presented as an image. Has anyone s...

How do I create drag-and-drop Strawberry Perl programs?

I've got a Strawberry Perl program that accepts a single-file as a command-line argument. How can I set things up such that I can drag and drop the desired file onto the Strawberry Perl program (or a wrapper around it) and the program runs with that file's name as an argument? ...

Is there a Perl equivalent to Python's `if __name__ == '__main__'`?

Is there a way to determine if the current file is the one being executed in Perl source? In Python we do this with the following construct: if __name__ == '__main__': # This file is being executed. raise NotImplementedError I can hack something together using FindBin and __FILE__, but I'm hoping there's a canonical way of doi...

Why doesn't my awk one-liner work when I call it from Perl?

Dear all, I have no problem using the following command of AWK as a stand alone command, without any error: $ awk '$9 != "NTM" && $9 != ""' myfile.txt | less -Sn But when I apply them inside Perl's script for qsub (i.e. running job in linux cluster) command, like this: use strict; use Data::Dumper; use Carp; use File::Basename; my...

Why does a Lucene exact match only score 0.4?

I have a document that contains a title and a description. One of the item description contains "Shipping is free with Amazon Prime" among other words. I do a search with lucene for "Shipping is free with Amazon Prime" on the fields title and description using perl Lucene my $analyzer = new Lucene::Analysis::SimpleAnalyzer(); my @field...

Why do I see HASH(0xABCDEF) in my Perl output?

I am running perl, v5.6.1 built for sun4-solaris-64int I am calling print on an array print "@vals\n"; and the output looks like HASH(0x229a4) uid cn attuid or another example @foo = {}; push(@foo, "c"); print "@foo I am done now\n"; with output of HASH(0x2ece0) c I am done now Where is HASH(0x2ece0) comming from? Thanks...

Is there a Perl module to monitor an email queue?

I'm working on an issue tracking system and would like the application to handle email replies. That is, I would like a script that can monitor an email queue and perform some action based on the email contents. It should then be able to delete the email, etc. I currently use MIME::Lite to send email, and I can handle writing the scri...

How can I store a timestamp in a DBM database?

I am implemening simple file-sharing service. Currently I use a file-based database (as it suits my needs). # somewhere in my cgi script sub first_run { my $dbh = DBI->connect('dbi:DBM:'); $dbh = DBI->connect("dbi:DBM:", "", "",{ AutoCommit => 1, RaiseError => 1, f_dir=>$DATABASE_DIR} ); unless ($dbh) {...

What warnings would you like a "warnins" pragma to throw?

Recently on the Perl5 Porters list a spelling error in a doc patch made me laugh: use warnins; I now feel compelled to write a "warnins" pragma which such sage advice as Yer usin' a variable that ain't got a value in addition (+) at z.pl line 8. instead of Use of uninitialized value in addition (+) at z.pl line 8. What ot...

Why can't I set $LIST_SEPARATOR in Perl?

I want to set the LIST_SEPARATOR in perl, but all I get is this warning: Name "main::LIST_SEPARATOR" used only once: possible typo at ldapflip.pl line 7. Here is my program: #!/usr/bin/perl -w @vals; push @vals, "a"; push @vals, "b"; $LIST_SEPARATOR='|'; print "@vals\n"; I am sure I am missing something obvious, but I don't see ...

How do I allow two concurrent processes to communicate?

I have two separate processes: a C program that outputs comma separated values followed by a newline every second, and a Perl program that accepts data (in the same format) and processes this data. The C program outputs (via printf) values as such: 1, 2, 3, 4, 5, 6 7, 8, 9, 10, 11, 12 ... The Perl program sits in an infinite lo...

Why does my non-greedy Perl regex match nothing?

Hi, I thought I understood Perl RE to a reasonable extent, but this is puzzling me: #!/usr/bin/perl use strict; use warnings; my $test = "'some random string'"; if($test =~ /\'?(.*?)\'?/) { print "Captured $1\n"; print "Matched $&"; } else { print "What?!!"; } prints Captured Matched ' It seems it has ...

How can I screen scrape with Perl?

I need to display some values that are stored in a website, for that I need to scrape the website and fetch the content from the table. Any ideas? ...

How can I rearrange my data to be (x,y) coordinates for GD::Graph?

I am writing a program that takes in an input file from the user. The file has bunch of numbers in it and I will read the numbers in the file and create a plot based on those numbers using GD::Graph. The first line of the file is X axis, second line of the file is Y values corresponding to X axis and third, fourth, ..., etc For example...

How can I remove all tokens with non-word characters in Perl?

I am trying to come up with a regex for removing all words that contain non-word characters. So if it contains a colon, comma, number, bracket etc then remove it from the line, not just the character but the word. I have this so far. $wordline = s/\s.*\W.*?\s//g; Does not have to be perfect so removing strings with dash and apostroph...

WWW::Mechanize and "HTTP::Message content must be bytes at..."

I'm writing simple program which has to change some data on Polish auction site. One of the steps involves loading edit page, changing one value, and submitting it. Sample page can be viewed here: http://depesz.com/various/new_item.php.html - this is just static copy of such edit page. Relevant part of my perl code: $agent->form_numb...

How can I write a caching HTTP proxy in Perl?

I intend to write a simple HTTP proxy in Perl using the HTTP::Proxy module. I'm clear with the very basic task of how to create a proxy and basic filters and stuff. But what I cannot understand is how to manually force-serve a file through cache. Basically, the scenario is this that I run this proxy in computer A. The user on computer ...