[25501] in Perl-Users-Digest
Perl-Users Digest, Issue: 7745 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 6 18:05:31 2005
Date: Sun, 6 Feb 2005 15:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 6 Feb 2005 Volume: 10 Number: 7745
Today's topics:
[ANN] Net::ChooseFName <nospam-abuse@ilyaz.org>
Connecting to a Domino Db <dummymb@hotmail.com>
Custom sort empties instead of sorting <groleau+news@freeshell.org>
Re: Exception handling in class: question (Anno Siegel)
Re: Newbie asking, interesting question (Anno Siegel)
Re: Newbie asking, interesting question <tadmc@augustmail.com>
Re: Perl - permute? <yyusenet@yahoo.com>
Re: Perl - permute? <yyusenet@yahoo.com>
Re: Perl - permute? <abigail@abigail.nl>
Re: Perl - permute? <postmaster@castleamber.com>
Re: Perl - permute? <dtrudgett@holdthespam_yahoo.com>
Perl Regex to search for ed2k links cmw@tulpje.co.uk
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 6 Feb 2005 20:43:54 GMT
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: [ANN] Net::ChooseFName
Message-Id: <IBIC96.EMp@zorch.sf-bay.org>
If you need (or thought of) something like this module, please comment
on features you miss. It took a lot of time to chip it out of my
version of recursive NET downloader; I may be able to spend some more
time to make it yet better...
Thanks,
Ilya
=======================================================
NAME
Net::ChooseFName - Perl extension for choosing a name of a local mirror
of a net (e.g., FTP or HTTP) resource.
SYNOPSIS
use Net::ChooseFName;
$namer = Net::ChooseFName->new(max_length => 64); # Copies to CD ok
$name = $namer->find_name_by_response($LWP_response);
$name = $namer->find_name_by_response($LWP_response, $as_if_content_type);
$name = $namer->find_name_by_url($url, $suggested_name,
$content_type, $content_encoding);
$name = $namer->find_name_by_url($url, $suggested_name, $content_type);
$name = $namer->find_name_by_url($url, $suggested_name);
$name = $namer->find_name_by_url($url);
$namer_returns_undef = Net::ChooseFName->failer(); # Funny constructor
DESCRIPTION
This module helps to pick up a local file name for a remote resource
(e.g., one downloaded from Internet). It turns out that this is a tricky
business; keep in mind that most servers are misconfigured, most URLs
are malformed, and most filesystems are limited w.r.t. possible
filenames. As a result most downloaders fail to work in some situations
since they choose names which are not supported on particular
filesystems, or not useful for "file:///"-related work.
Because of the many possible twists and ramifications, the design of
this module is to be as much configurable as possible. One of ways of
configurations is a rich system of options which influence different
steps of the process. To cover cases when options are not flexible
enough, the process is broken into many steps; each step is easily
overridable by subclassing "Net::ChooseFName".
The defaults are chosen to be as safe as possible while not getting very
much into the ways. For example, since "%" is a special character on
DOSish shells, to simplify working from command line on such systems, we
avoid this letter in generated file names. Similarly, since MacOS has
problems with filenames with 8-bit characters, we avoid them too; since
may Unix programs have problem with spaces in file names, we massage
them into underscores; the length of the longest file path component is
restricted to 255 chars.
Note that in many situations it is advisable to make these restrictions
yet stronger. For example, for copying to CD one should restrict names
yet more ("max_length => 64"); for copying to MSDOS file systems enable
option "'8+3' => 1".
[In the description of methods the $self argument is omitted.]
Principal methods
new(OPT1 => $val1, ...)
Constructor method. Creates an object with given options. Default
values for the unspecified options are (comments list in which
methods this option is used):
protect => # protect_characters()
# $1 should contain the match
qr/([?*|\"<>\\:?#\x00-\x1F\x7F-\xFF\[\])/,
protect_pref => '@', # protect_characters(), protect_directory()
root => '.', # find_directory()
dir_mode => 0775, # directory_found()
mkpath => 1, # directory_found()
max_suff_len => 4, # split_suffix() 'jpeg'
keepsuff_same_mediatype => 1, # choose_suffix()
type_suff => # choose_suffix()
{'text/ftp-dir-listing' => '.dirl'}
keep_suff => { text/plain => 1,
application/octet-stream => 1 },
short_suffices => # eight_plus_three()
{jpeg => 'jpg', html => 'htm',
'tar.bz2' => 'tbz', 'tar.gz' => 'tgz'},
suggest_disposition => 1, # find_name_by_response()
suggested_only_basename => 1, # find_name_by_response(), raw_name()
fix_url_backslashes => 1, # protect_characters()
max_length => 255, # fix_dups(), fix_component()
cache_name => 1, # name_found()
queryless_types => # url_takes_query()
{ map(($_ => 1), # http://filext.com/detaillist.php?extdetail=DJV 2005/01
qw(image/djvu image/x-djvu image/dejavu image/x-dejavu
image/djvw image/x.djvu image/vnd.djvu ))},
queryless_ext => { 'djvu' => 1, 'djv' => 1 }, # url_takes_query()
The option "type_suff" is special so that the user-specified value
is *added* to this hash, and not *replaces* it. Similarly, the value
of option "html_suff" is used to populate the value for "text/html"
of this hash.
Other, options have "undef" as the default value. Their effects are
documented in the documentation of the methods they affect. With the
exception of "known_names", these options are booleans.
html_suff # new()
known_names # known_names() name_found(); hash ref or undef
only_known # known_names()
hierarchical # raw_name(), find_directory()
use_query # raw_name()
8+3 # fix_basename(), fix_component()
keep_space # fix_component()
keep_dots # fix_component()
tolower # fix_component()
dir_query # find_directory()
site_dir # find_directory()
ignore_existing_files # fix_dups
keep_nosuff, type_suff_no_enc, type_suff_fallback,
type_suff_fallback_no_enc # choose_suffix()
Summary of the most useful in applications options (with defaults if
applicable):
html_suff # Suffix for HTML (dot will be prepended)
root => '.', # Where to put files?
mkpath => 1, # Create directories with chosen names?
max_length => 255, # Maximal length of a path component
ignore_existing_files # Should the filename be "new"?
cache_name => 1, # Return the same filename on the same URL,
# even if file jumped to existence?
hierarchical # Only the last component of URL path matters?
suggested_only_basename => 1, # Should suggested name be relative the path?
use_query # Do not ignore the query part of URL?
# Value is used as (literal) prefix of query
dir_query # Make the non-query part of URL a directory?
site_dir # Put the hostname part of URL into directory?
keepsuff_same_mediatype # Preserve the file extensions matching type?
8+3 # Is the filesystem DOSish?
keep_space # Map spaces in URL to spaces in filenames?
tolower # Translate filenames to lowercase?
type_suff, type_suff_no_enc, type_suff_fallback, type_suff_fallback_no_enc,
keep_suff, keep_nosuff # Hashes indexed by lowercased types;
# Allow tuning choosing the suffix
find_name_by_url($url, $suggested_name, $type, $enc)
This method returns a suitable filename for the resource given its
URL. Optional arguments are a suggested name (possibly, it will be
modified according to options of the object), the content-type, and
the content-encoding of the resource. If multiple content-encodings
are required, specify them as an array reference.
A chain of helper methods ("Transformation chain") is called to
apply certain transformations to the name. "undef" is returned if
any of the helper methods (except known_names() and protect_query())
return undefined values; the caller is free to interpret this as
"load to memory", if appropriate. These helper methods are listed in
the following section.
find_name_by_response($response [, $content_type])
This method returns name given an LWP response object (and,
optionally, an overriding "Content-Type"). If option
"suggest_disposition" is TRUE, uses the header "Content-Disposition"
from the response as the suggested name, then passes the fields from
the response object to the method find_name_by_url().
Transformation chain
url_2resource($url [, $type, $encoding])
This method returns $url modified by removing the parts related to
access to *parts* of the resource. In particular, the *fragment*
part is removed, as well as the *query* part if url_is_queryless()
returns TRUE.
known_names($url, $suggested, $type, $enc)
The method find_name_by_url() will return the return value of this
method (unless undef) immediately. Unless overriden, this method
returns the value of the hash option "known_names" indexed by the
$url. (By default this hash is empty.)
If the option "only_known" is true, it is a fatal error if $url is
not a key of this hash.
raw_name($url, $suggested, $type, $enc)
Returns the 0th approximation to the filename of the resource; the
return value has two parts: the principal part, and the query string
("undef" if should not be used).
If $suggested is undefined, returns the path part of the $url, and
the query part, if present and if option "use_query" is TRUE).
Otherwise either returns $suggested, or (if options
"suggested_only_basename" and "hierarchical" are both true), returns
the *path* part of the $url with the last component changed to
$suggested; the query part is ignored in this case. In the latter
case, if option "suggested_basename" is TRUE, only the last path
component of $suggested is used.
protect_characters($f, $query, $url, $suggested, $type, $enc)
Returns the filename $f with necessary character-by-character
translations performed. Unless overriden, it translates backslashes
to slashes if the option "fix_url_backslashes" is TRUE, replaces
characters matched by regular expression in the option "protect" by
their hexadecimal representation (with the leader being the value of
the option "protect_pref"), and replaces percent signs by the value
of the option "protect_pref".
protect_query($f, $query, $url, $suggested, $type, $enc)
Returns $query with necessary character-by-character translations
performed. Unless overriden, it translates slashes, backslashes, and
characters matched byregular expression in the option "protect" by
their hexadecimal representation (with the leader being the value of
the option "protect_pref"), and replaces percent signs by the value
of the option "protect_pref".
find_directory($f, $query, $url, $suggested, $type, $enc)
Returns a triple of the appropriate directory name, the relative
filename, and a string to append to the filename, based on
processed-so-far filename $f and the $query string.
Unless overriden, does the following: unless the option
"hierarchical" is TRUE, all but the last path components of $f are
ignored. If the option "site_dir" is TRUE, the host part of the URL
(as well as the port part - if non-standard) are prepended to the
filename. The leading backslash is always stripped, and the option
"root" is used as the lead components of the directory name. If
$query is defined, and the option "dir_query" is true, $f is used as
the last component of the directory, and $query as file name (with
option "use_query" prepended).
(Dirname is assumed to be "/"-terminated.)
protect_directory($dirname, $f, $append, $url, $suggested, $type, $enc)
Returns the provisional directory part of the filename. Unless
overriden, replaces empty components by the string "empty" preceeded
by the value of "protect_pref" option; then applies the method
fix_component() to each component of the directory.
directory_found($dirname, $f, $append, $url, $suggested, $type, $enc)
A callback to process the calculated directory name. Unless
overriden, it creates the directory (with permissions per option
"dir_mode") if the option "mkpath" is TRUE.
Actually, the directory name is the return value, so this is the
last chance to change the directory name...
split_suffix($f, $dirname, $append, $url, $suggested, $type, $enc)
Breaks the last component $f of the filename into a pair of basename
and suffix, which are returned. $dirname consists of other
components of the filename, $append is the string to append to the
basename in the future.
Suffix may be empty, and is supposed to contain the leading dot (if
applicable); it may contain more than one dot. Unless overriden, the
suffix consists of all trailing non-empty started-by-dot groups with
length no more than given by the option "max_suff_len" (not
including the leading dot).
choose_suffix($f, $suff, $dirname, $append, $url, $suggested, $type,
$enc)
Returns a pair of basename and appropriate suffix for a file. $f is
the basename of the file, $suff is its suffix, $dirname consists of
other components of file names, $append is the string to append to
the basename.
Different strategies applicable to this problem are:
* keep the file extension;
* replace by the "best" extension for this $type (and $enc);
* replace by the user-specified type-specific extension.
Any of these has two variants: whether we want the encodings
reflected in the suffix, or not. Unless overriden, chosing
strategy/variant consists of several rounds.
In the first round, choose user-specified suffix if $type is
defined, and is (lowercased) in the option-hashes "type_suff" and
"type_suff_no_enc" (choosing the variant based on which hash
matched). Keep the current suffix if $type is not defined, or option
"keepsuff_same_mediatype" is TRUE and the current suffix of the file
matches $type and $enc (per database of known types and encodings).
The second round runs if none of these was applicable. Choose
user-specified suffix if $type is (lowercased) in the hashes
"type_suff_fallback" or "type_suff_fallback_no_enc" (choosing
variant as above); keep the current suffix if the type (lowercased)
is in the hashes "keep_nosuff" or "keep_suff" (depending on whether
$suff is empty or not).
If none of these was applicable, the last round chooses the
appropriate suffix by the database of known types and encodings; if
not found, the existing suffix is preserved.
fix_basename($f, $dirname, $suff, $url, $suggested, $type, $enc)
Returns a pair of basename and suffix for a file. $f is the last
component of the name of the file, $dirname consists of other
components. Unless overriden, this method replaces an empty basename
by "index" and applies fix_component() method to the basename;
finally, if '8+3' otion is set, it converts the filename and suffix
to a name suitable 8+3 filesystems.
fix_dups($f, $dirname, $suff, $url, $suggested, $type, $enc)
Given a basename, extension, and the directory part of the filename,
modifies the basename (if needed) to avoid duplicates; should return
the complete file name (combining the dirname, basename, and
suffix). Unless overriden, appends a number to the basename
(shortening basename if needed) so that the result is unique.
This is a prime candidate for overriding (e.g., to ask user for
confirmation of overwrite).
name_found($url, $f, $dirname, $suff, $suggested, $type, $enc)
The callback method to register the found name. Unless overridden,
behaves like following: if option "cache_name" is TRUE, stores the
found name in the "known_names" hash. Otherwise just returns the
found name.
Helper methods
fix_component($component, $isdir)
Returns a suitably modified value of a path component of a filename.
The non-overriden method massages unescapes embedded SPACE
characters; it removes starting/trailing, and converts the rest to
"_" unless the option "keep_space" is TRUE; removes trailing dots
unless the option "keep_dots" is TRUE; translates to lowercase if
the option "tolower" is TRUE, truncates to "max_length" if this
option is set, and applies the eight_plus_three() method if the
option '8+3' is set.
eight_plus_three($fname, $suffix)
Returns the value of filename modified for filesystems with 8+3
restriction on the filename (such as DOS). If $suffix is not given,
calculates it from $fname; otherwise $suffix should include the
leading dot, and $fname should have $suffix already removed. (Some
parts of info may be moved between suffix and filename if judged
appropriate.)
url_takes_query($url [, $type, $encoding])
This method returns TRUE if the *query* part of the URL is selecting
a part of the resource (i.e., if it is behaves as a *fragment* part,
and it is the client which should process this part). Such URLs are
detected by $type (should be in hash option "queryless_types"), or
by extension of the last path component (should be in hash option
"queryless_ext").
Net::ChooseFName::Failer class
A class which behaves as Net::ChooseFName, but always returns "undef".
For convenience, the constructor is duplicated as a class method
failer() in the class Net::ChooseFName.
EXPORT
None by default.
BUGS
Documentation keeps mentioning *"unless overriden"*... Of course it is a
generic remark applicable to any method of any class; however, please
remember that methods of this class are designed to be overriden.
There is no protection against a wanted directory name being already
taken by a file.
There is no restriction on length of overall file name, only on length
of a component name.
SEE ALSO
LWP=libwww-perl
AUTHOR
Ilya Zakharevich <ilyaz@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2005 by Ilya Zakharevich <ilyaz@cpan.org>
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.8.2 or, at
your option, any later version of Perl 5 you may have available.
------------------------------
Date: 6 Feb 2005 11:47:19 -0800
From: "DMB" <dummymb@hotmail.com>
Subject: Connecting to a Domino Db
Message-Id: <1107719238.967863.147040@l41g2000cwc.googlegroups.com>
Ok,
I'll try harder this time. Perhaps it is my impatient nature, but I
tend to have difficulty posting questions that don't draw fire (not
enough info, vague errors, etc.).
I've been programming in Perl long enough (for about 5 years on and
off) to know that I suck at it. I don't find it very intuitive to me
and no matter how long I use it, I still feel like I have to look up
darn near everything. I'm sure it's a flaw with how my brain works,
but I don't have this problem with C, Java, Pascal, BASIC, or
JavaScript, so it can't ALL be me.
Any way, I've never connected a Perl script to ANY database, let alone
a Domino one, so perhaps the syntax is similar. Has anyone here ever
connected to a Lotus Domino database? If so, could you post a code
snippet?
My goal is to run a Perl script which then looks up some information in
a Lotus Domino database and returns the findings to the web browser.
Hopefully I laid this question out well enough to avoid too many flames.
------------------------------
Date: Sun, 06 Feb 2005 17:53:41 -0500
From: Wes Groleau <groleau+news@freeshell.org>
Subject: Custom sort empties instead of sorting
Message-Id: <36nlf9F53h7poU1@individual.net>
I put a bunch of records in a hash. I need to output a subset
of the records, so I make a list of the keys needed. Output order
is not important EXCEPT that a certain key must always be first,
and a certain key last.
# here $Keys[0], $Keys[1], $Keys[5] all contain text
@Keys = sort
{
if ($a eq "HEAD") {return -1};
if ($b eq "HEAD") {return 1};
if ($a eq "TRLR") {return 1};
if ($b eq "TRLR") {return -1};
return 0;
} @Keys;
# here $Keys[0], $Keys[1], $Keys[5] are all undefined
Several variations on the style of the comparison black
all gave the same result. Assigning the sort to a different
array left the result array empty also.
What am I missing?
RTFM references OK,
as long as they're not 'perlfunc' or "Perl Cookbook" :-)
--
Wes Groleau
Is it an on-line compliment to call someone a Net Wit ?
------------------------------
Date: 6 Feb 2005 19:05:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Exception handling in class: question
Message-Id: <cu5pot$rpp$1@mamenchi.zrz.TU-Berlin.DE>
nobull@mail.com <nobull@mail.com> wrote in comp.lang.perl.misc:
>
> Anno Siegel wrote:
>
> > As for your question, it is unclear why you use "eval" at all. It is
> not
> > the standard error handling mechanism in Perl.
>
> Er, it's one of them.
>
> > If you must use it, make
> > its scope as small as possible, that is, treat every case
> individually.
>
> I would agree with that.
>
> > Only use it if the exception can't be otherwise anticipated. Don't
> catch
> > division by zero that way, for instance.
>
> I completely disagree with Anno on that.
That seems to happen quite a bit, both ways. When it comes to pushing
the envelope, we seem to be pushing into opposite directions. There's
nothing wrong with that. We do seem to agree on most elementary matters.
> If you want to cope with the
> possibility of numeric overflow you should figure out where it can
> happen and wrap that code in eval{}. Trying to anticipate numeric
> overflow is inefficient and error promne
...especially with portability in view.
However, division by zero is the one case where numeric overflow *can*
be reliably predicted. If it's the only thing to worry about (as with
an integer denominator), I wouldn't recommend eval-catching the error.
Division of floats is another matter.
> > Standard error handling is through the standard module Carp.
>
> The use of Carp is orthogonal to the decision to use an a throw-catch
> approach.
Carp does error attribution as its main feature, that is, it guesses an
entry on the call stack that is likely to be the place where the using
module introduced the error. With a throw-catch pair, that place is fully
under programmer control -- it is the location of the catcher. Using Carp
in addition could only mess things up. I don't see that as orthogonal.
> > OTOH, if you deliberately want to use "eval" for exception handling,
> > take a look at some of the "Exception" modules on CPAN, or write your
> > own. Don't use "eval" directly for that.
>
> Out of interest, why?
Well, that may have come out more dogmatic than it should have. If
exceptions are just that, i.e. rare, two or three cases may well be
handled with eval directly.
Before I'd sprinkle my code with lots of eval's (and associated "if
$@ ..."), I'd look for a smoother interface.
Anno
------------------------------
Date: 6 Feb 2005 21:18:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie asking, interesting question
Message-Id: <cu61k1$2ni$1@mamenchi.zrz.TU-Berlin.DE>
Wondering <dbent@comcast.net> wrote in comp.lang.perl.misc:
> I'm struggling to learn Perl, with some degree of success. I have a
> question that's a bit more advanced than I am, but I hope someone can
> help (thanks in advance to all who read this and biger thanks to
> responders).
>
> I'm trying to match name and address records in a large (~300,000
> record) database with potential new records to avoid duplicates. Anyone
> who has tried this knows that there are problems with exact matching,
> especially if no convention has been followed for entering data.
> (Consider all the possible variations of "avenue" - "avenue", "av",
> "ave", etc., and when you consider drive, boulevard, etc. and all their
> possible abbreviations, you begin to get the picture). So, I want to be
> able to extract just the numeric characters in a strings so I can do
> the matching on those (it's fuzzy, but with other feilds being
> considered, too, we can get a fairly high matching rate). Anyone know
> how to extract just the numeric charaters?
tr/0..9//cd;
That will delete everything except digits.
> I'll also accept any other ideas for doing the match.
There's the Soundex method with a corresponding standard module
Text::Soundex. It tries to map words so that similar-sounding ones
map to the same thing. It may also map different-sounding words to
the same thing, but you're not overly concerned about false positives.
Your fields may need some pre-processing (as breaking into words in
a useful way).
Anno
------------------------------
Date: Sun, 6 Feb 2005 16:43:30 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Newbie asking, interesting question
Message-Id: <slrnd0d7ci.p4s.tadmc@magna.augustmail.com>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> tr/0..9//cd;
>
> That will delete everything except digits.
Make that
tr/0-9//cd;
please.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 06 Feb 2005 12:41:59 -0700
From: YYusenet <yyusenet@yahoo.com>
Subject: Re: Perl - permute?
Message-Id: <cu5ru9$esj$1@news.xmission.com>
Ej wrote:
> Hi,
> How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER] combos
> of these letters, I want the output to look like
>
> abc
> acb
> aab
> aaa
>
> how can I Using perl
> Thanks Ej
This may be what you would want instead:
---------------------------------
#!/usr/bin/perl
use warnings;
use strict;
my $items = "a,b,c,d,e";
print join "\n", glob "{$items}" x (length($items)/2);
__END__
---------------------------------
--
k g a b e r t (@at@) x m i s s i o n (.dot.) c o m
* After "extensive" research, I noticed
* that yyusenet@yahoo.com received 12
* spam e-mail messages after just two
* posts on usenet groups. If you want
* to email me, use the "encrypted"
* email address at the beginning of my
* signature.
------------------------------
Date: Sun, 06 Feb 2005 12:47:15 -0700
From: YYusenet <yyusenet@yahoo.com>
Subject: Re: Perl - permute?
Message-Id: <cu5s85$fkr$1@news.xmission.com>
YYusenet wrote:
> This may be what you would want instead:
> ---------------------------------
> #!/usr/bin/perl
>
> use warnings;
> use strict;
>
> my $items = "a,b,c,d,e";
> print join "\n", glob "{$items}" x (length($items)/2);
>
> __END__
> ---------------------------------
Sorry about that: The correction would be:
#!/usr/bin/perl
use warnings;
use strict;
my $items = "a,b,c,d";
print join "\n", glob "{$items}" x ((length($items)/2)+1);
__END__
--
k g a b e r t (@at@) x m i s s i o n (.dot.) c o m
* After "extensive" research, I noticed
* that yyusenet@yahoo.com received 12
* spam e-mail messages after just two
* posts on usenet groups. If you want
* to email me, use the "encrypted"
* email address at the beginning of my
* signature.
------------------------------
Date: 06 Feb 2005 21:24:24 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl - permute?
Message-Id: <slrnd0d2o8.g2.abigail@alexandra.abigail.nl>
Bob Walton (see_sig@invalid) wrote on MMMMCLXXVII September MCMXCIII in
<URL:news:42065a4b$2_2@127.0.0.1>:
$$ Ej wrote:
$$ > Hi,
$$ > How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER] combos
$$ > of these letters, I want the output to look like
$$ >
$$ > abc
$$ > acb
$$ > aab
$$ > aaa
$$ >
$$ > how can I Using perl
$$ > Thanks Ej
$$
$$ That's a FAQ:
$$
$$ perldoc -q permute
It may be a FAQ, but 'perldoc -q permute' sure isn't the answer to
the question.
The algorithms displayed in 'perldoc -q permute' will generate 120
five-letter strings. Which isn't the 125 three letter strings the
OP is looking for.
Please read the question and read the answer in the FAQ, before
giving an answer.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: 6 Feb 2005 22:09:31 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Perl - permute?
Message-Id: <Xns95F5A45FED6BFcastleamber@130.133.1.4>
A. Sinan Unur wrote:
> Ej <justsurge@mailcan.com> wrote in
> news:1107709033.0d15271ffc45f8463e1fcde7dddd2c79@bubbanews:
>
>> Hi,
>> How can I take an array (a,b,c,d,e) and list ALL possible [3 LETTER]
>> combos of these letters, I want the output to look like
>>
>> abc
>> acb
>> aab
>> aaa
>>
>> how can I Using perl
>
> It all begins with using all the goodies available to you.
>
> For the following, I just used the first module CPAN gave me when I
> searched for the word 'permute'.
So you select CPAN modules based on "I feel lucky?"
> I have no idea if it is the best, for
> that you will have to do some work yourself.
So you pick the first module and ...
> You will note that Algorithm::Permute won't do all 3-letter
> permutations out of 5 letters.
Aargh!
So you could have also recommended the Acme module, since it's the base
of perfection.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Mon, 07 Feb 2005 09:34:06 +1100
From: David Trudgett <dtrudgett@holdthespam_yahoo.com>
Subject: Re: Perl - permute?
Message-Id: <z_wNd.7139$i6.66402@nasal.pacific.net.au>
Bill Smith wrote:
>
> The required function should not
> be called 'permute'. A quick
Goodness me! Doesn't anyone know a combination when they see one? This
is high school maths. How about the Math:Combinatorics module?
my @n = qw(a b c);
my @c = combine(2,@n);
print join "\n", map { join " ", @$_ } @c;
# prints:
# b c
# a c
# a b
David
------------------------------
Date: 6 Feb 2005 14:35:49 -0800
From: cmw@tulpje.co.uk
Subject: Perl Regex to search for ed2k links
Message-Id: <1107729349.121056.99380@l41g2000cwc.googlegroups.com>
Can anybody help me? I need a regex that extracts the ed2k:// links
from the below text. I am new to regex so i don't really know what i am
doing. Can anybody help.
I only want it to detect links that have eZebra\t before them. Can
anybody help?
Thanks
Example Text
------------
eZebra ------
troll
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x19.-.The.Damage.Done.(RTFM).AC3.2.0.avi|364597248|3CFACD8D441AA9EB03BF63958C674D16|/
wan !yesterday
eZebra [yesterday] (2005-02-05 +/- 4h, CST/GMT-6) new links
added: 36
(results in private msg window).
|<-- predx has left irc (Ping timeout)
eZebra --- Latest links: ---
eZebra
ed2k://|file|The.L.Word.-.1x03.-.Let's.Do.It.DVDrip.XviD-SAVANNAH.avi|367785984|55B0F21E816C22D4B68674DCD96E583D|/
eZebra
ed2k://|file|jonny.zero.104.whos.your.daddy.hdtv-lol.avi|358369280|01F96A3E710F645443A6A3133830D81F|/
eZebra
ed2k://|file|jonny.zero.s01e04.hdtv.xvid.proper-fqm.avi|366120960|7A94985989338D435998E453E84D6102|/
eZebra
ed2k://|file|MacGyver.s01e05.The.Heist.REPACK.DVDRip.XviD-MEDiEVAL.avi|366958592|5C3EC856C57389DDB294B32B9A36E0E6|/
eZebra
ed2k://|file|MacGyver.s01e04.The.Gauntlet.DVDRip.XviD-MEDiEVAL.avi|366446592|A08A1B9CCC74FC6F0A1E82CD1E4E35D8|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x22.-.Work.Related.(RTFM).AC3.2.0.avi|364687360|D36268345768CA9FD8C1ECA2F8F0D285|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x21.-.Scene.of.the.Crime.(RTFM).AC3.2.0.avi|364775424|339B35DE28552E0A416663A4540EB76C|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x20.-.The.Wedding.(RTFM).AC3.2.0.avi|364388352|9CBC843587017E08D4E7F207C1B48DD9|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x19.-.The.Damage.Done.(RTFM).AC3.2.0.avi|364597248|3CFACD8D441AA9EB03BF63958C674D16|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x18.-.Requiem.for.Adena.(RTFM).AC3.2.0.avi|364414976|391940769E2C7C133AD4C3F5BB1E4D4C|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x17.-.Map.of.the.Heart.(RTFM).AC3.2.0.avi|364865536|14C8C15189D8141F7EAD34A057947EBA|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x16.-.Stakeout.(RTFM).AC3.2.0.avi|364455936|321C7061687E6518332DD2295EE3616F|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x15.-.Justice.(II).(RTFM).AC3.2.0.avi|364781568|463FD7507112ECB5E5F3F5DFAD5780C0|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x14.-.Justice.(I).(RTFM).AC3.2.0.avi|364742656|D45F4C91D3ABDBFF735CBA11C6CDA048|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x13.-.I've.Got.a.Secret.(RTFM).AC3.2.0.avi|364410880|93D3FB12756C8831752B6A6FB770034F|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x12.-.The.Hat.(RTFM).AC3.2.0.avi|357390336|1552CE8BEB318DAFB896B2D7C4CADF7B|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x11b.-.For.God.and.Country.(2).(RTFM).AC3.2.0.avi|364519424|73B2B25D825CC154AB825629C0382340|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x11a.-.Charm.City.(1).(RTFM).AC3.2.0.(Previously.on.Law.&.Order.-.6x13).avi|7309312|C934EA6A5EABE39FCBAF
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x10.-.Full.Moon.(RTFM).AC3.2.0.avi|364388352|310BE9BCC64ECF022DE30B0D5534AA5B|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x09.-.Sniper.(II).(RTFM).AC3.2.0.avi|363542528|8851118EF7EBDD08423D5C1061441066|/
eZebra
ed2k://|file|Homicide.-.Life.on.the.Street.-.4x08.-.Sniper.(I).(RTFM).AC3.2.0.avi|364095488|5002EBAB39FCBBE1695CCBB16DC7693A|/
eZebra ------
Shanshu !list lost
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7745
***************************************