FAQ 4.23 How do I find matching/nesting anything?


This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
Posted On: Thursday 15th of November 2012 08:54:05 PM Total Views:  100
View Complete with Replies

RELATED TOPICS OF Perl PROGRAMMING LANGUAGE




find an entry in hash array

Is there a way to find out if an entry exists in a hash array e.g. I have a hash array and another normal array. I would like loop though regular array and see if the entries defined in this array exist in hash array.
VIEWS ON THIS POST

112

Posted on:

Wednesday 7th November 2012
View Replies!

Please let me know where can I find practice exercises

I am currently learning perl programming. Please help me by giving some practice exercises or direct me to the site where i can find them.
VIEWS ON THIS POST

100

Posted on:

Wednesday 7th November 2012
View Replies!

cant find locally installed module

I have installed permute module locally and added the path to my script. However, perl fails to find the module. The script: #!/usr/bin/perl use lib "/u/basappas/local/perl/Algorithm-Permute-0.06"; use Algorithm::Permute; my @array = (1..9); Algorithm::Permute:ermute { print "@array\n" } @array; The files under /u/basappas/local/perl/Algorithm-Permute-0.06: bench Changes Makefile.PL META.yml Permute.c Permute.pm pm_to_blib typemap blib Makefile MANIFEST Permute.bs Permute.o Permute.xs test.pl The error: Can't locate Algorithm/Permute.pm in @INC (@INC contains: /u/basappas/local/perl/Algorithm-Permute-0.06 /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5 /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.4/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.3/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.1/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl/5.8.4 /usr/lib/perl5/vendor_perl/5.8.3 /usr/lib/perl5/vendor_perl/5.8.2 /usr/lib/perl5/vendor_perl/5.8.1 /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at Perm.pl line 3. BEGIN failed--compilation aborted at Perm.pl line 3. Please let me know if I am missing something...
VIEWS ON THIS POST

156

Posted on:

Wednesday 7th November 2012
View Replies!

Fastest way to find a match?

I'm trying to find the fastest way in perl to see if a name contains another. I've a list of 2704 names (aka "A") I've another name (aka "B") I need to know if any of A is contained in B. A = foo foo1 foo2 foo3 foo45 .... B = INCASE_foo2_YOUWANT is a match B = INCASE_YOURDONOTWANT is not a match. what would be the fastest way to check the 2704 possible values of "A"
VIEWS ON THIS POST

81

Posted on:

Wednesday 7th November 2012
View Replies!

FAQ 4.35 How do I find the soundex value of a string?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 4.35: How do I find the soundex value of a string (contributed by brian d foy) You can use the Text::Soundex module. If you want to do fuzzy or close matching, you might also try the "String::Approx", and "Text::Metaphone", and "Text:oubleMetaphone" modules. -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

72

Posted on:

Wednesday 7th November 2012
View Replies!

FAQ 4.12 How do I find the day or week of the year?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 4.12: How do I find the day or week of the year The localtime function returns the day of the year. Without an argument localtime uses the current time. $day_of_year = (localtime)[7]; The "POSIX" module can also format a date as the day of the year or week of the year. use POSIX qw/strftime/; my $day_of_year = strftime "%j", localtime; my $week_of_year = strftime "%W", localtime; To get the day of year for any date, use "POSIX"'s "mktime" to get a time in epoch seconds for the argument to localtime. use POSIX qw/mktime strftime/; my $week_of_year = strftime "%W", localtime( mktime( 0, 0, 0, 18, 11, 87 ) ); The "Date::Calc" module provides two functions to calculate these. use Date::Calc; my $day_of_year = Day_of_Year( 1987, 12, 18 ); my $week_of_year = Week_of_Year( 1987, 12, 18 ); -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

103

Posted on:

Wednesday 7th November 2012
View Replies!

FAQ 4.16 How can I find the Julian Day?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 4.16: How can I find the Julian Day (contributed by brian d foy and Dave Cross) You can use the "Time::JulianDay" module available on CPAN. Ensure that you really want to find a Julian day, though, as many people have different ideas about Julian days. See http://www.hermetic.ch/cal_stud/jdn.htm for instance. You can also try the "DateTime" module, which can convert a date/time to a Julian Day. $ perl -MDateTime -le'print DateTime->today->jd' 2453401.5 Or the modified Julian Day $ perl -MDateTime -le'print DateTime->today->mjd' 53401 Or even the day of the year (which is what some people think of as a Julian day) $ perl -MDateTime -le'print DateTime->today->doy' 31 -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

96

Posted on:

Wednesday 7th November 2012
View Replies!

FAQ 8.1 How do I find out which operating system I'm running under?

This is an excerpt from the latest version perlfaq8.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 8.1: How do I find out which operating system I'm running under The $^O variable ($OSNAME if you use English) contains an indication of the name of the operating system (not its release number) that your perl binary was built for. -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

