perl

what does this line do in Perl? ($rowcol =~ m/([A-Z]?)([0-9]+)/);

What does this line do in Perl? my @parsedarray = ($rowcol =~ m/([A-Z]?)([0-9]+)/); $rowcol is something like A1, D8 etc... and I know that the script somehow splits them up because the next two lines are these: my $row = $parsedarray[0]; my $col = $parsedarray[1]; I just can't see what this line does ($rowcol =~ m/([A-Z]?)([0-9]+...

What's the difference between my ($variableName) and my $variableName in Perl?

What's the difference between my ($variableName) and my $variableName in Perl? What to the parentheses do? ...

How can I use arbitrary length integers in Perl?

Is there any standard way to use integers of arbitrary length in Perl? I am working on code that generates x64 assembly for tests, and I'm tired of manipulating 32 bits at a time. I'm using Perl 5.10.0, for what it's worth. ...

How can I get the HTTP status and Location header in Perl?

Hi, I'm new to Perl but need to use it on a project I'm working on. What I need to do is check to see if a URL has a 301 redirect and if it has, get the location. The following told me the code but not the location: use strict; use warnings; require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; $ua->ma...

How do I run a Perl one liner from a makefile?

I know the perl one liner below is very simple, works and does a global substitution, A for a; but how do I run it in a makefile? perl -pi -e "s/a/A/g" filename I have tried (I now think the rest of the post is junk as the shell command does a command line expansion - NOT WHAT I WANT!) The question above still stands! APP = $(shell p...

How do I completely change the appearance of a Win32 title bar from Perl?

I'm learning to add GUI to my Perl program using Win32::GUI. Now I can change the icon of a Win32 title bar using something like: $myicon = new Win32::GUI::Icon('myicon.ico'); $myclass=new Win32::GUI::Class( -name=>'myclass', -icon=>$myicon, ); $mydialogbox = new Win32::GUI::DialogBox( -name => 'my...

How do I fix "perl is not recognized" on Windows?

I've set up a log file to pick up MySQL slow queries. I've been unable to parse the file however. Linux makes this task seem very simple. In tutorials it seems as easy as: $ mysqldumpslow -s c -t 10 In Windows however, I'm not sure how you run Perl, located in: G:\xampp\perl\bin with the Perl Script mysqldumpslow.pl, located in: G:\...

How can I store entire contents of a Perl array to a scalar variable?

How can I store entire contents of an array to a scalar variable. eg: my $code = do { local $/; <FILE HANDLE>; }; This works fine for file handles but I need this for an array. ...

Why does my Perl open() fail with "Unsuccessful open on filename containing newline"?

I tried to placed ${date[0]} in my directory which is equivalent to 01252010 but @hits not printed. How can I managed to open the directory to get the desired output? Thanks. ERROR: Unsuccessful open on filename containing newline at ./total.pl line 11, line 1. #!/opt/perl/bin/perl -w use strict; open(FH,"/home/daily/scripts/sms_...

How can I replace text that is not part of an anchor tag in Perl?

What is a Perl regex that can replace select text that is not part of an anchor tag? For example I would like to replace only the last "text" in the following code. blah <a href="http://www.text.com"&gt; blah text blah </a> blah text blah. Thanks. ...

How can I match certain nested parentheses in Perl?

^\s*[)]*\s*$ and ^\s*[(]*\s*$ matches the parentheses ( and ) which are bold. That is, what am trying is to ignore parentheses that are single and not (condition1) parentheses: while ( #matches here ( #matches here (condition1) && (condition2) && condition3 ) || (#matches here (condition4) || ...

How can I correctly calculate the lengths of fields in a CSV dcoument using Perl?

I have a datas et and like to do a simple while operation with a Perl script. Here is a small extraction from the dataset: "number","code","country","gamma","X1","X2","X3","X4","X5","X6" 1,"DZA","Algeria","0.01",7.44,47.3,0.46,0,0,0.13 2,"AGO","Angola","0.00",6.79,"NULL",0.21,1,0,0.28 3,"BEN","Benin","-0.01",7.02,38.9,0.27,1,0,...

How can I insert array data into MySQL in Perl?

I parse a text file with the script below. How to insert the array data to MySQL table? I already learned Perl MySQL DBI connect method. And I can connect to local MySQL DB successfully. I can create the table with MySQL command line. #!C:\Perl\bin\perl.exe use strict; use warnings; while ( <DATA> ) { my @rocks = split(/\s+/, ...

Randomize matrix in perl, keeping row and column totals the same

I have a matrix that I want to randomize a couple of thousand times, while keeping the row and column totals the same: 1 2 3 A 0 0 1 B 1 1 0 C 1 0 0 An example of a valid random matrix would be: 1 2 3 A 1 0 0 B 1 1 0 C 0 0 1 My actual matrix is a lot bigger (about 600x600 items), so I really nee...

How can I fire and forget a process in Perl?

Can somebody please tell me how to fire-and-forget a process in Perl? I've already looked at ruby: how to fire and forget a subprocess? for doing the same in Ruby. ...

Does Perl have something like Java/PHP Docs?

Does Perl have a Perl Docs generator? Something like Java Docs or PHP Documenter? ...

Does using undef as hash values save any memory in Perl?

A Perl idiom for removing duplicate values from an array: @uniq = keys %{{map{$_=>1}@list}} Is it cheaper to use this version: @uniq = keys %{{map{$_=>undef}@list}} I tested it with these one-liners, and seems that it is true on some versions of Perl: perl -e 'my %x; $x{$_} = 1 for 0..1000_000; system "ps -ovsz $$"' perl -e 'my ...

DBD::mysql: How can I write with "SELECT * INTO file" to my home-directory?

Hello, is there a way to make this work? (write the out_file to my home-directory) #!/usr/bin/perl use warnings; use strict; use File::Spec::Functions; use File::HomeDir; use DBI; my $database = 'my_db'; my $table = 'my_table'; my $user = 'user'; my $passwd = 'password'; my $dbh = DBI->connect( "DBI:mysql:$database;", $user, $passwd,...

How can I read Excel files in Perl?

I am looking for some examples/advice on how to write a Perl script to read data from an excel file then use the data read in (as a string hopefully) and pass it to another Perl file (as an argument). The goal is to have a table in which the user can type some data (ftp destination or filename) into the table. Then my program will grab...

How do I get the Perl's DateTime::Format::DateManip version number from the command line?

I'm using this from the command line: perl -MDateTime::Format::DateManip -le 'print $Some::Module::VERSION' but only return a blank line, any thoughts? ...