[28551] in Perl-Users-Digest
Perl-Users Digest, Issue: 9915 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 1 11:05:50 2006
Date: Wed, 1 Nov 2006 08:05:06 -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 Wed, 1 Nov 2006 Volume: 10 Number: 9915
Today's topics:
Re: Abysmal performance of Net::SFTP (and I have GMP & <bik.mido@tiscalinet.it>
Re: Abysmal performance of Net::SFTP (and I have GMP & <zentara@highstream.net>
Re: FAQ 2.2 How can I get a binary version of perl? <bik.mido@tiscalinet.it>
File Permissions using NIS and NFS and copying via perl alerman@gmail.com
Re: Homemade youtube style (Flash??) videos? zentara@highstream.net
Re: Homemade youtube style (Flash??) videos? <bik.mido@tiscalinet.it>
Re: Interesting behaviour with lexical variable <rvtol+news@isolution.nl>
Re: killing processes using perl (artsd) <andreas./@\.poipoi.de>
Re: killing processes using perl (artsd) <andreas./@\.poipoi.de>
longest common substring <henry.townsend@not.here>
LWP::UserAgent and non-default outgoing IP <balrog2000@o2.pl>
Re: Mailbox-style directory hashing <rvtol+news@isolution.nl>
Re: Mailbox-style directory hashing <tadmc@augustmail.com>
Need to retain the order of array of hash references. <kalyanrajsista@gmail.com>
Putting a line in a specific place in a file <bryan@worldspice.net>
Re: Putting a line in a specific place in a file anno4000@radom.zrz.tu-berlin.de
Re: Regular Expression Question Why Doesn't this Match? <thepoet_nospam@arcor.de>
Re: Regular Expression Question Why Doesn't this Match? <wahab@chemie.uni-halle.de>
Re: Regular Expression Question Why Doesn't this Match? <rvtol+news@isolution.nl>
scoping file handles dcruncher4@aim.com
Re: scoping file handles <someone@example.com>
Re: Use of uninitialized variable with print << HTMLEND <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 01 Nov 2006 10:14:08 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Abysmal performance of Net::SFTP (and I have GMP & Pari)
Message-Id: <krogk2d9udejqafan6j4fcva44dpf87f48@4ax.com>
On 31 Oct 2006 17:30:40 -0800, usenet@DavidFilmer.com wrote:
>I am having terrible problems with very poor performance when using
>Net::SFTP. Specifically, it takes about 10 seconds for a machine to
>transfer a 1 MB file to itself (localhost), and this is a brand new,
I cannot help you. I've been wondering whether it would have been
appropriate to reply at all. All I can say is that it worked like a
charm for me when I had to use it. However I had some other issues for
which I joined the mailing list: there and elsewhere complains about
speed problems abounded. But they were all due to the lack of a fast
bigint implementation, and were all sorted out when one was provided.
Other than this, I was about to point you to Net::SSH2, but I see you
know it and you've been considering it too. So the only remaining tiny
piece of advice I can give you is to join the ml too, maybe they can
help you...
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: Wed, 01 Nov 2006 14:35:51 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Abysmal performance of Net::SFTP (and I have GMP & Pari)
Message-Id: <rrahk2p5m3ofo55nk7p91cmtvhj03u1l0i@4ax.com>
On 31 Oct 2006 17:30:40 -0800, usenet@DavidFilmer.com wrote:
>So the machine is definitely spending most of its time with the crypto
>stuff (not I/O stuff), which is to be expected, but it is taking a LONG
>time to do the crypto stuff.
>
>I know that Math::BigInt::GMP (or Pari) is very important for SFTP
>performance. But I have both libraries and their BigInt modules
>installed. Is there ANOTHER math module that I need???
Did you rebuild the Net::SFTP and the Net::SSH::Perl module
after you installed the Math modules? And I mean rebuild them
from scratch, not just install some premade package?
When things don't work, usually the best bet is to upgrade to
the latest versions of all modules, and Perl version, AND build
them yourself so you can see any warnings.
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Wed, 01 Nov 2006 10:05:41 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FAQ 2.2 How can I get a binary version of perl?
Message-Id: <lnogk2lm4mk2l9hgp2iccm5ecvvt6l8237@4ax.com>
On Tue, 31 Oct 2006 21:43:53 -0600, brian d foy
<brian.d.foy@gmail.com> wrote:
>> Surely a mention of ActivePerl is appropriate here.
>
>Indeed, it is. I'll add it. Thanks,
It may also be worth to keep an eye on the vanilla/strawberry thing
(<http://vanillaperl.com/>), because if it eventually gets mature
enough then a mention to it will be appropriate too.
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: 1 Nov 2006 05:56:54 -0800
From: alerman@gmail.com
Subject: File Permissions using NIS and NFS and copying via perl
Message-Id: <1162389414.887331.214610@i42g2000cwa.googlegroups.com>
I have written a script that copies files from a test server to a
production server. The userID's and groupID's are the same on both
servers and we are using NIS.
I set the permissions on the test server to alerman:www-data (I own it,
it is in the web users group) so that the web server can read and
execute it.
The files copy over to the new server, but are always alerman:alerman .
This means that my web server cant read them because of permissions
issues.
Any suggestions?
I have tried both File::Copy and using `cp -p from to`
------------------------------
Date: Wed, 01 Nov 2006 14:35:52 GMT
From: zentara@highstream.net
Subject: Re: Homemade youtube style (Flash??) videos?
Message-Id: <94chk2tb2dg5e2e3jecdujhpvkeserdjji@4ax.com>
On Tue, 31 Oct 2006 18:55:00 +0000 (UTC), Ignoramus18920
<ignoramus18920@NOSPAM.18920.invalid> wrote:
>Like many people, I make pictures and videos and place them on my own
>website (self hosted). I wrote a perl script that makes HTML index
>files for directory structures, along with such nice features as image
>thumbnails, RSS feed for updates, and even "video thumbnails" (small
>animated GIFs that represent first several seconds of a video at the
>rate of one frame per second).
>
>That's all nice. What I would like, though, is to also add
>functionality to generate whatever Youtube is doing to make videos
>that you can see embedded in a page, with the pause and resume buttons
>etc. I assume that it is a Flash presentation. Is there some transcode
>module or perl module that would let me convert a DivX file into a
>video like youtube?
>
>thanks
I think I know what you are talking about. YouTube has some extra fancy
controls to aid in playing the flv file.
I looked into how they do it, and it's not simple, it's some sort of
complicated javascript, which loads some custom script which wraps
the flv video in another video player. (Maybe Ajax?)
I'm just recalling this from memory, but you can try to look at the
raw html page that YouTube uses to play the flv files, and you will
see what I mean.
There are some examples of how to do this on the net, but they require
a web server and browser to view them.
google for "flv pause control" and "flv ajax" , then start reading all
the links.
It's not easy, and IMHO definitely not worth the time, since you
can do the same thing by playing the flv file in mplayer or
gmplayer, without the need for a web server, ajax or javascript.
If you are persistent enough, you will be able to figure it out,
but there is no easy package available to do this.
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Wed, 01 Nov 2006 15:41:38 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Homemade youtube style (Flash??) videos?
Message-Id: <rdchk2pempek8f47enoqcv0a850jo4egpj@4ax.com>
On Wed, 01 Nov 2006 14:35:52 GMT, zentara@highstream.net wrote:
>I looked into how they do it, and it's not simple, it's some sort of
>complicated javascript, which loads some custom script which wraps
>the flv video in another video player. (Maybe Ajax?)
I think this kind of "technology" is called aflax...
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: Wed, 1 Nov 2006 09:06:55 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Interesting behaviour with lexical variable
Message-Id: <ei9ob0.ts.1@news.isolution.nl>
Ben Morrow schreef:
> Named subs are only created once, the
> first time the 'sub foo' statement is executed; anon subs are
> created anew each time, with a new lexical context.
One could also say that the anonymous sub is partly created anew each
time. For instance the code tree can be shared.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Wed, 01 Nov 2006 16:46:17 +0100
From: "andreas" <andreas./@\.poipoi.de>
Subject: Re: killing processes using perl (artsd)
Message-Id: <eff6e$4548c149$5499b0a1$22708@news2.eu.disputo.net>
Am Wed, 01 Nov 2006 06:58:41 +0000 schrieb Mumia W. (reading news):
> #!/bin/sh
> PIDLIST=`ps h -C artsd -o %p | sed -ne '2,$p'`
> for arpid in $PIDLIST
> do
> echo "Would kill $arpid"
> done
> -----------------------------------
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Carp qw(carp croak);
> my @pids = `ps h -C artsd` =~ m/^ +(\d+)/mg;
> shift @pids;
> print "PIDS: @pids\n";
> kill (15, $_) or carp("Failure: $! for $_")
> for (@pids);
>
>
Hello Mumia,
thanks for the Carp & shift hints. To use \d+ is a good idea. If I insert a
debug print @pids; just after line my @pids...; and before the shift.. the
printed line ist empty, at least on my system. There is one artsd running
currently. I'm using perl, v5.8.8. I will play with your solution and try
to get it running even on my system ;-)
-andreas
------------------------------
Date: Wed, 01 Nov 2006 17:01:30 +0100
From: "andreas" <andreas./@\.poipoi.de>
Subject: Re: killing processes using perl (artsd)
Message-Id: <2dccd$4548c4da$5499b0a1$22708@news2.eu.disputo.net>
Am Wed, 01 Nov 2006 08:44:04 +0100 schrieb Dr.Ruud:
> andreas schreef:
>
>
>> Now I started thinking about how to reduce the artsd process count
>> using a perl script and wrote something which works and can possibly
>> be used to remove any processes (cron etc.)
>>
>> #!/usr/bin/perl -w
>> # file: killartsd.pl
>> # kill additional artsd processes - only one is required!
>> # (c)2006 Andreas Mueller andreas%at%poipoi.de
>> #####################################
>
> Remove the -w, and add:
>
> use warnings ;
> use strict ;
ok - I will look for that and try to figure out why?
>
>> # get artsd process ids from ps piped into a sed script
>> $plist=qx'ps h -C artsd | sed "s/\(\([ 0-9]*\|[0-9]*\).*\)/\2/g"';
>
> Whitespace is cheap. The sed-stuff can also be done in Perl of course.
> See "Pipe Opens" in perlopentut.
>
> That regex doesn't mean what you think it means. Compare to:
> s/ *\([0-9]*\).*/\1/g
yes - I found the redundancy a little later and corrected it in version
1.01 ;-) thanks!
currently I use:
$plist=qx'ps h -C artsd | sed "s/\(\([ 0-9]*\).*\)/\2/g"';
I know that [ 0-9]* is not fully correct, but because there is an process
name after the pid the pattern stops with the disadvantage of capturing
additional spaces (or a tab?) before and after the pid. Your solution is
better for this reason.
>
>
>> # remove space+newline to form a list of pids $plist =~ s/ \n/,/g;
>>
>> # remove the ugly last comma in that list $plength=length($plist);
>> $plist=substr($plist,0,$plength-1) unless $plength < 1 ;
>>
>> # convert result to an array because kill() wants an array, isn't it?
>> @parray=split(/,/,$plist);
>
> In stead of the 8 lines above, try this:
>
> my @parray = split / \n/, $plist ;
very good!
>
>
>> # how many process ids are there?
>> $numproc=@parray;
>>
>> # kill all unless there is only one or none kill ('KILL',@parray)
>> unless $numproc < 2 ;
>>
>> My question is whether one knows a better way to do the whole thing or
>> parts of the script?
>
>
>
> #!/usr/bin/perl
> use warnings ;
> use strict ;
>
> my @pids = do
> { local $/ ;
> open my $ph, '-|', 'ps h -C artsd' or die "open ps: $!" ; <$ph> =~
> m/^ *([0-9]+)/gm ;
> } ;
>
> print "Pa: ", getppid(), "\n" ;
> print "Me: $$\n\n" ;
> print "kill '$_'\t?\n" for @pids ;
>
works fine! I've learnt a lot from that, will study the special variables
later - many thanks!!
-andreas
------------------------------
Date: Wed, 01 Nov 2006 10:28:05 -0500
From: Henry Townsend <henry.townsend@not.here>
Subject: longest common substring
Message-Id: <jbKdnfqg07maINXYnZ2dnUVZ_vKdnZ2d@comcast.com>
Is there a standard algorithm or module which finds the N longest common
substrings in a set of text files?
Here's the use case: I'm trying to clean up a very old, very large, and
very ugly build system which has thousands of unparameterized
compile/link commands in hundreds of Makefiles. I want to search them
for frequently-occurring long substrings. Hopefully this will turn up
phrases like "-lrpcsvc -ltermlib -lcurses -ldl -lnsl -lsocket" or
"-DUNIX -DANSI -DUSE_SOCKETS". I would then evaluate these for semantic
meaning, make up reasonable names like $(SYS_LIBS) and $(UNIX_DEFINES),
and do a global replace. Then repeat until satisfied.
I've done some searching but haven't found anything close to the above.
Thanks,
HT
------------------------------
Date: Wed, 01 Nov 2006 13:18:28 +0100
From: Tomek <balrog2000@o2.pl>
Subject: LWP::UserAgent and non-default outgoing IP
Message-Id: <op.tib642dwbdw0a5@balrog.tkraus.com>
Hello!
My box on which Perl runs has several IPs, let's say that:
192.168.0.1 is the first IP and the default one,
192.168.0.5 is the last IP
How to force LWP::UserAgent to connect to remote hosts from IP 192.168.0.3
? I couldn't find it in the manual of LWP :(
Now, it always connects from the first and default IP: 192.168.0.1 :( How
to bind other outgoing address?
Regards, Tomasz Kraus
------------------------------
Date: Wed, 1 Nov 2006 09:12:01 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Mailbox-style directory hashing
Message-Id: <ei9oke.1ao.1@news.isolution.nl>
s1037989 schreef:
> Tad McClellan:
>> s1037989:
>>> #!/usr/bin/perl -w
>>
>> use warnings;
>>
>> Lexical warnings are a big improvement over global warnings.
>
> Interesting...! Why is that?
Read perllexwarn: `perldoc perllexwarn`.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Wed, 1 Nov 2006 06:36:20 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Mailbox-style directory hashing
Message-Id: <slrnekh564.86l.tadmc@tadmc30.august.net>
s1037989@gmail.com <s1037989@gmail.com> wrote:
>
> Tad McClellan wrote:
>> s1037989@gmail.com <s1037989@gmail.com> wrote:
>>
>> > Or, perhaps someone likes what I've started and wants to help improve
>> > the code?
>> >
>> > ---------------------
>> > #!/usr/bin/perl -w
>>
>>
>> use warnings;
>>
>> Lexical warnings are a big improvement over global warnings.
>
> Interesting...! Why is that?
For the same reason that lexical variables are a big improvement
over global variables.
You can control the scope.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 1 Nov 2006 04:26:34 -0800
From: "alwaysonnet" <kalyanrajsista@gmail.com>
Subject: Need to retain the order of array of hash references.
Message-Id: <1162383994.216244.317950@k70g2000cwa.googlegroups.com>
hi all -- Help needed
I'm trying to sort an array of hash-references based on the "A/C No" by
preserving the "Type" order,'ZCurrency' and 'Status' , where "A/C No"
is unique for every record.
Important Note is that - if Records having same "Type","Status" and
"ZCurrency" have different "A/C No" so sorting them with "A/C No"
doesn't effect the actual order of display.
1) I'm looping through every element, checking current record if
"Type","Status" and "ZCurrency" is equal to previous record. if not,
pushing it to final array.
2) if current record matches with previous record, i'm pushing to
another array and sorting them with the "A/C No". Because, both the
records will have same "Type","Status" and "ZCurrency".
3) By this, I got two arrays @final and @curr ... need to merge them
into one by sorting with "A/C No" and preserving the order with
original but sort with "A/C No" if the records have same
"Type","Status" and "ZCurrency".
Partially working code ---
#!/usr/bin/perl
my %type_order = qw/Prefund 1 Receipt 2 Payment 3/;
my @records = (
{'Type'=>'Prefund' , 'A/C No'=>12345 , 'Status'=>'Y',
'ZCurrency' =>'GBP'},
{'Type'=>'Prefund' , 'A/C No'=>45678 , 'Status'=>'Y',
'ZCurrency' =>'SEK'},
{'Type'=>'Prefund' , 'A/C No'=>33333 , 'Status'=>'Y',
'ZCurrency' =>'SEK'},
{'Type'=>'Prefund' , 'A/C No'=>32222 , 'Status'=>'N',
'ZCurrency' =>'SEK'},
{'Type'=>'Receipt' , 'A/C No'=>32365 , 'Status'=>'Y',
'ZCurrency' =>'EUR'},
{'Type'=>'Receipt' , 'A/C No'=>78878 , 'Status'=>'N',
'ZCurrency' =>'AIR'},
{'Type'=>'Receipt' , 'A/C No'=>32435 , 'Status'=>'N',
'ZCurrency' =>'AIR'},
{'Type'=>'Receipt' , 'A/C No'=>64237 , 'Status'=>'N',
'ZCurrency' =>'GBP'},
{'Type'=>'Payment' , 'A/C No'=>22476 , 'Status'=>'Y',
'ZCurrency' =>'AUS'},
{'Type'=>'Payment' , 'A/C No'=>22447 , 'Status'=>'Y',
'ZCurrency' =>'BEL'},
{'Type'=>'Payment' , 'A/C No'=>56546 , 'Status'=>'N',
'ZCurrency' =>'EUR'},
{'Type'=>'Payment' , 'A/C No'=>44444 , 'Status'=>'N',
'ZCurrency' =>'EUR'},
{'Type'=>'Payment' , 'A/C No'=>43434 , 'Status'=>'N',
'ZCurrency' =>'EUR'},
);
foreach $current (@records) {
if ($previous->{'Type'} eq $current->{'Type'} && $previous->{'Status'}
eq $current->{'Status'} && $previous->{'ZCurrency'} eq
$current->{'ZCurrency'}) {
push(@curr,$previous);
push(@curr,$current);
} else {
push(@final,$current);
}
$previous = $current;
}
%seen = ();
foreach $item (@curr) {
push(@uniq, $item) unless $seen{$item}++;
}
@uniq = sort { $type_order{$a->{'Type'}} <=> $type_order{$b->{'Type'}}
||
$a->{'A/C No'} <=> $b->{'A/C No'}
} @uniq;
foreach $x(@uniq) {
print " $x->{'Type'} $x->{'A/C No'} $x->{'Status'}
$x->{'ZCurrency'}\n";
}
I want my final output as
{'Type'=>'Prefund' , 'A/C No'=>12345 , 'Status'=>'Y', 'ZCurrency'
=>'GBP'},
{'Type'=>'Prefund' , 'A/C No'=>33333 , 'Status'=>'Y', 'ZCurrency'
=>'SEK'},
{'Type'=>'Prefund' , 'A/C No'=>45678 , 'Status'=>'Y', 'ZCurrency'
=>'SEK'},
{'Type'=>'Prefund' , 'A/C No'=>32222 , 'Status'=>'N', 'ZCurrency'
=>'SEK'},
{'Type'=>'Receipt' , 'A/C No'=>32365 , 'Status'=>'Y', 'ZCurrency'
=>'EUR'},
{'Type'=>'Receipt' , 'A/C No'=>32435 , 'Status'=>'N', 'ZCurrency'
=>'AIR'},
{'Type'=>'Receipt' , 'A/C No'=>78878 , 'Status'=>'N', 'ZCurrency'
=>'AIR'},
{'Type'=>'Receipt' , 'A/C No'=>64237 , 'Status'=>'N', 'ZCurrency'
=>'GBP'},
{'Type'=>'Payment' , 'A/C No'=>22476 , 'Status'=>'Y', 'ZCurrency'
=>'AUS'},
{'Type'=>'Payment' , 'A/C No'=>22447 , 'Status'=>'Y', 'ZCurrency'
=>'BEL'},
{'Type'=>'Payment' , 'A/C No'=>43434 , 'Status'=>'N', 'ZCurrency'
=>'EUR'},
{'Type'=>'Payment' , 'A/C No'=>44444 , 'Status'=>'N', 'ZCurrency'
=>'EUR'},
{'Type'=>'Payment' , 'A/C No'=>56546 , 'Status'=>'N', 'ZCurrency'
=>'EUR'},
So records to be effected are
{'Type'=>'Prefund' , 'A/C No'=>45678 , 'Status'=>'Y', 'ZCurrency'
=>'SEK'},
{'Type'=>'Prefund' , 'A/C No'=>33333 , 'Status'=>'Y', 'ZCurrency'
=>'SEK'},
{'Type'=>'Receipt' , 'A/C No'=>78878 , 'Status'=>'N', 'ZCurrency'
=>'AIR'},
{'Type'=>'Receipt' , 'A/C No'=>32435 , 'Status'=>'N', 'ZCurrency'
=>'AIR'},
{'Type'=>'Payment' , 'A/C No'=>56546 , 'Status'=>'N', 'ZCurrency'
=>'EUR'},
{'Type'=>'Payment' , 'A/C No'=>44444 , 'Status'=>'N', 'ZCurrency'
=>'EUR'},
{'Type'=>'Payment' , 'A/C No'=>43434 , 'Status'=>'N', 'ZCurrency'
=>'EUR'},
Thanks,
Raj
------------------------------
Date: 1 Nov 2006 05:39:27 -0800
From: "samasama" <bryan@worldspice.net>
Subject: Putting a line in a specific place in a file
Message-Id: <1162388367.426926.232010@k70g2000cwa.googlegroups.com>
Hi... I need to place a line in a specific part of the file. I don't
really know where to begin. Aside from feeding the file contents into
an array?
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
exclude=httpd
I need to find the [base] entry and then put the exclude= below the
gpgkey= line.
Any help is vastly appreciated. Any docs or turtorials about writing a
parser would help too.
Thanks
--
samasama
------------------------------
Date: 1 Nov 2006 14:07:30 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Putting a line in a specific place in a file
Message-Id: <4qro12Fok85tU1@news.dfncis.de>
samasama <bryan@worldspice.net> wrote in comp.lang.perl.misc:
> Hi... I need to place a line in a specific part of the file. I don't
> really know where to begin. Aside from feeding the file contents into
> an array?
That's a faq. Find it through "perldoc -q 'line in a file'". The
(terse) answer is to tie an array to the file so it *looks* like the
contents were fed into the array. The use pattern matching (and
possibly List::Util::first) to locate your place and add a line
after it.
Anno
> [base]
> name=CentOS-$releasever - Base
> mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
> #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
> gpgcheck=1
> gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
> exclude=httpd
>
> I need to find the [base] entry and then put the exclude= below the
> gpgkey= line.
>
> Any help is vastly appreciated. Any docs or turtorials about writing a
> parser would help too.
>
> Thanks
>
> --
> samasama
>
------------------------------
Date: Wed, 01 Nov 2006 09:23:28 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Regular Expression Question Why Doesn't this Match?
Message-Id: <4548596f$0$27610$9b4e6d93@newsspool2.arcor-online.net>
jm wrote:
> /([\w\s\.\'\-]*)
>
> does not match this:
>
> My Fictional Co.
>
> But it does match
>
> Product by abc company
>
> I don't understand why it matches the second one, but not the first.
> Doesn't my expresionsay match anything that has a word, space, dot,
> apostrophe, or a hyphen, one or more times? Thefirst one has a . in it
> and it should work. It does work on others like:
The RE above isn't closed, and I doubt that it is your
complete expression. Give a short, working examples that
illustrates what exactly you are trying to accomplish,
and what goes wrong. Then people will be able to aid in
solving your problem.
Otherwise, to me the pattern seems to match just fine:
C:\> perl
use strict; use warnings;
$_='My Fictional Co.';
print 'Matches: '.$1.$/ if( /([\w\s\.\'\-]*)/ );
^Z
Matches: My Fictional Co.
C:\>
-Chris
------------------------------
Date: Wed, 01 Nov 2006 09:29:23 +0100
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Regular Expression Question Why Doesn't this Match?
Message-Id: <ei9m58$h9h$1@mlucom4.urz.uni-halle.de>
Thus spoke jm (on 2006-11-01 04:51):
> /([\w\s\.\'\-]*)
>
> does not match this:
>
> My Fictional Co.
>
> But it does match
>
> Product by abc company
Your Regex matches almost everything,
including the empty string. The
term [x]* means: match zero times
or more, which is always given.
The result of the match will be
at lest an empty string.
test it like here:
use warnings;
use strict;
my $t1 = 'My Fictional Co.';
my $t2 = 'Product by abc company';
my $t3 = '³µ€ Product ü€µ ²~° ';
my $t4 = '';
my $rg = '([\w\s\.\'\-]*)';
print length +($_=~/$rg/)[0], "\n" for $t1, $t2, $t3, $t4
prints (lengths of matches):
16
22
0
0
which means, in case of $t3 and $t4, there *is* a match,
which is the empty string (length 0).
Is this really what you are trying to do?
Regards
Mirco
------------------------------
Date: Wed, 1 Nov 2006 09:27:11 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Regular Expression Question Why Doesn't this Match?
Message-Id: <ei9pm0.1cc.1@news.isolution.nl>
jm schreef:
> /([\w\s\.\'\-]*)
thaT iS brokeN.
> does not match this:
>
> My Fictional Co.
witH thE missinG enD-slasH addeD, it doeS:
echo 'My Fictional Co.' |
perl -nwle '/([\w\s.\x27-]*)/ and print qq{<$1>}'
This prints:
<My Fictional Co.>
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 1 Nov 2006 06:57:13 -0800
From: dcruncher4@aim.com
Subject: scoping file handles
Message-Id: <1162393033.612418.315670@m73g2000cwd.googlegroups.com>
Aren't file handles global in scope?
So is there a way I can restrict the scope of a file handle to a
subroutine using my,
or any other suggested way. I am concerned about accidentally using the
same
file handle in different subroutines in a file and clobbering each
other.
TIA.
------------------------------
Date: Wed, 01 Nov 2006 15:24:42 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: scoping file handles
Message-Id: <__22h.35918$P7.31114@edtnps90>
dcruncher4@aim.com wrote:
> Aren't file handles global in scope?
Normal filehandles are package variables which are sort-of global.
> So is there a way I can restrict the scope of a file handle to a
> subroutine using my,
perldoc -q "How can I make a filehandle local to a subroutine"
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: Wed, 01 Nov 2006 09:26:37 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Use of uninitialized variable with print << HTMLEND (and $ENV)
Message-Id: <cmmfk2hv5htt54rbfmfhfecms44nqpsf37@4ax.com>
On 31 Oct 2006 14:28:03 -0800, kevinwhite@bellsouth.net wrote:
>I am trying to fix some code I inherited, and there are many warnings I
>would like to clean up. The biggest offenders are as follows:
>
>print <<"HTMLEND"; #<= this causes an uninitialized variable warning...
>
><html><head></head><body></body></html>
>HTMLEND
This shouldn't cause 'uninitialized' warnings. Unless you have
variables interpolated in. In which case you may either take care of
checking for defined()ness or *temporarily* go C<no warnings;>.
>The second example is:
>my $htmlfile = "";
>my $hide = "";
No need to initialize them, BTW.
>$htmlfile = param('filename');
>$hide = param('hide') || "no"; #<= what does this do?
Sets $hide to "no" if param('hide') is a Perl false value. More about
|| in
perldoc perlop
>if ($htmlfile eq "default.html") #<= this causes an uninitialized
>variable warning...
Ditto as above!
>The third problem I have is printing environment variables when I have
>"use strict" enabled. What is the legal way to do this?
>
>I have:
>my $n;
>my @keys;
>my @values;
>my $Item;
>
>@keys = keys %ENV;
>@values %ENV;
^^^^^^^^^^^^^
^^^^^^^^^^^^^
(This is not valid Perl, I assume you mean
@values = values %ENV; #)
>$n = 0;
So far so fine as far as strict is concerned, although we recommend
people all the time to declare lexicals as close as possible to the
point where they're actually used
>foreach $Item (@keys) { $$Item = $values[$n++];}
>foreach $Item (@keys) { print "$Item=$$Item"; }
Here you have a symref, which is not making strict.pm happy. Just use
somehash instead.
But... what is it that you're trying to do? All in all it seems you're
wanting to do X but you're either really doing Y or doing X some very
awkward and convoluted way...
HTH,
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: 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 9915
***************************************