perl

How do I extract a substring from this string?

I have a string that looks like: /somedir/ref/some-dir/foo.word How could I extract foo from the above string? The whole string, including foo may vary, however, the structure is always the same. It will always the letters between the last slash and the last dot. ...

How can I pretty print DBIx::Class results?

I'd like to pretty-print DBIx::Class::ResultSet results like this: my $schema = MyDatabase::Main->connect('dbi:SQLite:db/example.db'); my $rs = $schema->resultset('Track')->all() # then print $rs with all of those feilds I found DBIx::SQLCrosstab::Format class but it seems to work only with own queries. ...

How can my Perl script determine whether an Excel file is in XLS or XLSX format?

I have a Perl script that reads data from an Excel (xls) binary file. But the client that sends us these files has started sending us XLSX format files at times. I've updated the script to be able to read those as well. However, the client sometimes likes to name the XLSX files with an .xls extension, which currently confuses the heck...

How can I access UNC paths from inside a Perl CGI program under IIS6?

For space reasons, we need to move some files off our main file/webserver to another network fileserver. However, the original file/webserver is still responsible for providing access to these files, so that everything is seamless to the users. I can provide transparent file access by using DFS on the original server. I can also provi...

How can I include doxygen perlmod in my perlscript?

Hi How can I include doxygen perlmod in my perlscript? I've noticed that you can generate a alternative output with doxygen that is called perlmod, but I can't find any examples on how to use this part. I've found 2 nice files in there DoxyDocs.pm and DoxyStructure.pm, and they contain some kind of nice structure that represents th...

Why does the line-by-line stats for NYTProf not match the totals?

I have a Perl script that takes about 30 minutes to run, so of course I run Devel::NYTProf. Great profiler. For many of my subs, I'm getting some data that doesn't make sense to me. I'm running with perl 5.10.0 on Linux using the default NYTProf settings. In the HTML output, each of the subs has a summary section stating how much time ...

How can I calculate the distance between two points in Perl?

I need help with a homework assignment for my beginner computer science class. I am completely lost! I need to write a program in Perl that will calculate the distance between 2 points with three values (x,y,z) by the given formula by my professor. the program must do the following: prompt for 'c' to continue 'q' to quit prompt for th...

Why doesn't my Perl variable have the right value outside the if() block?

I have a hash, where the keys and values are from matches in a regular expression. I'm having difficulty extracting the values given the keys. In the interest of brevity and honing in on the problem, my first version of this post I attempted to strip down my program to only the relevant parts, but it wasn't enough, so here's more. Variab...

Will this Perl program work on Windows???

Hi All, I am trying to open multiple processes in a Perl script on Windows. Program structure would look some thing like this... my($chld1_out, $chld1_in); my($chld2_out, $chld2_in); my($chld3_out, $chld3_in); my @cmds1=(); my @cmds2=(); my @cmds3=(); $pid1 = open2($chld1_out, $chld1_in, 'ex1.exe')or die $!; $...

Perl: hash-keys have lost their class information

Hi there, I have a package X.pm with a method data_x(); I use instances of class X as keys of a hash %seen, say. Now the elements of keys %seen seem to have forgotten their blessing: use X; my( $x, $y, %seen ); $x = X->new(); $x->data_x( 1 ); print " x: ", $x, "\n"; print " x.data: ", $x->data_x(), "\n"; $seen{ $x } = 1; $y =...

perl Get indexes of matches in array

Hi There! I want to search for an element in an array. What I want to get from this search is the all the indices of the array where I find a match. So, for example the word I want to search is : $myWord = cat @allMyWords = my whole file with multiple occurrances of cat in random positions in file So, if cat occurs at 3rd, 19th and...

Why are the images included in cgi page not getting displayed in browser?

Hello everyone,I hope everyone's doin good. I am facing an issue regarding the images, i have a cgi page i.e Login.cgi, in tha html section i have included some images but some are getting displayed and some are not. Here's the code: #!C:\perl\bin\perl.exe use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use stri...

how to find the file is created or updated current date/day

how to find the file is created or updated current date/day ...

Finger Code in perl - Not able to execute

Error: Syntax error: end of file unexpected Below is the Code I changed. "#!/usr/local/bin/perl" The actual program is #!/local/perl5/bin/perl5.003 use Socket; $sockaddr = 'S n a4 x8'; $host = $ARGV[0]; $them = $host; $port = 79; print "Finger $host: \n"; $hostname = ``; `nslookup $host |grep Name: >> $test`; print $test; #($...

Finding Paths in Directed Graph with Greedy Approach With At Least K Nodes and a Given Starting Node

I have a non-weighted DAG graph. What I want to do is to find all the paths in a greedy way and the path should contain at least K nodes, and a given starting node. Is there any existing algorithm/implmentation that does that? For example I have the following graph: my %graph =(36=>[31],31=>[30,22],30=>[20],22=>[20,8],20=>[1],8=>[5],...

What is the purpose of Parse::CPAN::Authors?

What is the purpose of the Parse::CPAN::Authors module? use Parse::CPAN::Authors; # must have downloaded my $p = Parse::CPAN::Authors->new("01mailrc.txt.gz"); # either a filename as above or pass in the contents of the file my $p = Parse::CPAN::Authors->new($mailrc_contents); my $author = $p->author('LBROCARD'); # $a is ...

How to convert a decimal number to hex string in Perl?

For example I would like to convert 2001 into: "0x07", "0xD1" Thanks ...

Handling multiple perl scripts in windows command prompt

Hi, I have a lot of perl scripts that are on infinite loop running on my windows system. It is terribly inconvenient to have that many command prompts open not to mention the likelihood of closing them by mistake(strangely, they also seem to pause when I click on the prompt) Is there someway I can handle this? Like maybe minimize this ...

How can I make perl recognize paths with '~' ?

Possible Duplicate: How do I find a user's home directory in Perl? I'm running Ubuntu. Whenever I pass a Perl script a path that starts with ~ (e.g. ~/Documents/file.txt) it fails finding it. I must pass the canonical path (e.g. /home/dave/Documents/file.txt). Why is that? Can I make perl recognize ~ paths? UPDATE All th...

How can I find the connected components of a graph in Perl?

I have the following collection of nodes and edges. What I want to do is to find all the distinct graph from it. my %connections=(36=>[31],10=>[3,4],31=>[30,22],30=>[20],22=>[20,8],20=>[1],8=>[5],5=>[2],2=>[1,20], 3=>[7]); In this example it will yield: my %all_graph = { graph1 => {36=>[31],31=>[30,22],30=>[20],22=>[20,8],20=>[1...