[30874] in Perl-Users-Digest
Perl-Users Digest, Issue: 2119 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 13 00:09:43 2009
Date: Mon, 12 Jan 2009 21:09:07 -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 Mon, 12 Jan 2009 Volume: 11 Number: 2119
Today's topics:
Re: Arrays instead of files into hashes <tadmc@seesig.invalid>
Re: Arrays instead of files into hashes sln@netherlands.com
Re: Arrays instead of files into hashes <tim@burlyhost.com>
Re: Arrays instead of files into hashes sln@netherlands.com
Re: Arrays instead of files into hashes <tim@burlyhost.com>
Re: Arrays instead of files into hashes sln@netherlands.com
Re: Circular lists - 26 letters sln@netherlands.com
Re: Circular lists <gamo@telecable.es>
Re: Circular lists sln@netherlands.com
Re: Help: Cannot acquire data by split sln@netherlands.com
Re: How can I access file on machine by address like \ <jurgenex@hotmail.com>
Re: How can I access file on machine by address like \ <WaterLin1999@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Jan 2009 17:55:36 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Arrays instead of files into hashes
Message-Id: <slrngmnm3o.5oh.tadmc@tadmc30.sbcglobal.net>
Francois Massion <massion@gmx.de> wrote:
> I would like to use 2 arrays, says @array1 and
> @array2 instead of files a.txt and b.txt.
> while (<WORDLIST2>) {
> $list2{$_}=1; #or any other value
> }
my @b_txt = <WORDLIST2>;
close WORDLIST2;
foreach ( @b_txt ) {
$list2{$_} = 1;
}
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Tue, 13 Jan 2009 00:28:46 GMT
From: sln@netherlands.com
Subject: Re: Arrays instead of files into hashes
Message-Id: <e0onm4hmafllmjb6fs4jhn0m09onifh0dn@4ax.com>
On Mon, 12 Jan 2009 17:55:36 -0600, Tad J McClellan <tadmc@seesig.invalid> wrote:
>Francois Massion <massion@gmx.de> wrote:
>
>> I would like to use 2 arrays, says @array1 and
>> @array2 instead of files a.txt and b.txt.
>
>
>> while (<WORDLIST2>) {
>> $list2{$_}=1; #or any other value
>> }
>
>
> my @b_txt = <WORDLIST2>;
Isin't slurp a bit rich?
[snip]
sln
------------------------------
Date: Mon, 12 Jan 2009 16:41:12 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Arrays instead of files into hashes
Message-Id: <IqRal.6113$u14.131@newsfe21.iad>
sln@netherlands.com wrote:
> On Mon, 12 Jan 2009 17:55:36 -0600, Tad J McClellan
> <tadmc@seesig.invalid> wrote:
>
>>Francois Massion <massion@gmx.de> wrote:
>>
>>> I would like to use 2 arrays, says @array1 and
>>> @array2 instead of files a.txt and b.txt.
>>
>>
>>> while (<WORDLIST2>) {
>>> $list2{$_}=1; #or any other value
>>> }
>>
>>
>> my @b_txt = <WORDLIST2>;
> Isin't slurp a bit rich?
> [snip]
>
> sln
Probably, but that's what the OP asked for. I can't imagine why, but
perhaps they just need to elaborate on their reasons to get a good
answer. Personally, I didn't answer them, because I had to ask what
they were wanting to do, since it didn't seem clear to me (or didn't
seem to have a purpose and would just waste good processing).
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Tue, 13 Jan 2009 02:38:42 GMT
From: sln@netherlands.com
Subject: Re: Arrays instead of files into hashes
Message-Id: <pjvnm45g7j74l4ffrga9b6c13mrshqet4p@4ax.com>
On Mon, 12 Jan 2009 16:41:12 -0800, Tim Greer <tim@burlyhost.com> wrote:
>sln@netherlands.com wrote:
>
>> On Mon, 12 Jan 2009 17:55:36 -0600, Tad J McClellan
>> <tadmc@seesig.invalid> wrote:
>>
>>>Francois Massion <massion@gmx.de> wrote:
>>>
>>>> I would like to use 2 arrays, says @array1 and
>>>> @array2 instead of files a.txt and b.txt.
>>>
>>>
>>>> while (<WORDLIST2>) {
>>>> $list2{$_}=1; #or any other value
>>>> }
>>>
>>>
>>> my @b_txt = <WORDLIST2>;
>> Isin't slurp a bit rich?
>> [snip]
>>
>> sln
>
>Probably, but that's what the OP asked for. I can't imagine why, but
>perhaps they just need to elaborate on their reasons to get a good
>answer. Personally, I didn't answer them, because I had to ask what
>they were wanting to do, since it didn't seem clear to me (or didn't
>seem to have a purpose and would just waste good processing).
There's a thin line between yes and no, but if its not yes....
sln
------------------------------
Date: Mon, 12 Jan 2009 19:15:37 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Arrays instead of files into hashes
Message-Id: <tHTal.41367$pe.27608@newsfe13.iad>
sln@netherlands.com wrote:
> On Mon, 12 Jan 2009 16:41:12 -0800, Tim Greer <tim@burlyhost.com>
> wrote:
>
>>sln@netherlands.com wrote:
>>
>>> On Mon, 12 Jan 2009 17:55:36 -0600, Tad J McClellan
>>> <tadmc@seesig.invalid> wrote:
>>>
>>>>Francois Massion <massion@gmx.de> wrote:
>>>>
>>>>> I would like to use 2 arrays, says @array1 and
>>>>> @array2 instead of files a.txt and b.txt.
>>>>
>>>>
>>>>> while (<WORDLIST2>) {
>>>>> $list2{$_}=1; #or any other value
>>>>> }
>>>>
>>>>
>>>> my @b_txt = <WORDLIST2>;
>>> Isin't slurp a bit rich?
>>> [snip]
>>>
>>> sln
>>
>>Probably, but that's what the OP asked for. I can't imagine why, but
>>perhaps they just need to elaborate on their reasons to get a good
>>answer. Personally, I didn't answer them, because I had to ask what
>>they were wanting to do, since it didn't seem clear to me (or didn't
>>seem to have a purpose and would just waste good processing).
>
> There's a thin line between yes and no, but if its not yes....
>
> sln
Its (its) or it's (it is) not yes, and what isn't? I'd say it is yes
(being it's "probably" going to be more resource intensive to grab all
of the contents of WORLDLIST2 into an array), only to compare then,
comparing it to a while loop to see if a hash value exists before
adding it (if the OP wants to add it). I absolutely don't understand
your cryptic response. I'm certain you were being sarcastic, but I
don't know if you mean to have a question in there.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Tue, 13 Jan 2009 03:50:35 GMT
From: sln@netherlands.com
Subject: Re: Arrays instead of files into hashes
Message-Id: <jd3om4t392kffb7hr8aok8c2n1fa66c20e@4ax.com>
On Mon, 12 Jan 2009 19:15:37 -0800, Tim Greer <tim@burlyhost.com> wrote:
>sln@netherlands.com wrote:
>
>> On Mon, 12 Jan 2009 16:41:12 -0800, Tim Greer <tim@burlyhost.com>
>> wrote:
>>
>>>sln@netherlands.com wrote:
>>>
>>>> On Mon, 12 Jan 2009 17:55:36 -0600, Tad J McClellan
>>>> <tadmc@seesig.invalid> wrote:
>>>>
>>>>>Francois Massion <massion@gmx.de> wrote:
>>>>>
>>>>>> I would like to use 2 arrays, says @array1 and
>>>>>> @array2 instead of files a.txt and b.txt.
>>>>>
>>>>>
>>>>>> while (<WORDLIST2>) {
>>>>>> $list2{$_}=1; #or any other value
>>>>>> }
>>>>>
>>>>>
>>>>> my @b_txt = <WORDLIST2>;
>>>> Isin't slurp a bit rich?
>>>> [snip]
>>>>
>>>> sln
>>>
>>>Probably, but that's what the OP asked for. I can't imagine why, but
>>>perhaps they just need to elaborate on their reasons to get a good
>>>answer. Personally, I didn't answer them, because I had to ask what
>>>they were wanting to do, since it didn't seem clear to me (or didn't
>>>seem to have a purpose and would just waste good processing).
>>
>> There's a thin line between yes and no, but if its not yes....
>>
>> sln
>
>Its (its) or it's (it is) not yes, and what isn't? I'd say it is yes
>(being it's "probably" going to be more resource intensive to grab all
>of the contents of WORLDLIST2 into an array), only to compare then,
>comparing it to a while loop to see if a hash value exists before
>adding it (if the OP wants to add it). I absolutely don't understand
>your cryptic response. I'm certain you were being sarcastic, but I
>don't know if you mean to have a question in there.
This no joke! I don't write anything unles I need to!
I said before this is beginner code. No sarcasm inteneded.
I do not want to go through this. The prototypes are wrong along
with alot of other stuff. Amazingly, this heards all the dup porn out
there into safely stored data. Go figure... it works like a champ!!
sln
mrg_test1.pl
----------
use strict;
use warnings;
require SMG;
use File::stat;
use File::Spec;
use File::Path;
use File::Copy;
use File::Find;
use sort 'stable';
my $VERSION = 1.00;
my $current = sort::current();
#print "\n==> sort : $current\n\n";
# Test smerge alone
#-----------------------
if (1)
{
#
my $ToDir = 'D:\agent\t1';
my $FromDir = 'D:\agent\t2';
my $PrefixName = time()."_";
my $PrefixLevel = 5;
my @Exclude = ('\.jbf$', '\.alb$'); # if all goes ok, these will be rmdir'd with the from, but not moved
my $Duponly = 0;
my $RmvFrom = 0;
if (SMG::SafeMerge ($ToDir,$FromDir,$PrefixName,$PrefixLevel,\@Exclude,$Duponly,$RmvFrom)) {
print "\nSafe Merge exited ok.\n";
} else { print "\nSafe Merge had a headache.\n"; }
}
---------------------
smg.pm
----------
package SMG;
use strict;
use warnings;
use File::stat;
use File::Path;
use File::Copy;
use File::Find;
use File::Spec;
use sort 'stable';
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(SafeMerge GetCommonElementsNxM GetCommonElements);
my $VERSION = 1.00;
#my $current = sort::current();
####################################################################################
# SAFE MERGE
# The two major options -
# 1. Merge 2 directories into 1, preserving/renaming duplicate named files.
# 2. Compare 2 directories and just rename the duplicates of 1 directory.
# Also -
# - The prefix level will be on a per-file monitored basis.
# - File/Dir names are cached and renamed in the "From" array,
# - Move is done via os-rename function into the "ToDir".
# - Remove "From" directory option (after rename).
# - Duplicate's-renaming-only is done in-place in the "FromDir".
# - Report output is created in the current directory (for now).
# - Itteration scheme are within-directory, then cross-directory until no more dups.
#-----------------------------------------------------------------------------------
sub SafeMerge ($$$$$$$)
{
return 0 if (@_ < 2 || @_ > 7);
my ($ToDir,$FromDir,$PrefixName,$PrefixLevel,$Exclude,$Duponly,$RmvFrom) = @_;
$PrefixName = '' unless defined $PrefixName; # Renaming Prefix
$PrefixLevel = 0 unless defined $PrefixLevel; # Number of times to += prefix
$Exclude = [] unless defined $Exclude; # Exclude list (must be re)
$Duponly = 0 unless defined $Duponly; # Flag to just rename dups in "from"
$RmvFrom = 0 unless defined $RmvFrom; # Flag to remove "from" after operation
my @To = ();
my @From = ();
my @ndx = ();
my @Xfound = ();
my $dupsize = @ndx;
my $passes = 0;
print "\n\n *******************************\n";
print "********[ Safe Merge ]*********\n";
print " *******************************\n";
print "\nPrefix\t$PrefixName\nLevel\t$PrefixLevel\nChecks ... ";
$ToDir = File::Spec->canonpath( "$ToDir" );
$FromDir = File::Spec->canonpath( "$FromDir" );
#print "$ToDir\n$FromDir";
if ($ToDir eq $FromDir) { print "\rFrom/To are identical: $ToDir\n"; return 0; }
if (!-e $ToDir) { print "\rTo directory does not exist: $ToDir\n"; return 0; }
if (!-e $FromDir) { print "\rFrom directory does not exist: $FromDir\n"; return 0;}
# Glob seems to be bothered by spaces in dir path names
my $Sep = "\\".File::Spec->canonpath( "/" );
{
my $td = File::Spec->canonpath( "$ToDir/*" );
my $fd = File::Spec->canonpath( "$FromDir/*" );
if ($td =~ / /) {
$td = "'$td'";
}
if ($fd =~ / /) {
$fd = "'$fd'";
}
foreach (glob ("$td")) {
/.+$Sep(.+)$/;
# /.+\/(.+)$/;
push (@To, [$1, 0]);
}
foreach (glob ("$fd")) {
/.+$Sep(.+)$/;
# /.+\/(.+)$/;
my $ftmp = $1;
for (@{$Exclude}) {
if ($ftmp =~ /$_/) {
# save in @Xfound if $RmvFrom is set (see below)
print "\rExclude - $ftmp\n";
push (@Xfound, $ftmp) if ($RmvFrom);
$ftmp = undef;
last;
}
}
push (@From, [$ftmp, 0, '']) if defined ($ftmp);
}
}
# Will return if "From" empty. Technically not an error.
# If it is empty through exclusions (regexp filter), "From" could be rmdir'd below.
if (@From == 0) { print "\rEmpty dir: $FromDir\n"; return 0; }
print "OK\n";
###**************************************************************************
## Iterate until there are no more dups across directories after (D2) rename
#
do {
@ndx = GetCommonElementsNxM(\@To,\@From, 1, 0);
$dupsize = @ndx;
$passes++;
print "\nP A S S \# $passes\n---------------------\n";
print "Found $dupsize dups:\n";
#**********************************
# Check for cross-directory dups
# -------------
if ($dupsize)
{
my $errflg = 0;
print "\n<DIR> $FromDir\n\n";
for (my $i = 0; $i < $dupsize; $i++)
{
my $Fromref = $From[$ndx[$i]];
my $pname = $PrefixName;
print "\t$Fromref->[0] ... $PrefixName";
#*****************************************
# Rename and check for in-directory dups
# ----------
while (1)
{
# Level check
if ($Fromref->[1] >= $PrefixLevel)
{
print "$Fromref->[0] <<level $Fromref->[1] exceeded>>\n";
# Clear the name in From so this file doesn't get moved
$Fromref->[0] = "";
$errflg = 1;
last;
}
my $stmp = uc($pname.$Fromref->[0]);
my $found = 0;
for (@From) { if (uc($_->[0]) eq $stmp) { $found = 1; last; } }
if (!$found) {
# OK to rename! Dup not found in "From"
# Change the name in "From" to this new one
# so it gets moved later. Increment its level of prefix
# ---------------------
print "$Fromref->[0]";
print "\n";
if ($Fromref->[1] == 0) { $Fromref->[2] = $Fromref->[0]; }
$Fromref->[0] = $pname.$Fromref->[0];
$Fromref->[1] += 1;
last;
}
else {
# File exist with that name, add another level of prefix.
# ---------------------
print "$PrefixName";
$pname = $pname.$PrefixName;
if ($Fromref->[1] == 0) { $Fromref->[2] = $Fromref->[0]; }
$Fromref->[1] += 1;
}
}
}
if ($errflg) {
print "!!! Can't rename some files, raise the level or change the prefix.\n";
#return 0;
}
}
} while ($dupsize > 0);
#
## End cross-dir iteration
###
#*************************************************************
# Check for rename of duplicates in D2 (only) without moving
# ------------
if ($Duponly)
{
my $rentried = 0;
my $renok = 0;
print "\nRename only ... ";
for (@From) {
my $res = 0;
if ($_->[1] > 0 && $_->[1] < $PrefixLevel) {
$rentried++;
my $fr = File::Spec->canonpath( "$FromDir/$_->[2]" );
my $fr2 = File::Spec->canonpath( "$FromDir/$_->[0]" );
if (!($res = rename ("$fr", "$fr2"))) {
print "Rename error:\t$_->[2] ... $_->[0]\n";
} else {
$renok++; }
}
}
if ($rentried) { print "$renok out of $rentried files OK\n"; }
else { print "No duplicates found\n"; }
return 1;
}
#**********************
# Move "From" into "To"
# -------------------
#print @From."@From\n";
my $sep = File::Spec->canonpath( "/" );
print "\nMoving:\t$FromDir$sep* to $ToDir$sep\n";
my $movcnt = 0;
for (@From) {
my $res = 0;
if ($_->[1] > 0 && $_->[1] < $PrefixLevel) {
my $fr = File::Spec->canonpath( "$FromDir/$_->[2]" );
my $to = File::Spec->canonpath( "$ToDir/$_->[0]" );
$res = File::Copy::move ("$fr", "$to");
if ($res == 0) { print "Move error:\t$_->[2] ... $to\n"; }
}
if ($_->[1] == 0 && $_->[0] gt '') {
my $fr = File::Spec->canonpath( "$FromDir/$_->[0]" );
my $to = File::Spec->canonpath( "$ToDir/$_->[0]" );
$res = File::Copy::move ("$fr", "$to");
if ($res == 0) { print "Move error:\t$fr\n" }
}
$movcnt++ if ($res);
}
my $notmoved = @From - $movcnt;
print "Moved:\t$movcnt out of ".@From." files.\n";
#***************************************
# Check if "FromDir" is to be deleted
# --------------
if ($RmvFrom) {
print "Remove:\t$FromDir ... ";
if ($notmoved > 0) {
print "not deleted, contains $notmoved file(s) that couldn't be moved!\n";
}
else {
# check if @Xfound has values (and their not directories)
# if so, delete these first before trying to remove the From directory
# for now, don't want to "unlink" a directory, and we're not doing a tree here
# ----------------
for (@Xfound) {
my $fr = File::Spec->canonpath( "$FromDir/$_" );
unlink ("$fr") if (!-d $fr) ; }
my $fr = File::Spec->canonpath( "$FromDir" );
if (!rmdir "$fr") {print "$!\n" } else {print "OK\n"; }
}
}
return 1;
}
#######################################################
# Get Common Elements (from two N-dimensioned Array's)
# IN - Refs to the NxN arrays to compare,
# sort flag and the compare field.
# OUT - Ndx's into Right_Array of matching elements
# ---------------------------------------------------
# Notes -
# 1. Elements are assumed textual and case insensitive
# 2. Ignores in-array duplicates
# 3. Sort will be done if sort flag > 0
#
sub GetCommonElementsNxM($$$$)
{
my ($A_Left,$A_Right,$Srtflg,$Fld) = @_;
$Srtflg = 0 unless defined $Srtflg;
$Fld = 0 unless defined $Fld;
# my @Dup = ();
my @Ndx = ();
if ($Srtflg > 0) {
@{$A_Left} = sort {uc($a->[$Fld]) cmp uc($b->[$Fld])} @{$A_Left};
@{$A_Right} = sort {uc($a->[$Fld]) cmp uc($b->[$Fld])} @{$A_Right};
} else {print "==> Common Elements : Not sorting arrays\n";}
my $rpos = 0;
my $rend = @{$A_Right};
my $cnt = 0;
my $llast = undef;
my $rlast = undef;
foreach my $left_element (@{$A_Left})
{
next if (uc($left_element->[$Fld]) eq uc($llast->[$Fld]));
$rpos += $cnt;
$cnt = 0;
foreach my $right_element (@{$A_Right}[$rpos..($rend-1)])
{
last if (uc($left_element->[$Fld]) lt uc($right_element->[$Fld]));
$cnt++;
next if (uc($right_element->[$Fld]) eq uc($rlast->[$Fld]));
if (uc($left_element->[$Fld]) eq uc($right_element->[$Fld]))
{
# push (@Dup, $right_element->[$Fld]); # the string
push (@Ndx, $rpos+$cnt-1); # the index into R_Array
last;
}
$rlast = $right_element;
}
$llast = $left_element;
last if ($rpos >= $rend);
}
# return (@Dup);
return (@Ndx);
}
#######################################################
# Get Common Elements from single Array's
# IN - Refs to the Nx1 arrays to compare, sort flag
# OUT - Ndx's into Right_Array of matching elements
# ---------------------------------------------------
# Notes -
# 1. Elements are assumed textual and case insensitive
# 2. Ignores in-array duplicates
# 3. Sort will be done if sort flag > 0
#######################################################
sub GetCommonElements($$$)
{
my ($A_Left,$A_Right,$Srtflg) = @_;
$Srtflg = 0 unless defined $Srtflg;
# my @Dup = ();
my @Ndx = ();
if ($Srtflg > 0) {
@{$A_Left} = sort {uc($a) cmp uc($b)} @{$A_Left};
@{$A_Right} = sort {uc($a) cmp uc($b)} @{$A_Right};
} else {print "==> Common Elements : Not sorting arrays\n";}
my $rpos = 0;
my $rend = @{$A_Right};
my $cnt = 0;
my $llast = '';
my $rlast = '';
foreach my $left_element (@{$A_Left})
{
next if (uc($left_element) eq uc($llast));
$rpos += $cnt;
$cnt = 0;
foreach my $right_element (@{$A_Right}[$rpos..($rend-1)])
{
last if (uc($left_element) lt uc($right_element));
$cnt++;
next if (uc($right_element) eq uc($rlast));
if (uc($left_element) eq uc($right_element))
{
# push (@Dup, $right_element); # the string
push (@Ndx, $rpos+$cnt-1); # the index into R_Array
last;
}
$rlast = $right_element;
}
$llast = $left_element;
last if ($rpos >= $rend);
}
# return (@Dup);
return (@Ndx);
}
1;
------------------------------
Date: Tue, 13 Jan 2009 00:05:26 GMT
From: sln@netherlands.com
Subject: Re: Circular lists - 26 letters
Message-Id: <8kmnm4hmne4kaunp2ga6i0lp5fleh83uae@4ax.com>
On Mon, 12 Jan 2009 14:56:27 -0800, Jim Gibson <jimsgibson@gmail.com> wrote:
>In article <t5anm4d27tdcj3cdm438a1antuesh3pqvt@4ax.com>,
><sln@netherlands.com> wrote:
>
>> I need to permute the 26,25,24,... letters of the alphabet.
>
>Which alphabet? There are 26 letters in the English alphabet. You can
>get an alphabet consisting of 25 letters by eliminating one letter from
>the English alphabet. There are 26 ways to do that. You can eliminate 2
>letters to get a 24-letter alphabet; there are 26*25 ways to do that.
>
>Given N distinct letters, there are N! permutations formed by selecting
>N letters from the set in order. N! = N * (N-1) * (N-2) * ... * 3 * 2 *
>1 (but you knew that).
>
>Given N distinct letters, there are N!/(N-M)! different ways to select
>M letters in order from N distinct letters (M < N).
>
><http://en.wikipedia.org/wiki/Permutation>
>
>> How many words can I make with that?
>
>Every word in the English language that does not have repeated letters,
>and then some! What is your definition of a "word".
>
>> Will it take much memory?
>
>Not if you generate the permutations one-at-a-time. See, for example,
>'perldoc -q permute'
>
>> How much ram do I need,
>
>Not much (see above).
>
>> how long will it take?
>
>A very long time. Enough time to generate
>
>26! + 26! + (26!/2!) + (26!/3!) + (26!/4!) + . . . + (26*25) + 26 + 1
>
>permutations ( or thereabouts -- my math might be off a little). Since
>26! is 4.0329E26, you will need about 10**13 years assuming you can
>generate and process 1,000,000 permutations per second.
>
>> Do I need circular lists?
>
>No.
Total utteral hogwash, to even reply is ignorance personified!!
sln
------------------------------
Date: Tue, 13 Jan 2009 01:40:06 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Circular lists
Message-Id: <alpine.LNX.2.00.0901130112070.4119@jvz.es>
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
--8323328-731692497-1231807207=:4119
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
On Mon, 12 Jan 2009, J=FCrgen Exner wrote:
=2E..
> eaabbbccccdddddeeeee
>=20
> Some of these may be identical and thus reduce the number of results
> (which they are not in this example), but how did you get 5.3 million
> candidates?
>=20
> jue
>=20
@a =3D qw(a a b b b c c c c d d d d d e e e e e e);
$n =3D @a;
for (1..10_000_000){
@set =3D shuffle(@a);
$s =3D join '',@set;
$two =3D $s . $s;
$clist{$s}++;
if ($clist{$s}=3D=3D1 && !defined $hash{$s}){
=09for $i (0..$n-1){
=09 $r =3D substr $two,$i,$n;
=09 $hash{$r}++;
=09 if ($hash{$r}=3D=3D1){ $counter++; }
=09}
=09$exito++;
=09print "$0 $exito\n";
}
}
print "El n=FAmero de permutaciones circulares es $exito\n";
print "Counter of distinct permutations $counter\n";
After a while, taking keys %clist gives you lists that neither
is a rotation of another, nor there are duplicates. But the=20
experiment fails because the numbers Xho shows. It's exponential,
and intractable.=20
Best regards,
PS: Xho, I need to have the $clist and $hash in ram to make=20
comparisons with a new candidate. C is no necesary since=20
perl fill the memory in a moment. 8-)
--=20
http://www.telecable.es/personales/gamo/
"Was it a car or a cat I saw?"
perl -E 'say 111_111_111**2;'
--8323328-731692497-1231807207=:4119--
------------------------------
Date: Tue, 13 Jan 2009 00:59:57 GMT
From: sln@netherlands.com
Subject: Re: Circular lists
Message-Id: <orpnm45osd98cktp18i4h5u03dma0lla9t@4ax.com>
On Tue, 13 Jan 2009 01:40:06 +0100, gamo <gamo@telecable.es> wrote:
>On Mon, 12 Jan 2009, Jürgen Exner wrote:
>...
>> eaabbbccccdddddeeeee
>>
>> Some of these may be identical and thus reduce the number of results
>> (which they are not in this example), but how did you get 5.3 million
>> candidates?
>>
>> jue
>>
>
>@a = qw(a a b b b c c c c d d d d d e e e e e e);
>$n = @a;
>for (1..10_000_000){
> @set = shuffle(@a);
> $s = join '',@set;
> $two = $s . $s;
> $clist{$s}++;
> if ($clist{$s}==1 && !defined $hash{$s}){
> for $i (0..$n-1){
> $r = substr $two,$i,$n;
> $hash{$r}++;
> if ($hash{$r}==1){ $counter++; }
> }
> $exito++;
> print "$0 $exito\n";
> }
>}
>print "El número de permutaciones circulares es $exito\n";
>print "Counter of distinct permutations $counter\n";
>
>After a while, taking keys %clist gives you lists that neither
>is a rotation of another, nor there are duplicates. But the
>experiment fails because the numbers Xho shows. It's exponential,
>and intractable.
>
>Best regards,
>
>PS: Xho, I need to have the $clist and $hash in ram to make
>comparisons with a new candidate. C is no necesary since
>perl fill the memory in a moment. 8-)
jeez, give it a rest........
sln
------------------------------
Date: Tue, 13 Jan 2009 04:09:43 GMT
From: sln@netherlands.com
Subject: Re: Help: Cannot acquire data by split
Message-Id: <0u4om4tf7ltpkft42nv454n9g3fmcamgch@4ax.com>
On Mon, 12 Jan 2009 12:15:42 -0800, Tim Greer <tim@burlyhost.com> wrote:
>Amy Lee wrote:
>
>> Hello,
>>
>> Here's the data I use.
>>
>> ath-MIR166f Marcal1-PA 100.00 18 0 0 58 75 2226 2243 0.008 36.2
>> dme-mir-278 GABA-B-R3-PA 100.00 18 0 0 64 81 282 265 0.007 36.2
>> dme-mir-100 CG6630-PA 100.00 19 0 0 28 46 5108 5126 0.002 38.2
>> cbr-mir-268 nop5-PA 95.65 23 1 0 57 79 1428 1406 0.001 38.2
>> mmu-mir-199a-2 CG7806-PA 100.00 18 0 0 8 25 107 124 0.008 36.2
>> rno-mir-320 CG15161-PA 100.00 18 0 0 2 19 265 248 0.006 36.2
>>
>> And at every line the contents are separated by tab, and I used
>> following syntax to get the first, second columns.
>>
>> my $query_seq = (split /\t/)[0];
>> my $sub_seq = (split /\t/)[1];
>>
>> But the output is quite odd. The output is
>>
>> Marcal1-PA Marcal1-PA
>> GABA-B-R3-PA GABA-B-R3-PA
>> CG6630-PA CG6630-PA
>> nop5-PA nop5-PA
>> CG7806-PA CG7806-PA
>> CG15161-PA CG15161-PA
>>
>> So could tell me how to fix that? Thanks very much.
>>
>> Amy
>
>That inconsistent output would be likely caused by some fields not being
>separated by an actual tab character, but more than one white space.
>If that's a risk, it's safer to just use \s+ in place of \t+, because
>it will cover both white space and tab separations of the fields.
>
>Also, you can save some typing, and just write it as:
>my ($query_seq, $sub_seq) = (split /\s+/)[0,1];
^^^^
won't work, spaces in fields
>
>I assume you're splitting on $_ somewhere in your code.
sln
------------------------------
Date: Mon, 12 Jan 2009 20:21:29 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How can I access file on machine by address like \\a_machine\pub\list
Message-Id: <f85om4tdl7v6m44861k1vpo3qtg9ku0tg4@4ax.com>
Water Lin <WaterLin1999@gmail.com> wrote:
>On Jan 12, 4:15 pm, Jürgen Exner <jurge...@hotmail.com> wrote:
>> Water Lin <WaterLin1...@gmail.com> wrote:
>> >I need to access file under Windows XP. The path on the network is
>> >something like \\a_machine\pub\list
>>
>> >I don't know what kind of this protocol is.
>>
>> SMB, seehttp://en.wikipedia.org/wiki/Server_Message_Block
>>
>> >And I don't know how I can access this folder by Perl.
>>
>> The easiest way is to assign a drive letter to the SMB share and then
>> use standard Drive:/Path/Filename.ext notation. See "net help use" for
>> details.
>
>But if I need to input password and username while I connect to this
>computer.
You need to _PASS_ username and password as argument to "net use ..."
when attaching the share as a drive. That is different from entering a
pwd.
>Is there any good solution for this problem?
That depends upon what "the problem" is.
The most simple approach is to just include uid and pwd in the call to
"net use ..." in the script. Of course that would be in clear text and
therefore you need to make sure, that nobody but you has permissions to
read or execute the script.
Depending upon your situation this may or may not be enough security.
Other approaches include e.g. storing the credentials in a separate,
secured and/or encrypted file, providing the credentials manually upon
starting the script, having a different script attaching the drive,
attaching the drive manually and then running the automated script, ....
jue
------------------------------
Date: Mon, 12 Jan 2009 19:37:17 -0800 (PST)
From: Water Lin <WaterLin1999@gmail.com>
Subject: Re: How can I access file on machine by address like \\a_machine\pub\list
Message-Id: <6d22bc97-01e6-48af-9a98-ca0d6f3e8b12@d36g2000prf.googlegroups.com>
On Jan 12, 4:15=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> Water Lin <WaterLin1...@gmail.com> wrote:
> >I need to access file under Windows XP. The path on the network is
> >something like \\a_machine\pub\list
>
> >I don't know what kind of this protocol is.
>
> SMB, seehttp://en.wikipedia.org/wiki/Server_Message_Block
>
> >And I don't know how I can access this folder by Perl.
>
> The easiest way is to assign a drive letter to the SMB share and then
> use standard Drive:/Path/Filename.ext notation. See "net help use" for
> details.
>
> jue
Yes, it works.
But if I need to input password and username while I connect to this
computer.
Is there any good solution for this problem?
Thanks
------------------------------
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 V11 Issue 2119
***************************************