[28478] in Perl-Users-Digest
Perl-Users Digest, Issue: 9842 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 13 09:05:41 2006
Date: Fri, 13 Oct 2006 06:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 13 Oct 2006 Volume: 10 Number: 9842
Today's topics:
Re: bless an object in a BEGIN block (Singleton) anno4000@radom.zrz.tu-berlin.de
Contradictory tags in ImageMagick's identify -verbose <dont-use-this@arcor.de>
Re: FAQ 4.36 How can I expand variables in text strings <bik.mido@tiscalinet.it>
Re: LWP and Unicode <benmorrow@tiscali.co.uk>
Problem with coderef and Test::Harness; carlo.maier@netcologne.de
Re: Problem with coderef and Test::Harness; anno4000@radom.zrz.tu-berlin.de
Re: Problem with coderef and Test::Harness; carlo.maier@netcologne.de
Re: Probs with nested conditions <bik.mido@tiscalinet.it>
Re: Probs with nested conditions <bik.mido@tiscalinet.it>
Re: Probs with nested conditions <bik.mido@tiscalinet.it>
Re: Reading substitution patterns from file <maciej.ogrodniczuk@gmail.com>
Re: Reading substitution patterns from file <peace.is.our.profession@gmx.de>
Re: Reading substitution patterns from file <peace.is.our.profession@gmx.de>
Re: Reading substitution patterns from file <peace.is.our.profession@gmx.de>
Re: Reading substitution patterns from file <rvtol+news@isolution.nl>
Re: Reading substitution patterns from file <tadmc@augustmail.com>
Re: Regarding junk characters !Help <peace.is.our.profession@gmx.de>
Re: Regarding junk characters !Help anno4000@radom.zrz.tu-berlin.de
Re: Regarding junk characters !Help <peace.is.our.profession@gmx.de>
Re: Research Collaboration Request anno4000@radom.zrz.tu-berlin.de
Re: Sorting and moving files to dir for DVD burn <bik.mido@tiscalinet.it>
Re: Sorting and moving files to dir for DVD burn (at)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Oct 2006 10:14:57 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: bless an object in a BEGIN block (Singleton)
Message-Id: <4p9791FhtsqjU2@news.dfncis.de>
Davy <zhushenli@gmail.com> wrote in comp.lang.perl.misc:
>
> anno4000@radom.zrz.tu-berlin.de wrote:
> > Davy <zhushenli@gmail.com> wrote in comp.lang.perl.misc:
> > >
> > > anno4000@radom.zrz.tu-berlin.de wrote:
> > > > Davy <zhushenli@gmail.com> wrote in comp.lang.perl.misc:
> > > > > Hi all,
> > > > >
> > > > > A perl design pattern document talk about Singleton.
> > > > > (http://www.perl.com/pub/a/2003/06/13/design1.html?page=2)
> > > > >
> > > > > My problem is what's the BEGIN block mean? I just can not find it in
> > > > > Perl Doc.
> > > >
> > > > It's in perlmod.
> > > >
> > > > A BEGIN block is executed as soon as it is compiled, thus before
> > > > any run-time action happens.
> > > [snip]
> > > Hi,
> > >
> > > If I call Name->new() several times, the $singleton will have only one
> > > copy in memory.
> >
> > Right. "new" is a misnomer here, it always gives you the pre-created
> > single object of the class.
> >
> > > But as you said, if not use BEGIN, the $singleton will have one copy
> > > according to one object.
> > > Is my understanding right?
> >
> > BEGIN doesn't change what the code in the block does, it only determines
> > when it does it, namely as early as possible. I don't think it's
> > necessary in the original context.
> [snip]
>
> Thanks!
>
> But design pattern Singleton means there is only one copy in the memory
> that everyone (every object) can share. So I think there must be some
> meaning to "bless in BEGIN block".
>
> I have searched bless in this group and find "bless means link the
> reference to the class". Therefore, if "bless in BEGIN i.e. bless at
> compile time", maybe only one reference is generated?
Did you read my post?
> > BEGIN doesn't change what the code in the block does, it only
> > determines when it does it
bless() in BEGIN does the exact same thing it does elsewhere. There
is only one object in the class because only one is generated, whether
in BEGIN or not. BEGIN is entirely inessential in the code.
Anno
------------------------------
Date: Fri, 13 Oct 2006 14:08:23 +0200
From: Johannes Kiehl <dont-use-this@arcor.de>
Subject: Contradictory tags in ImageMagick's identify -verbose
Message-Id: <pan.2006.10.13.12.08.23.323540@arcor.de>
Hi all,
I seem to find contradictions in the output of "identify -verbose".
1. Some images are tagged "Class: DirectClass" and "Type: Palette"
at the same time (I understand that DirectClass means linear colours,
not a palette?)
2. Some are tagged to have no "Matte", but one or more bits of
Alpha (=transparency) channel (I thought one requires the other?)
I want to resolve these contradictions by looking at "Channel
depth:" for transparency (thus, ignoring Matte) and at the "Class:"
tag to decide the Palette vs. Linear colours issue.
My full perl script (rambling through an image directory, calling
"identify" for each, parsing the output, and printing a compact
record on the image type) can be found here:
http://faq.perl-community.de/bin/view/Wissensbasis/InhaltPerlSkripteDateien
What do you think? is this more or less it, or am I missing something?
thanks for all feedback,
Johannes
--
Please don't send personal email to the From: address. -->>
ed tod iduej ta oj :siht rof bmud oot era stobmaps epoH <<--
------------------------------
Date: 13 Oct 2006 12:18:35 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FAQ 4.36 How can I expand variables in text strings?
Message-Id: <rppui2t2fv9go8u5l86emtlu3v1mk04dp0@4ax.com>
On Fri, 13 Oct 2006 09:45:01 +0200, Martijn Lievaart
<m@remove.this.part.rtij.nl> wrote:
>> eval { $text =~ s/(\$\w+)/$1/eeg };
>> die if $@;
>
>What is wrong with
> $text = eval "$text";
Nothing. Except that one should not peruse eval(), and in particular
string eval() anyway. But more importantly, that requires $text to
hold valid perl code, and then it will store the value of the last
expression of it into $text again, which doesn't make much sense to me
at all. Oh, and while we're there, "$text" is yet another instance of
useless quoting of variables. Unless you've overloaded double quotes,
of course - before someone points it out...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 13 Oct 2006 00:29:24 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: LWP and Unicode
Message-Id: <knv204-dar.ln1@osiris.mauzo.dyndns.org>
[attributions tidied slightly]
Quoth "Peter J. Holzer" <hjp-usenet2@hjp.at>:
> On 2006-10-11 23:03, Ben Morrow <benmorrow@tiscali.co.uk> wrote:
> > Quoth "Peter J. Holzer" <hjp-usenet2@hjp.at>:
> >> On 2006-10-11 03:03, Ben Morrow <benmorrow@tiscali.co.uk> wrote:
> >> > Quoth "Peter J. Holzer" <hjp-usenet2@hjp.at>:
> >> >> >> On 6 Oct 2006, benmorrow@tiscali.co.uk wrote:
> >> >> >>>
> >> >> >>> It's not a question of this group's charter, it applies
> >> >> >>> generally on Usenet. There is no header in a Usenet article
> >> >> >>> that specifies a charset, so no way to use anything other
> >> >> >>> than the default ASCII.
> >> >>
> >> >> Content-Type: text/plain; charset=...
> >> >>
> >> >> Introduced in RFC 1341 (June 1992). It is true that RFC 1036 was never
> >> >> updated, but MIME is current practice on usenet.
> >> >
> >> > Really??? I was under the impression it was considered rude.
> >>
> >> If it is, then most posters in this group are rude (well, some people
> >> think this is the case even without MIME :-)).
> >>
> >> I have currently 2805 messages from this group in my spool, 1954 of
> >> which (70%) are MIME messages. Of these, about 1400 use ISO-8859-1,
> >> about 400 use US-ASCII, about 70 UTF-8, and about 30 ISO-8859-15.
> >
> > OK, maybe I wasn't clear. What I meant was that actually making any
> > *use* of MIME (as opposed to simply being passively conformant with it)
> > such as multipart messages, signed messages;
>
> Properly declaring the used charset *is* a use of MIME. There is no way
> you can do that without using MIME.
Of course. My position *was* that since MIME is not used on Usenet,
there is no way to declare the charset; and hence one should not use
charsets other than that generally prevailing in the group (which, in
this group, is US-ASCII); *however*...
> > in fact any messages that are not 'text/plain; charset=us-ascii'
> > appears to me to be considered rude.
>
> Given that about 50% of the messages in this group fit that description
> and nobody except you is complaining, your perception appears to me to
> be slightly off.
...given this...
> > However, my newsreader, although it makes some attempt to handle MIME,
> > doesn't appear to handle them at all; while you could say 'that's your
> > problem'
>
> I do. You are using a newsreader which hasn't been maintained for 5
> years.
>
> > I would respectfully disagree until 1036 is updated.
>
> I've almost given up hope on that. I don't recall when USEFOR was
> established, but it must have been in the late 90's. So far they haven't
> managed to produce a single RFC.
...and these, it appears I am in the wrong. I apologise. It looks like I
may have to start looking for a new newsreader: damn :). I'd just about
weaned myself off rn and onto trn, and now it seems that isn't adequate
either. Ah well, such is life.
[quotes slightly reordered for clarity]
> It may have escaped your attention, but English is not the only language
> used on Usenet, but it is the only language for which US-ASCII is
> sufficient. I don't have any statistics at hand, but don't think I'm far
> off when I estimate that about half of the (text) traffic on Usenet is
> not in English, and therefore also not in US-ASCII.
I realise it may not have been entirely clear from my posts in this
thread, but I am very well aware that much of Usenet is not conducted in
English :). However, since I know nothing about how groups that don't
speak English manage charsets and the like (I was under the impression
that there was some kind of implicit agreement to use, e.g. ISO8859-1 or
KOI8-R or whatever within one particular group or hierarchy, since I
wasn't aware newsreaders routinely 'did' MIME; again, it seems I was
wrong and I can only plead ignorance and too much faith in the RFCs in
that regard) I did not consider myself in a position to comment on that
situation.
If anyone got the impression that I think English should be somehow a
priviledged language on Usenet (except by the accidents of its origin,
which ought by now to have been erased) then I can only apologise
(again) for any offence caused and state for the record that that idea
is of course complete nonsense.
(Hmm, I seem to have dug myself into something of a hole here.
Whoops...)
Ben
--
You poor take courage, you rich take care:
The Earth was made a common treasury for everyone to share
All things in common, all people one. [benmorrow@tiscali.co.uk]
'We come in peace'---the order came to cut them down.
------------------------------
Date: 13 Oct 2006 04:09:28 -0700
From: carlo.maier@netcologne.de
Subject: Problem with coderef and Test::Harness;
Message-Id: <1160737768.331112.235590@b28g2000cwb.googlegroups.com>
Hi Folks,
i would like to use the Test::Harness Module to do some program-tests.
My test script is as follows:
__BEGIN__
#!/usr/local/bin/perl
#
use MyTestModule;
my
($dbinstanz,$user,$pass)=("$ENV{HOST}_$ENV{ORACLE_SID}",$ENV{DB_USER},
$ENV{DB_PASSWORD});
my $obj = new MyTestModule($dbinstanz, $user, $pass,
'test/test-plan-data.xls');
use Test::Harness;
my @tests;
sub testcase {
my ($testcasenr)=@_;
print "\n";
$obj->LoadTestData($testcasenr);
$obj->RunProgram();
$obj->GetProgramResults();
ok( &CompareResult($testcasenr)==0, "Testcase-Nr: $testcasenr");
};
my $coderef=\&testcase;
# in der Schleife die Tests von 1 bis 12 durchlaufen
for my $i (1 .. 12) {
push @tests, $coderef($i);
}
runtests(@tests);
# Compare the result...
use File::Compare(compare_text);
sub CompareResult {
# do compare
}
__END__
I am getting the following result, when executing on Commandline:
[myuser@zuse1] /work/lvs/unix/src/nl11b/test> mycode.pl
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
FAILED--12 test scripts could be run, alas--no output ever seen
What am i doing wrong? Is is not possible to pass an array of coderefs
to the Test::Harness Module.
I'm not sure how to pass variables to coderefs?
Any help is very appreciated.
Thanks in advance.
Carlo
------------------------------
Date: 13 Oct 2006 12:20:23 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Problem with coderef and Test::Harness;
Message-Id: <4p9ek7Fhqi1oU1@news.dfncis.de>
<carlo.maier@netcologne.de> wrote in comp.lang.perl.misc:
> Hi Folks,
>
> i would like to use the Test::Harness Module to do some program-tests.
Test::Harness is normally not used in the test scripts themselves.
It is a module that helps run and evaluate one or more test scripts.
The test scripts typically use Test and Test::More and related modules.
> My test script is as follows:
>
> __BEGIN__
> #!/usr/local/bin/perl
> #
> use MyTestModule;
>
> my
> ($dbinstanz,$user,$pass)=("$ENV{HOST}_$ENV{ORACLE_SID}",$ENV{DB_USER},
> $ENV{DB_PASSWORD});
>
> my $obj = new MyTestModule($dbinstanz, $user, $pass,
> 'test/test-plan-data.xls');
>
> use Test::Harness;
>
> my @tests;
>
> sub testcase {
> my ($testcasenr)=@_;
> print "\n";
> $obj->LoadTestData($testcasenr);
> $obj->RunProgram();
> $obj->GetProgramResults();
> ok( &CompareResult($testcasenr)==0, "Testcase-Nr: $testcasenr");
> };
> my $coderef=\&testcase;
>
> # in der Schleife die Tests von 1 bis 12 durchlaufen
> for my $i (1 .. 12) {
> push @tests, $coderef($i);
> }
>
> runtests(@tests);
runtests() expects one or more file names (of test scripts to run).
You are giving it coderefs. That is not going to work.
>
> # Compare the result...
> use File::Compare(compare_text);
> sub CompareResult {
> # do compare
> }
> __END__
>
> I am getting the following result, when executing on Commandline:
>
> [myuser@zuse1] /work/lvs/unix/src/nl11b/test> mycode.pl
> CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
Sure. It looks for the (stringified) coderefs as file names and doesn't
find them.
[...]
> What am i doing wrong? Is is not possible to pass an array of coderefs
> to the Test::Harness Module.
The documentation of Test::Harness seems to be quite clear about
that. It expects file names, not coderefs.
Are you sure you even want to use Test::Harness? Your code shows
very little of what is actually happening, so it's hard to guess.
> I'm not sure how to pass variables to coderefs?
$coderef->( $var1, $var2);
calls the coderef with arguments $var1 and $var2. I don't see how
that is pertinent to your problem.
Anno
------------------------------
Date: 13 Oct 2006 05:44:02 -0700
From: carlo.maier@netcologne.de
Subject: Re: Problem with coderef and Test::Harness;
Message-Id: <1160743442.795597.289070@i3g2000cwc.googlegroups.com>
I realized from the docs that all Test::Harness - Samples were related
on Modules, not on coderefs. But i thought it could be flexible enough
to manage coderefs too. And it would have been nice to get the
statistics from the test::Harness Module.
Thank you very much for your comments.
Carlo
anno4000@radom.zrz.tu-berlin.de schrieb:
> <carlo.maier@netcologne.de> wrote in comp.lang.perl.misc:
> > Hi Folks,
> >
> > i would like to use the Test::Harness Module to do some program-tests.
>
> Test::Harness is normally not used in the test scripts themselves.
> It is a module that helps run and evaluate one or more test scripts.
> The test scripts typically use Test and Test::More and related modules.
>
> > My test script is as follows:
> >
> > __BEGIN__
> > #!/usr/local/bin/perl
> > #
> > use MyTestModule;
> >
> > my
> > ($dbinstanz,$user,$pass)=("$ENV{HOST}_$ENV{ORACLE_SID}",$ENV{DB_USER},
> > $ENV{DB_PASSWORD});
> >
> > my $obj = new MyTestModule($dbinstanz, $user, $pass,
> > 'test/test-plan-data.xls');
> >
> > use Test::Harness;
> >
> > my @tests;
> >
> > sub testcase {
> > my ($testcasenr)=@_;
> > print "\n";
> > $obj->LoadTestData($testcasenr);
> > $obj->RunProgram();
> > $obj->GetProgramResults();
> > ok( &CompareResult($testcasenr)==0, "Testcase-Nr: $testcasenr");
> > };
> > my $coderef=\&testcase;
> >
> > # in der Schleife die Tests von 1 bis 12 durchlaufen
> > for my $i (1 .. 12) {
> > push @tests, $coderef($i);
> > }
> >
> > runtests(@tests);
>
> runtests() expects one or more file names (of test scripts to run).
> You are giving it coderefs. That is not going to work.
>
> >
> > # Compare the result...
> > use File::Compare(compare_text);
> > sub CompareResult {
> > # do compare
> > }
> > __END__
> >
> > I am getting the following result, when executing on Commandline:
> >
> > [myuser@zuse1] /work/lvs/unix/src/nl11b/test> mycode.pl
> > CODE(0x40491ad8)...CODE(0x40491ad8) does not exist
>
> Sure. It looks for the (stringified) coderefs as file names and doesn't
> find them.
>
> [...]
>
> > What am i doing wrong? Is is not possible to pass an array of coderefs
> > to the Test::Harness Module.
>
> The documentation of Test::Harness seems to be quite clear about
> that. It expects file names, not coderefs.
>
> Are you sure you even want to use Test::Harness? Your code shows
> very little of what is actually happening, so it's hard to guess.
>
> > I'm not sure how to pass variables to coderefs?
>
> $coderef->( $var1, $var2);
>
> calls the coderef with arguments $var1 and $var2. I don't see how
> that is pertinent to your problem.
>
> Anno
------------------------------
Date: 13 Oct 2006 12:24:21 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Probs with nested conditions
Message-Id: <s4qui2tk7gskhda40advdmjrbdq0o1jco4@4ax.com>
On 12 Oct 2006 17:20:21 -0700, ultimard@yahoo.com wrote:
>if ( $ar{$ar}{loc} eq 'HBR' and \
^
^
Huh?!? This is not the shell...
> $ar{$ar}{ar_typ} eq 'DMX' and $ar{$ar}{tier} = 146 )
Your third condition is an assignment. Is that what you want? If so
then you should know that logical C<and> is short circuiting which is
fine and generally extremely useful, but chances are that it may not
do what you want if you need side effects, but I wouldn't consider
that a good programming style in any case. However it seems *much*
more probable that you want numeric equality, which is C<==> and not
C<=>.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 13 Oct 2006 12:26:09 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Probs with nested conditions
Message-Id: <4cqui29mpri58tsg5hv1fcmgnufgabuj5t@4ax.com>
On Thu, 12 Oct 2006 20:19:40 -0500, Tad McClellan
<tadmc@augustmail.com> wrote:
>There are 2 conditions...
[...]
>> if ( $ar{$ar}{loc} eq 'HBR' and \
>> $ar{$ar}{ar_typ} eq 'DMX' and $ar{$ar}{tier} = 146 )
> ^
> ^
>... and 1 assignment.
Which *is* a condition, which always evaluates to true and is not what
the OP wants...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 13 Oct 2006 12:27:26 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Probs with nested conditions
Message-Id: <aequi2p1216mqmshvvuuj3sceb306fuspr@4ax.com>
On Fri, 13 Oct 2006 03:03:22 GMT, "Mumia W. (reading news)"
<paduille.4059.mumia.w@earthlink.net> wrote:
>> if ( $ar{$ar}{loc} eq 'HBR' and \
>
>There's no need for the backslash.
There's no need for it and it will have a different semantic than it
may possibly have in *sh programming, hence do something very
different from what the OP actually expects...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 13 Oct 2006 03:31:51 -0700
From: "Orangutan" <maciej.ogrodniczuk@gmail.com>
Subject: Re: Reading substitution patterns from file
Message-Id: <1160735511.718674.98890@b28g2000cwb.googlegroups.com>
Hello,
In fact, my own problem is even more general than what I cited, but the
idea is identical.
Here is a piece to illustrate:
----------------
# We have 2 patterns, let's suppose they were read from a file:
$pattern1 = "([kw])eep";
$pattern2 = "$1ept";
# Here are 2 texts which we will use to test the patterns:
$text1 = "keep";
$text2 = "weep";
# And here is my substitution;
$text1 =~ s/$pattern1/$pattern2/;
$text2 =~ s/$pattern1/$pattern2/;
print "$text1\n$text2\n";
----------------
So, the idea is to change "keep" or "weep" to "kept" or "wept". The
example is stupid, but the idea is important: to be able to use $1 on
the right-hand side.
Such piece of course works:
$text1 =~ s/$pattern1/$1ept/;
$text2 =~ s/$pattern1/$1ept/;
Am I missing something?
Regs,
Maciek
------------------------------
Date: Fri, 13 Oct 2006 12:44:35 +0200
From: Mirco Wahab <peace.is.our.profession@gmx.de>
Subject: Re: Reading substitution patterns from file
Message-Id: <egnqv2$nvo$1@mlucom4.urz.uni-halle.de>
Thus spoke Orangutan (on 2006-10-13 12:31):
> In fact, my own problem is even more general than what I cited, but the
> idea is identical.
> # We have 2 patterns, let's suppose they were read from a file:
> $pattern1 = "([kw])eep";
> $pattern2 = "$1ept";
>
> # Here are 2 texts which we will use to test the patterns:
> $text1 = "keep";
> $text2 = "weep";
>
> # And here is my substitution;
> $text1 =~ s/$pattern1/$pattern2/;
> $text2 =~ s/$pattern1/$pattern2/;
>
> print "$text1\n$text2\n";
> ----------------
>
> So, the idea is to change "keep" or "weep" to "kept" or "wept". The
> example is stupid, but the idea is important: to be able to use $1 on
> the right-hand side.
You have to 'double-eval' the right side, because
you must restore the $1 correctly and *then*
evaluate it to its value:
my $pattern1 = "([kw])eep";
my $pattern2 = '$1 . \'ept\'';
# Here are 2 texts which we will use to test the patterns:
my $text1 = "keep";
my $text2 = "weep";
# And here is my substitution;
$text1 =~ s/$pattern1/$pattern2/ee;
$text2 =~ s/$pattern1/$pattern2/ee;
print "$text1\n$text2\n";
Regards
M.
(maybe somebody does it with *one* /e,
but I can't figure now without thinking
longer ;-)
------------------------------
Date: Fri, 13 Oct 2006 12:48:20 +0200
From: Mirco Wahab <peace.is.our.profession@gmx.de>
Subject: Re: Reading substitution patterns from file
Message-Id: <egnr63$nvo$2@mlucom4.urz.uni-halle.de>
Thus spoke Mirco Wahab (on 2006-10-13 12:44):
> my $pattern1 = "([kw])eep";
> my $pattern2 = '$1 . \'ept\'';
which you can also write shorter as
my $pattern2 = "\$1.'ept'";
Regards
M.
------------------------------
Date: Fri, 13 Oct 2006 13:13:58 +0200
From: Mirco Wahab <peace.is.our.profession@gmx.de>
Subject: Re: Reading substitution patterns from file
Message-Id: <egnsm4$ogc$1@mlucom4.urz.uni-halle.de>
Thus spoke Mirco Wahab (on 2006-10-13 12:48):
> Thus spoke Mirco Wahab (on 2006-10-13 12:44):
>> my $pattern1 = "([kw])eep";
>> my $pattern2 = '$1 . \'ept\'';
>
> which you can also write shorter as
> my $pattern2 = "\$1.'ept'";
and even shorter (and more efficient):
my $pattern2 = '"$1ept"';
Regards
M.
------------------------------
Date: Fri, 13 Oct 2006 13:42:45 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Reading substitution patterns from file
Message-Id: <ego5bm.ss.1@news.isolution.nl>
Mirco Wahab schreef:
> Mirco Wahab:
>> my $pattern1 = "([kw])eep";
>> my $pattern2 = '$1 . \'ept\'';
>
> which you can also write shorter as
>
> my $pattern2 = "\$1.'ept'";
Alternatives:
my $pattern2 = q{$1.'ept'};
my $pattern2 = q{"$1ept"};
though you should really write that last one as
my $pattern2 = q{"${1}ept"};
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Fri, 13 Oct 2006 06:56:33 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Reading substitution patterns from file
Message-Id: <slrneiuvnh.9bv.tadmc@magna.augustmail.com>
Mirco Wahab <peace.is.our.profession@gmx.de> wrote:
> Thus spoke Orangutan (on 2006-10-13 11:32):
>> open (INPUT,"file.in");
> Change this to:
> open (my $inhandle, '<', 'file.in');
Then change that to:
open(my $inhandle, '<', 'file.in') or die "could not open 'file.in' $!";
Since you should always check the return value from open() to
ensure that you actually got what you asked for.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 13 Oct 2006 12:13:53 +0200
From: Mirco Wahab <peace.is.our.profession@gmx.de>
Subject: Re: Regarding junk characters !Help
Message-Id: <egnp5g$nj8$1@mlucom4.urz.uni-halle.de>
Thus spoke Gaurav (on 2006-10-13 11:59):
> I am using the following script to read a text file and write it into
> another text file. Below is a sample of this :
'text file' ?
> The following is the sample text file.
>
> 000.50 000.90 BBBBB AAAA NO 14 NNN EEEE UUUUU
> 000.63 001.03 BBBBBbbb XXXXX NO 1 HOTEL YYYYYYYYU
> 000.60 001.56 XXXX RMH NO 299 AAA BBBBBB CCCCCC
> 000.70 001.49 DDDDDDDD TTTTT NO 254 AAA BBBBBB CCCCCC
> 000.70 001.47 DDDDDDDD TTTTT NO 248/249 AAA BBBBBB CCCCCC
>
> The problem is I cannot write the whole file, the process ended when it
> reaches the char (it is a junk char ASCII value is 20). How to I read
> the whole text file and write it into new text file. help me.
The ASCII '->' (CTRL-Z?) is surely no 'text'.
You have to read the whole thing in 'binary mode',
like:
...
open(my $testhandle, '<', $textFilename) or die "in agony $!";
open(my $recordvalues, '>', $outdatafile) or die "in agony $!";
binmode $_ for $testhandle, $recordvalues; # set handles to 'binary' on windows!
while(<$testhandle>) {
print $recordvalues $_;
}
close for $testhandle, $recordvalues;
...
Regards
Mirco
------------------------------
Date: 13 Oct 2006 10:17:32 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Regarding junk characters !Help
Message-Id: <4p97dsFhtsqjU3@news.dfncis.de>
Gaurav <Gaurav.Saikia@gmail.com> wrote in comp.lang.perl.misc:
> Hi,
>
> I am using the following script to read a text file and write it into
> another text file.
> Below is a sample of this :
>
> open(TESTFILE,$textFilename);
> open(RECORDVALUES,">$outdatafile");
> while(<TESTFILE>)
> {
> print RECORDVALUES $_;
> }
> close (TESTFILE);
> close (RECORDVALUES);
>
> The following is the sample text file.
>
> 000.50 000.90 BBBBB AAAA NO 14 NNN EEEE UUUUU
> 000.63 001.03 BBBBBbbb XXXXX NO 1 HOTEL YYYYYYYYU
> 000.60 001.56 XXXX RMH NO 299 AAA BBBBBB CCCCCC
> 000.70 001.49 DDDDDDDD TTTTT NO 254 AAA BBBBBB CCCCCC
> 000.70 001.47 DDDDDDDD TTTTT NO 248/249 AAA BBBBBB CCCCCC
>
> The problem is I cannot write the whole file, the process ended when it
> reaches the char (it is a junk char ASCII value is 20). How to I read
> the whole text file and write it into new text file. help me.
perldoc -f binmode
Anno
------------------------------
Date: Fri, 13 Oct 2006 12:21:12 +0200
From: Mirco Wahab <peace.is.our.profession@gmx.de>
Subject: Re: Regarding junk characters !Help
Message-Id: <egnpj7$nj8$2@mlucom4.urz.uni-halle.de>
Thus spoke Mirco Wahab (on 2006-10-13 12:13):
> open(my $testhandle, '<', $textFilename) or die "in agony $!";
> open(my $recordvalues, '>', $outdatafile) or die "in agony $!";
> ...
> close for $testhandle, $recordvalues;
what a silly bug! must read
close $_ for ...
Sorry
M.
------------------------------
Date: 13 Oct 2006 10:11:03 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Research Collaboration Request
Message-Id: <4p971nFhtsqjU1@news.dfncis.de>
<bekijkfotos@gmail.com> wrote in comp.lang.perl.misc:
> Dear perl newsgroups,
>
> I am looking for someone with Perl skills that is willing to help me in
> a small research project.
I don't know what you call small. What you describe below looks like
quite a challenge.
[...]
> This procedure should contain the following steps:
> - Parsing of a pdf (or text) file, which lists all abstracts of the
> ISMRM, to create a database with relevant information.
> - Performing a set of queries in Pubmed for each abstract, to maximize
> the sensitivity of procedure.
>
> For example, I will use one of my own abstracts to illustrate the
> possible different appearance of an abstract and its final publication
> in a journal:
>
> Abstract:
> J.F.A. Jansen, J.M. Hakumäki, L. Ifeanyi, M. Shamblott, J. Gearhart
> and P.C.M. van Zijl
> 1H-NMR spectroscopy of stem cells in vitro demonstrates high
> proliferation state.
> Proc. Int. Soc. Mag. Reson. Med. 10, Honolulu, Hawaii, USA, May 2002:
> 131
>
> Paper:
> Jacobus F.A. Jansen, Michael J. Shamblott, Peter C.M. van Zijl, Kimmo
> K. Lehtimäki, Jeff W.M. Bulte, John D. Gearhart, and Juhana M.
> Hakumäki
> Stem Cell Profiling by Nuclear Magnetic Resonance Spectroscopy.
> Magnetic Resonance in Medicine 56 (3): 666-670 SEP 2006
>
> Although both the abstract and the paper describe essentially the same
> research, the title has changed, and the authors are different. It
> requires a relative sophisticated search algorithm to find the paper
> based on the information from the abstract, and to consider it as a
> match.
>
> Unfortunately my Perl skills are very limited, and I don't think it
> is plausible that I will succeed in creating this sophisticated search
> algorithm.
You're mixing up two stages. First you need to develop an algorithm.
Then you can decide in which language to implement it (Perl is a likely
choice) and find a programmer to do so.
The hard part will be the development of an algorithm that makes
sense of the mess. I don't think a totally automatic procedure
will suffice. Aim for a pre-selection that finds plausible pairs
but prepare to hand-select the final list from that.
> Therefore I was hoping that someone could help me out with
> this. (e.g. a student who could use it to improve his/her resume?). If
> possible, I'd like to submit the results as an abstract for the ISMRM
> 2007, for which the deadline is 15 November 2006.
Four weeks? That won't do for something this size, not as a one-man
job.
Anno
------------------------------
Date: 13 Oct 2006 12:19:47 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Sorting and moving files to dir for DVD burn
Message-Id: <o0qui2d5anfdnnrmimu4k3ljusoaipv0bv@4ax.com>
On 12 Oct 2006 22:36:54 +0200, Michele Dondi <bik.mido@tiscalinet.it>
wrote:
>>use constant QUOTA => 4.7 * 2**30;
>
>Haha! Don't be fooled by the hype. I thought so too. But it turned out
>to be 4.7 * 10**3...
In fact I was the original author of that line myself...
;-P
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 13 Oct 2006 08:30:01 -0400
From: at <"romorris(at)"@bellsouth.net>
Subject: Re: Sorting and moving files to dir for DVD burn
Message-Id: <6FLXg.61246$vX5.27883@bignews8.bellsouth.net>
Michele Dondi wrote:
> On 12 Oct 2006 22:36:54 +0200, Michele Dondi <bik.mido@tiscalinet.it>
> wrote:
>
>
>>> use constant QUOTA => 4.7 * 2**30;
>>>
>> Haha! Don't be fooled by the hype. I thought so too. But it turned out
>> to be 4.7 * 10**3...
>>
>
> In fact I was the original author of that line myself...
> ;-P
>
>
> Michele
>
So what does it mean?
------------------------------
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 9842
***************************************