124

Posted on:

Wednesday 7th November 2012
View Replies!

Re: find2perl

oryann9> No, but good point. My intent was to determine when -prune was set on oryann9> the CLI what the De-parsed code told me, 1==true, 0==false because oryann9> when I run this code below prune = 0 is not working, its descending oryann9> down "/". You're misusing it. Set it within the wanted() routine when you're looking at a directory that you don't want to descend. It'll be cleared to 0 before calling wanted(), so setting it before calling find() is completely useless. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. - __OUTPUT__ main:find_hog:47): if ( $fs eq "/" ) { # only if the root directory DB print $fs / DB n main:find_hog:48): find_me ( $fs, 0 ); DB n print caller find_me main:find_hog:61): my ( @sorted_large_files, @large_files ) ; DB main:find_hog:80): if (@sorted_large_files) { DB print caller find_me invalid top directory at /opt/perl/lib/5.8.2/File/Find.pm line 568, line 1. DB print $fs / DB n main:find_hog:81): my %meta ; DB n main:find_hog:82): for my $file (@sorted_large_files) { DB n main:find_hog:83): $meta{$file} = { main:find_hog:84): 'uid' => (stat($file))[4], main:find_hog:85): 'gid' => (stat($file))[5], main:find_hog:86): 'sz' => (stat($file))[7], main:find_hog:87): 'mod' => (stat($file))[9], DB print $file /data/data01/recovery/archives/dubhdv04/2007-11-15,11:21 DB /data/... should not be appearing if prune set to false, or 0. __CODE__ Is this what you mean on line 9 I tried and it does not seem to work, meaning it still descending. 1 sub find_me { 2 use Data:umper; 3 my $fs = shift; 4 #local $File::Find:rune = shift; ##-- localize prune to just this block --## 5 #my @directory = ($fs) ; 6 use constant MAX_SIZE => (25*1024*1024) ; 7 use constant DIVISOR => (1024) ; 8 my ( $wanted, $list ) = find_by_min_size ( MAX_SIZE ) ; 9 File::Find::find ( { wanted => $wanted, prune => $File::Find:rune = shift}, $fs ) ; 10 @large_files = $list->() ; 11 12 @sorted_large_files = 13 sort { -s $b -s $a } 14 @large_files ; 15 16 } ##-- End sub --## ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
VIEWS ON THIS POST

63

Posted on:

Wednesday 7th November 2012
View Replies!

[RESOLVED]Re: How to find version of a module

nm. I was able to get the version by running perl -MDBD::Oracle -e 'print "$DBD::Oracle::VERSION\n"'
VIEWS ON THIS POST

77

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 4.23 How do I find matching/nesting anything?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

84

Posted on:

Saturday 10th November 2012
View Replies!

Can't find string terminator "EOHTML" anywhere before EOF

Hi I just copied this script from CGI::Ajax manual at cpan.org page use strict; use CGI; # or any other CGI:: form handler/decoder use CGI::Ajax; my $cgi = new CGI; my $pjx = new CGI::Ajax( 'exported_func' => \&perl_func ); print ...
VIEWS ON THIS POST

94

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 7.26 How can I find out my current package?

This is an excerpt from the latest version perlfaq7.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

105

Posted on:

Saturday 10th November 2012
View Replies!

how to find how many items are in a reference?

How can I find how many items are there in a reference Let's say we first make: my $data = $db->selectall_arrayref("SELECT * FROM table"); Now, I can access any data with: print $$hardware[X][Y]; How can I find the maximum element ...
VIEWS ON THIS POST

152

Posted on:

Saturday 10th November 2012
View Replies!

Re: find2perl

---- Original Message ---- From: Randal L. Schwartz To: oryann9 Cc: Perl List Sent: Thursday, January 17, 2008 7:04:40 PM Subject: Re: find2perl >>>>> "oryann9" == oryann9 writes: oryann9> No one from perlmonks seems to know ...
VIEWS ON THIS POST

77

Posted on:

Saturday 10th November 2012
View Replies!

FAQ 8.37 How do I find out if I'm running interactively or not?

This is an excerpt from the latest version perlfaq8.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

70

Posted on:

Sunday 11th November 2012
View Replies!

FAQ 7.26 How can I find out my current package?

This is an excerpt from the latest version perlfaq7.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

101

Posted on:

Sunday 11th November 2012
View Replies!

FAQ 9.23 How do I find out my hostname, domainname, or IP address?

This is an excerpt from the latest version perlfaq9.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest ...
VIEWS ON THIS POST

83

Posted on:

Sunday 11th November 2012
View Replies!

file::find

Perl'ers, In my code I call a find routine called xyz based on what the user enters which can be "/" or /\w+. Instead of having one block of code and another block of the same code, but with $File::Find: ...
VIEWS ON THIS POST

51

Posted on:

Monday 12th November 2012
View Replies!