[29537] in Perl-Users-Digest
Perl-Users Digest, Issue: 781 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 21 18:09:39 2007
Date: Tue, 21 Aug 2007 15:09:05 -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 Tue, 21 Aug 2007 Volume: 11 Number: 781
Today's topics:
another character substitution question <pauls@nospam.off>
Re: another character substitution question <klaus03@gmail.com>
Re: another character substitution question <wahab@chemie.uni-halle.de>
Re: another character substitution question <noreply@gunnar.cc>
Re: another character substitution question <pauls@nospam.off>
Re: form requires two parameters <brian.pat.kelly@googlemail.com>
Re: format/write question greymaus@spurious.com
Re: how to call sub by value in variable - SOLVED <nobull67@gmail.com>
Re: Join lines nickli2000@gmail.com
Re: LAMP / Web Developer for Irvine , CA - 3- 6 months <dha@panix.com>
Re: Mail::Sender problem <jismagic@gmail.com>
Re: On redhat, different users = different @INC <russell.brooks@perdue.com>
Re: Perldoc and the pipe "|" character <rvtol+news@isolution.nl>
Re: Stumped: returning a read pipe from a function xhoster@gmail.com
Re: Symbolic representation of logical operators <bik.mido@tiscalinet.it>
Re: writing array to file? <davechunny@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 21 Aug 2007 13:07:48 -0700
From: pauls <pauls@nospam.off>
Subject: another character substitution question
Message-Id: <PPCdnVJZ15gb21bbnZ2dnUVZ_gadnZ2d@seanet.com>
I have a file where one line looks like this:
+nkf =0.5 dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))} rb = 500
I want to remove the text:
dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))}
There are many lines in my file with the dev/gauss thing and in each
case the numbers withing the brackets are different>
I thought I'd try this (see below) but it doesn't seem to work:
s 'dev/gauss\*+}'';
my idea was to substitute anything that starts with dev/gauss , has one
or more alphanumeric characters and ends with a closing bracket }
Any tips for how to do this?
Thanks!
Paul
------------------------------
Date: Tue, 21 Aug 2007 13:23:19 -0700
From: Klaus <klaus03@gmail.com>
Subject: Re: another character substitution question
Message-Id: <1187727799.667087.123000@r34g2000hsd.googlegroups.com>
On Aug 21, 10:07 pm, pauls <pa...@nospam.off> wrote:
> I have a file where one line looks like this:
>
> +nkf =0.5 dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))} rb = 500
>
> I want to remove the text:
>
> dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))}
>
> There are many lines in my file with the dev/gauss thing and in each
> case the numbers withing the brackets are different>
>
> I thought I'd try this (see below) but it doesn't seem to work:
>
> s 'dev/gauss\*+}'';
>
> my idea was to substitute anything that starts with dev/gauss , has one
> or more alphanumeric characters and ends with a closing bracket }
If you don't have nested { ... }, then the following should work:
s!dev/gauss={[^}]*?}!!g;
On the other hand, if you do have nested { ... }, then you will have
to read first perlfaq 4: "How do I find matching/nesting anything?"
--
Klaus
------------------------------
Date: Tue, 21 Aug 2007 22:20:47 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: another character substitution question
Message-Id: <fafhr9$1qvu$1@nserver.hrz.tu-freiberg.de>
pauls wrote:
> I have a file where one line looks like this:
> +nkf =0.5 dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))} rb = 500
> I want to remove the text:
> dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))}
> I thought I'd try this (see below) but it doesn't seem to work:
> s 'dev/gauss\*+}'';
The \* is not correct. You meant probably .* ('.' means any character).
In Linux/Unix, you could do a:
perl -pe 's/dev\/gauss[^}]+}//' gauss.txt > nogauss.txt
Regards
M.
------------------------------
Date: Tue, 21 Aug 2007 22:35:30 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: another character substitution question
Message-Id: <5j10ktF3s17adU1@mid.individual.net>
pauls wrote:
> I have a file where one line looks like this:
>
> +nkf =0.5 dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))} rb = 500
>
> I want to remove the text:
>
> dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))}
>
> There are many lines in my file with the dev/gauss thing and in each
> case the numbers withing the brackets are different>
>
> I thought I'd try this (see below) but it doesn't seem to work:
>
> s 'dev/gauss\*+}'';
s'dev/gauss\S+''
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 21 Aug 2007 13:44:58 -0700
From: pauls <pauls@nospam.off>
Subject: Re: another character substitution question
Message-Id: <O8ednVVsM-Km0lbbnZ2dnUVZ_oHinZ2d@seanet.com>
Klaus wrote:
> On Aug 21, 10:07 pm, pauls <pa...@nospam.off> wrote:
>> I have a file where one line looks like this:
>>
>> +nkf =0.5 dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))} rb = 500
>>
>> I want to remove the text:
>>
>> dev/gauss={7.5e-19*dkispp*0.01672/sqrt(E(*,m))}
>>
>> There are many lines in my file with the dev/gauss thing and in each
>> case the numbers withing the brackets are different>
>>
>> I thought I'd try this (see below) but it doesn't seem to work:
>>
>> s 'dev/gauss\*+}'';
>>
>> my idea was to substitute anything that starts with dev/gauss , has one
>> or more alphanumeric characters and ends with a closing bracket }
>
> If you don't have nested { ... }, then the following should work:
>
> s!dev/gauss={[^}]*?}!!g;
>
> On the other hand, if you do have nested { ... }, then you will have
> to read first perlfaq 4: "How do I find matching/nesting anything?"
>
> --
> Klaus
>
brilliant, that did the trick!
thanks so much for your help, you got me out of a coding impasse!
P.
------------------------------
Date: Tue, 21 Aug 2007 13:58:33 -0700
From: kelticeye <brian.pat.kelly@googlemail.com>
Subject: Re: form requires two parameters
Message-Id: <1187729913.805606.38590@19g2000hsx.googlegroups.com>
On 15 Aug, 22:36, "Nospam" <nos...@home.com> wrote:
> I also notice when manually submitted compared to trying it with the perl
> script that several lines of
>
> %5B%5D=on&ops%5B%5D=on&ops%5B%5D=on&ops%5B%5D=on&ops%5B%5D=on&ops%5B%5D=on&o
> ps%5
> B%5D=on
>
> are appended to the url (even though it is not passed through the
> submit_form() javascript function), when submitted manually via the bre is
> no such addition.
Sorry for taking a while to get back to you-
I've looked at the form again and have determined that you cannot
submit the form directly as the form relies on javascript in the form
to past flags - the binary code that follows "hl=" is related to
whether each sucessive checkbox in the form is 'on' or 'off'.
As mentioned ad nauseum, Mechanize cannot cope with javascript, but
because the form uses this to encode it's url GET method, the results
of submitting a form can be replicated by substituting parts of the
url.
Trying this in the browser is unsuccessful as the webpage script
obviously checks the referer header (as many others do), however,
Mechanize allows us to define our headers through it's add_header()
method.
Hence:
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
my $query = "http://news.bbc.co.uk"; # whatever url you want
# a submission where all checkboxes are unticked:
my $url = "http://www.witchproxy.info/index.php?q=
$query&hl=0000000000";
$mech->add_header( Referer => "http://www.witchproxy.info");
$mech->get($url);
print $mech->content(),"\n";
------------------------------
Date: 21 Aug 2007 19:42:19 GMT
From: greymaus@spurious.com
Subject: Re: format/write question
Message-Id: <slrnfcmdfg.4tm.greymaus@maus.org>
On 2007-08-16, Darren Dunham <ddunham@redwood.taos.com> wrote:
> fixed-width fields.
>
>> I'm also wondering why one would want to use them over printf/sprintf,
>> especially when they seem to be so much trouble to use. It reminds me a
>> little of Cobol.
>
> Maybe you don't. But formats do understand line counts per page, so if
> you're used to 66 line pages, they take a bit of work out. You'd have
> to code some extra logic to do that with printf.
>
format is a nice low-end word formatter, best used, AFAIknow, for
formatting data extracted with perl into a nicely formed and easily
read report. Pump it into TeX and use \verbatim{}. Filter out a data
field you want from the mass of data.
--
Greymaus
Just Another Grumpy Old man
------------------------------
Date: Tue, 21 Aug 2007 15:03:21 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: how to call sub by value in variable - SOLVED
Message-Id: <1187733801.317051.162830@o80g2000hse.googlegroups.com>
On Aug 21, 6:22 pm, Brian McCauley <nobul...@gmail.com> wrote:
> my %handler = map { /(.*)_handler$/ ? ( $1 => \&$_ ) : () } keys %::;
> And before anyone else points it out, I do realise this would get
> confused if you had, for example, a variable $main::test3_handler.
my %handler = map { ( /(.*)_handler$/ && defined &$_ ) ? ( $1 => \&
$_ ) : () } keys %::;
------------------------------
Date: Tue, 21 Aug 2007 13:18:55 -0700
From: nickli2000@gmail.com
Subject: Re: Join lines
Message-Id: <1187727535.922366.155320@22g2000hsm.googlegroups.com>
On Aug 21, 1:16 pm, Mirco Wahab <wa...@chemie.uni-halle.de> wrote:
> nickli2...@gmail.com wrote:
> > I have a file with a lot of lines with a singer number like the
> > following:
> > 111
> > 222
> > 333
> > 444
> > 555
> > 6666
> > 77777
> > 888
> > 9999
> > ..........
>
> > How could I join 3 lines at a time and with a "," in between and at
> > the beginning of the next line, as in the following:
> > 111,222,333
> > ,444,555,6666
> > ,77777,888,9999
>
> Is this Unix/Linux? Then do a simple:
>
> perl -0777 -pe 's/\n/(++$n%3)?",":"\n,"/eg' lines.txt > commas.txt
>
> if your file is 'lines.txt'.
>
> In Win32, you have to change the quotes.
>
> Regards
>
> M.- Hide quoted text -
>
> - Show quoted text -
Thanks for all your help.
Nick
------------------------------
Date: Tue, 21 Aug 2007 19:32:42 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: LAMP / Web Developer for Irvine , CA - 3- 6 months Contract
Message-Id: <slrnfcmfer.37v.dha@panix2.panix.com>
On 2007-08-13, Bhavani wrote:
>
> We are looking for LAMP / Web Developer
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :) (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
http://jobs.perl.org may be of more use to you
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Why *isn't* there a Widget::Gonzo module?
------------------------------
Date: Tue, 21 Aug 2007 21:32:48 -0000
From: jis <jismagic@gmail.com>
Subject: Re: Mail::Sender problem
Message-Id: <1187731968.840126.222340@d55g2000hsg.googlegroups.com>
On Aug 21, 12:38 pm, Larry <larry.grant...@gmail.com> wrote:
> On Aug 20, 7:58 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>
>
>
>
>
> > jis wrote:
> > > I wrote a program to send email. It looks as below
>
> > > use strict;
> > > use Mail::Sender;
>
> > <snip>
>
> > > This works fine for me without any issues.
> > > I converted this script to exe using p2x-8.80-Win32.It gave warnings
> > > initially with
> > > 1. Config file missing.
> > > 2. Langinfo.pm missing.
> > > 3. Digest::Perl::MD5 missing
>
> > > I re installed Mail::Sender to make sure that there is a config file.
>
> > Did that really make a difference with respect to the config file
> > Perl2Exe complained about?
>
> > > I manually copied LangInfo.pm to the I18N folder under C:\\perl\\lib.
> > > ALso installed MD5 from cpan.
>
> > > I converted to exe without any warnings.
> > > But when I run exe it throws the error
> > > " -3Error Sending
> > > mail: Connect failed:An established connection was aborted by
> > > software
> > > in your host machine" . I do not have problems when I go back and run
> > > my perl file.
>
> > > I use Windows xp, Active perl 5.8.8 Build 820, Mail::sender 0.8.13
> > > I use p2x-8.80-Win32 to convert .pl to .exe.I did not have any
> > > problems while converting to exe before.Ofcourse I never used
> > > Mail::Sender before.
>
> > I know that Mail::Sender was written with conversion to .exe files in
> > mind, so it ought to be a good choice for the purpose.
>
> > Maybe you should try to get in touch with the Mail::Sender author.
>
> > --
> > Gunnar Hjalmarsson
> > Email:http://www.gunnar.cc/cgi-bin/contact.pl
>
> Why are you messing with CPAN and copying things manually? If you
> have ActiveState Perl you should use Perl Package Manager to install
> your packages.- Hide quoted text -
>
> - Show quoted text -
As far as i know PPM do not allow to install all packages.
Any way author of the module confirmed me none of the warnings have
dependencey on the this module.
regards,
jis
------------------------------
Date: Tue, 21 Aug 2007 14:46:11 -0700
From: Russ <russell.brooks@perdue.com>
Subject: Re: On redhat, different users = different @INC
Message-Id: <1187732771.687867.254250@a39g2000hsc.googlegroups.com>
On Aug 20, 3:00 pm, Russ <russell.bro...@perdue.com> wrote:
> Hi,
>
> We have RedHat 4EL and perl 5.8.5. Per a user's request I installed
> Date:Simple, using perl -MCPAN -e shell
> as the root user.
> Now root can find Date::Simple, but other users cannot. They do not
> want to include a lib statement in their scripts or invoke with a -I.
> The @INC libraries are close, but not identical.
>
> Does anyone know how to correct or resolve this?
> Any suggestions would be appreciated.
>
> Best regards,
> Russ
Thank you all for your responses. What I've found so far is
1. I searched all files in the user's directory, find . -type f -exec
grep -il PERL5LIB {} \;
Nothing. There is a .cpan directory.
2. I tested several users, including root and all resolve to the same
perl - /usr/bin/perl
3. I think CPAN.pm may be the issue. It is being installed in
directories under /root. The bulk of the other modules appear to be
under /usr/lib/perl5/5.8.5. That includes a copy of CPAN.pm.
Having never alter CPAN.pm I'm not certain what I'm looking for.
Please excuse my ignorance.
Do I hard code a value for a parameter (build_dir?) or is there a
command line override saying build it over there?
Thanks,
Russ
------------------------------
Date: Tue, 21 Aug 2007 20:41:16 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Perldoc and the pipe "|" character
Message-Id: <fafilv.1bk.1@news.isolution.nl>
jkstill schreef:
> Try this. Create a file called pod_pipe.pl with nothing in it
> but a pod section:
>
> jkstill-6 > cat pod_pipe.pl
> =head1 Does the pipe display correctly?
> this is a pipe: |
> =cut
>
> Now here is the output from perldoc:
> Does the pipe display correctly?
> this is a pipe: ?
Also try
$ LANG="" perldoc pod_pipe.pl
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 21 Aug 2007 19:22:46 GMT
From: xhoster@gmail.com
Subject: Re: Stumped: returning a read pipe from a function
Message-Id: <20070821152248.648$SD@newsreader.com>
kj <socyl@987jk.com.invalid> wrote:
> In <20070821121717.488$RO@newsreader.com> xhoster@gmail.com writes:
>
> >Just call eof($rdr) right off the bat.
>
> That works great, reducing the function to:
>
> use IPC::Open3 'open3';
> use Symbol 'gensym';
>
> sub foo {
> my $err = gensym;
> my $pid = open3( my ( $wtr, $rdr ), $err,
> '/some/command', @_ );
> close $wtr;
> die join '', <$err> if eof $rdr;
> return $rdr;
> }
I think you previously said that /some/command can legitimately
produce no output under some non-error conditions. If so, that means you
have to do something more than just check eof $rdr before dying, you also
need to check $err or $?. Assuming $? doesn't tell you anything you need
to know and $err tells it all, then something like:
if (eof $rdr) {
return $rdr if eof $err; # no error message, means no error
waitpid $pid,0; # avoid zombies if die isn't really fatal
die <$err>;
};
return $rdr;
>
> Thanks.
>
> I'm still mulling over the zombies issue...
Since you die on errors, rather than logging and going on (well,
you could be invoking this from an eval {} and doing logging from
outside, so maybe the die doesn't really mean die...) I was kind of
hoping this was a single-use program and you could just forget about
zombies.
Maybe you could double-fork so the OS cleans up zombies automatically,
although it isn't obvious to me how to do that cleanly and simply with
Open3. Or you could set $SIG{CHLD} to "IGNORE", but that might screw up
other parts of your code if those parts also use fork, system, etc. and are
expecting $SIG{CHLD} to stay at its default.
> ${ *$rdr{ SCALAR } } = $pid; # Yeeeew!
Hmm. That makes me wonder, when you do an ordinary pipe open
(not IPC::Open? open), the corresponding close automatically waits on the
child. How does it know what pid to wait on? The pid must be stored
somewhere in the resulting file handle, but where? I tried finding it with
Devel::Peek, but couldn't. Considering my lack of experience with
Devel::Peek, I guess that that isn't surprising.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 21 Aug 2007 20:52:56 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Symbolic representation of logical operators
Message-Id: <e2dmc39r20n0gm4733hhu7pu6lpbquphu1@4ax.com>
On Tue, 21 Aug 2007 08:04:28 -0700, Paul Lalli <mritty@gmail.com>
wrote:
>Again, it doesn't return true for me. I don't know what's making you
>think it does. For me, it returns the empty string, which is false:
>
>$ perl -le'print ("apples" xor "pears");'
>
>$
>
>> With "apples" and "pears" both being true, I was expecting a
>> result of false here.
>
>Yes, and that's exactly what it produces. What output are you seeing
>that contradicts that? Please copy and paste your actual code and
>output, rather than typing in a comment what you think you're seeing.
(To the OP) to be sure, try print()ing
"apples" xor "pears" ? 'TRUE' : 'FALSE'
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: Tue, 21 Aug 2007 18:15:04 -0000
From: elroyerni <davechunny@gmail.com>
Subject: Re: writing array to file?
Message-Id: <1187720104.253346.166560@i13g2000prf.googlegroups.com>
On Aug 21, 12:02 pm, Jim Gibson <jgib...@mail.arc.nasa.gov> wrote:
> In article <1187714457.955337.306...@x35g2000prf.googlegroups.com>,
>
>
>
> elroyerni <davechu...@gmail.com> wrote:
> > Hi -
>
> > I have a array that i initialize for using this in my perl script:
> > my @array_data = qx(cat /home/dchun/logs/$date/stat.log|grep "System
> > took"|cut -c 56-62);
>
> > I know this is really simple but I can't seem to figure it out. How do
> > i write this array to a text file in my home directory? I just want to
> > save it for later. If the file already exists, i just want to write
> > over it.
>
> > I tried using a system command.. but that didn't work. Any suggestions
> > on a simple way to do this?
>
> > system `cat /home/ssi9gwy/logs/$date/rco.log|grep "OTS took"|cut -c
> > 56-62 > /u/dchun/rco_stats/$date.rco_stat.log`;
>
> Perl has input and output facilities for reading and writing files,
> regular expressions for searching for patterns in strings, and
> functions for manipulating strings. You should consider using them
> (untested):
>
> #!/usr/local/bin/perl
> #
> use warnings;
> use strict;
> my $date = '???';
> my $infile = "/home/ssi9gwy/logs/$date/rco.log";
> my $outfile = "/u/dchun/rco_stats/$date.rco_stat.log";
> open(my $in, '<', $infile) or die("Can't open $infile: $!");
> open(my $out, '>', $outfile) or die("Can't open $outfile: $!");
> while(<$in>) {
> next unless /OTS took/;
> print $out substr($_,56,7), "\n";}
>
> close($in) or die("Error closing $infile: $!");
> close($out) or die("Error closing $outfile: $!");
> __END__
>
> See
> perldoc -f open
> perldoc -f substr
> perldoc perlre
> perldoc perlop (search for 'I/O Operators')
>
> --
> Jim Gibson
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com
Thanks everyone for your help. As you can see I'm new to perl and am
very thankful for all your help and feedback as I try to master this
language.
------------------------------
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 781
**************************************