[30565] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1808 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 20 21:09:51 2008

Date: Wed, 20 Aug 2008 18:09:16 -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           Wed, 20 Aug 2008     Volume: 11 Number: 1808

Today's topics:
    Re: Calling writev and readv from perl <Alexander.Farber@gmail.com>
    Re: Calling writev and readv from perl xhoster@gmail.com
    Re: Calling writev and readv from perl <fawaka@gmail.com>
    Re: CLPM - a help group? <m@rtij.nl.invlalid>
    Re: CLPM - a help group? <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: CLPM - a help group? <tadmc@seesig.invalid>
        DBI, MySQL and apostrophes <tch@nospam.wpkg.org>
    Re: DBI, MySQL and apostrophes xhoster@gmail.com
    Re: DBI, MySQL and apostrophes <m@rtij.nl.invlalid>
    Re: DBI, MySQL and apostrophes <ben@morrow.me.uk>
    Re: Help: Characters with colors <tadmc@seesig.invalid>
    Re: Help: Debug perl codes <vron@byu.edu.invalid>
    Re: Help: Debug perl codes <spamtrap@dot-app.org>
    Re: Help: Debug perl codes <nospam@somewhere.com>
        OT news server <fidokomik@gmail.com>
    Re: OT news server <spamtrap@dot-app.org>
    Re: OT news server sln@netherlands.com
        printing two consecutive lines icebrakers2008@gmail.com
    Re: printing two consecutive lines <spamtrap@dot-app.org>
    Re: printing two consecutive lines <1usa@llenroc.ude.invalid>
    Re: Programming Languages Decisions <edgrsprj@ix.netcom.com>
    Re: Programming Languages Decisions sln@netherlands.com
        Score files (was Re: CLPM - a help group?) <tadmc@seesig.invalid>
    Re: Score files (was Re: CLPM - a help group?) sln@netherlands.com
    Re: Score files (was Re: CLPM - a help group?) <spamtrap@dot-app.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 20 Aug 2008 13:25:25 -0700 (PDT)
From: "A. Farber" <Alexander.Farber@gmail.com>
Subject: Re: Calling writev and readv from perl
Message-Id: <623670b7-d446-4f2a-baa6-ff89070be4cf@f63g2000hsf.googlegroups.com>

On 19 Aug., 23:22, Leon Timmermans <faw...@gmail.com> wrote:
> easiest solution would be to just write the elements individually.

Thank you, but that would degrade the performance
of my non-forking server too much, because:

currently in the C-program the whole linked list
is often being written out (to an Apache child via
Unix socket) in a single writev() call - after poll()
has reported that a write/writev call wouldn't block.

If I switch to syswriting every element individually,
then I'll also have to call IO::Poll::poll inbetween...

> use Symbol qw/qualify_to_ref/;
> BEGIN { require 'syscall.ph' };
>
> subwritev(*@) {
> =A0 =A0 my $fh =3D qualify_to_ref(shift, caller);
> =A0 =A0 my $vector =3D join '', map { pack 'PI', $_, length } @_;
> =A0 =A0 return syscall SYS_writev, fileno $fh, $vector, scalar @_;
>
> }
>
> sub readv(*@) {
> =A0 =A0 my $fh =3D qualify_to_ref(shift, caller);
> =A0 =A0 my $vector =3D join '', map { pack 'PI', $_, length } @_;
> =A0 =A0 return syscall SYS_readv, fileno $fh, $vector, scalar @_;
>
> }

This and Inline::C look too complicated for me for now.
And I'm not sure how stable those interfaces are
(in various perl versions).

I'll try going with concatenating data to 1 big string
as Ben suggested

Regards
Alex


------------------------------

Date: 20 Aug 2008 21:19:43 GMT
From: xhoster@gmail.com
Subject: Re: Calling writev and readv from perl
Message-Id: <20080820171946.290$lq@newsreader.com>

"A. Farber" <Alexander.Farber@gmail.com> wrote:
> On 19 Aug., 23:22, Leon Timmermans <faw...@gmail.com> wrote:
> > easiest solution would be to just write the elements individually.
>
> Thank you, but that would degrade the performance
> of my non-forking server too much, because:

You are rewriting C into Perl, yet are that concerned about
performance at this level?

>
> currently in the C-program the whole linked list
> is often being written out (to an Apache child via
> Unix socket) in a single writev() call - after poll()
> has reported that a write/writev call wouldn't block.

I don't see how this could work.  Poll doesn't guarantee that an
arbitrarily large amount of data can be written without blocking,
just that at least one byte (or maybe one "block") can be.

Unless your poll and my poll are not the same thing.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


------------------------------

Date: 21 Aug 2008 00:58:19 GMT
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: Calling writev and readv from perl
Message-Id: <48acbdab$0$185$e4fe514c@news.xs4all.nl>

On Wed, 20 Aug 2008 13:25:25 -0700, A. Farber wrote:

> On 19 Aug., 23:22, Leon Timmermans <faw...@gmail.com> wrote:
> 
> Thank you, but that would degrade the performance of my non-forking
> server too much, because:

Would it? How many elements are we talking about? Half a dozen? Hundreds?

> after poll() has reported that a write/writev call wouldn't block.
> If I switch to syswriting every element individually, then I'll also
> have to call IO::Poll::poll inbetween...

If you don't want it to block, you should use real non-blocking IO, not 
this hack.

> I'll try going with concatenating data to 1 big string
as Ben suggested

Probably the best idea.

Regards,

Leon Timmermans


------------------------------

Date: Wed, 20 Aug 2008 22:36:02 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: CLPM - a help group?
Message-Id: <pan.2008.08.20.20.36.02@rtij.nl.invlalid>

On Tue, 19 Aug 2008 00:16:54 -0700, Adam Worrall wrote:

> Martijn Lievaart wrote:
>> On Sat, 16 Aug 2008 10:36:21 -0700, Adam Worrall wrote:
>> 
>>>> A help desk is a place where people can go with the expectation of
>>>> receiving assistance, without commentary that isn't relevant to their
>>>> questions.
>>> There you go again. This does not really apply to a _volunteer_ help
>>> desk where you are _not_ obligated to answer _anything_, which _how_
>>> _this_ _group_ _functions_.
>> 
>> That's not how a volunteer help desk functions, so stop pretending it
>> is.
> 
> Yes it is. I've been on one, so I've been speaking from first hand
> experience, so don't tell me how one functions. You just posted in one.

I have first hand experience as well, and a volunteer helpdesk takes 
commitment from their volunteers, otherwise it would not function. Who is 
available when, rosters and that kind of thing. You volunteer to take an 
obligation.

Quite different from this group.

> 
>> (And you have been explained this several times
> 
> So have you. And reiterating a falsehood over and over doesn't make it
> any more true, so please spare us all the superior
> you-must-listen-to-us-because-we-are-never-wrong routine.

I never say I'm never wrong. In fact, if you look at my posting history, 
you'll see that I often retract statements and am often wrong. I'm not 
afraid to admit that.

So I'll let your statement above just speak for itself.

M4


------------------------------

Date: Wed, 20 Aug 2008 15:56:47 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: CLPM - a help group?
Message-Id: <f2kun5xsp6.ln2@goaway.wombat.san-francisco.ca.us>

On 2008-08-20, Charlton Wilbur <cwilbur@chromatico.net> wrote:
>
> In the case of people who change their From line, how do you handle it?

Unless they start permuting the values of their name, I have found that
killfiling just on the full name, sans email address, is often
sufficient.  There was a recent troll in here who needed a more complex
regex to kill effectively; it may kill more than I want, but I haven't
seen any problems with it so far.

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



------------------------------

Date: Wed, 20 Aug 2008 17:59:32 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: CLPM - a help group?
Message-Id: <slrngap8ek.e8j.tadmc@tadmc30.sbcglobal.net>

Stephan Bour <sbour@niaid.hin.gow> wrote:
> John Bokma wrote:

>::  *ploink*


> Tad J McClellan wrote:
>:: I did that 5 years ago.
>
> Not possible, since I wasn't here 5 years ago,


    http://groups.google.com/group/comp.lang.perl.misc/msg/ee8bb90190c33d74

    http://groups.google.com/groups/profile?enc_user=Z1NROBMAAADiU51oHQLTtd4xiCEEXKM6JLiykVkzDXJvZE77WC-J4Q


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Wed, 20 Aug 2008 23:03:06 +0200
From: Tomasz Chmielewski <tch@nospam.wpkg.org>
Subject: DBI, MySQL and apostrophes
Message-Id: <g8i0qa$t5i$1@online.de>

Let's assume I have this code which inserts some values into a MySQL 
database:


my $var = "Jake's cake";
$SQL = "INSERT INTO `recipes` (`name`, `stat`) VALUES ('$var', 'ok')";
$my_db->do($SQL) or die "Error!\n";


Executing this will render an error:

DBD::mysql::db do failed: You have an error in your SQL syntax; check 
the manual that corresponds to your MySQL server version for the right 
syntax to use near 's cake', 'ok')' at line 1 at my_script.pl line 77.
Error!

Obviously, it breaks because of an apostrophe in $var variable.

What are the ways to get around this issue?

I could prepend each apostrophe with a backslash:

$var =~ s/'/\\'/;

But I'm not sure if it's the right way to do this.

Are there any "better" approaches?


-- 
Tomasz Chmielewski
http://wpkg.org


------------------------------

Date: 20 Aug 2008 21:22:26 GMT
From: xhoster@gmail.com
Subject: Re: DBI, MySQL and apostrophes
Message-Id: <20080820172228.851$XL@newsreader.com>

Tomasz Chmielewski <tch@nospam.wpkg.org> wrote:
> Let's assume I have this code which inserts some values into a MySQL
> database:
>
> my $var = "Jake's cake";
> $SQL = "INSERT INTO `recipes` (`name`, `stat`) VALUES ('$var', 'ok')";
> $my_db->do($SQL) or die "Error!\n";
>
> Executing this will render an error:
>
> DBD::mysql::db do failed: You have an error in your SQL syntax; check
> the manual that corresponds to your MySQL server version for the right
> syntax to use near 's cake', 'ok')' at line 1 at my_script.pl line 77.
> Error!
>
> Obviously, it breaks because of an apostrophe in $var variable.
>
> What are the ways to get around this issue?

In my opinion, the only sane way to deal with this is to use
placeholder/bind variables.

$SQL = "INSERT INTO recipes (name, stat) VALUES (?, 'ok')";
$my_db->do($SQL,undef,$var) or die "Error!\n";

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


------------------------------

Date: Wed, 20 Aug 2008 23:37:38 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: DBI, MySQL and apostrophes
Message-Id: <pan.2008.08.20.21.37.37@rtij.nl.invlalid>

On Wed, 20 Aug 2008 23:03:06 +0200, Tomasz Chmielewski wrote:

> I could prepend each apostrophe with a backslash:
> 
> $var =~ s/'/\\'/;
> 
> But I'm not sure if it's the right way to do this.
> 
> Are there any "better" approaches?

Just drop the apostrophes, they are not needed.

Besides, use DBI variable binding. What if $var contained "');delete from 
users;"? Well actually that will not work with DBI, but interpolating 
variables in SQL queries is a bad idea and has to be done very carefully. 
Variable binding is the easy way to get it right.

The following should work (untested and error handling omitted):

my $var = "Jake's cake";
$SQL = "INSERT INTO recipes (name, stat) VALUES (?, 'ok')";
my $sth = $my_db->prepare($SQL);
$sth->execute($var);

HTH,
M4


------------------------------

Date: Wed, 20 Aug 2008 22:35:38 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: DBI, MySQL and apostrophes
Message-Id: <aafun5-4hb.ln1@osiris.mauzo.dyndns.org>


Quoth Tomasz Chmielewski <tch@nospam.wpkg.org>:
> Let's assume I have this code which inserts some values into a MySQL 
> database:
> 
> 
> my $var = "Jake's cake";
> $SQL = "INSERT INTO `recipes` (`name`, `stat`) VALUES ('$var', 'ok')";
> $my_db->do($SQL) or die "Error!\n";
> 
> 
> Executing this will render an error:
> 
> DBD::mysql::db do failed: You have an error in your SQL syntax; check 
> the manual that corresponds to your MySQL server version for the right 
> syntax to use near 's cake', 'ok')' at line 1 at my_script.pl line 77.
> Error!
> 
> Obviously, it breaks because of an apostrophe in $var variable.
> 
> What are the ways to get around this issue?

See 'Placeholders and Bind Values' in perldoc DBI.

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
ben@morrow.me.uk                                    The Levellers, 'Believers'


------------------------------

Date: Wed, 20 Aug 2008 18:07:56 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Help: Characters with colors
Message-Id: <slrngap8uc.e8j.tadmc@tadmc30.sbcglobal.net>

Amy Lee <openlinuxsource@gmail.com> wrote:

[ snip: asking a FAQ ]

> when I want to search some keywords, could I
> use "perldoc -q <keyword>"?


Have you seen the Posting Guidelines that are posted here frequently?

It covers "perldoc -q", along with about a dozen or so other tips on
how to get answers to Perl questions.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Wed, 20 Aug 2008 13:48:15 -0700
From: "Vernan R." <vron@byu.edu.invalid>
Subject: Re: Help: Debug perl codes
Message-Id: <28OdnccWr-OMHjHVnZ2dnUVZ_hudnZ2d@wavecable.com>

Sherm Pendley wrote:
> Amy Lee <openlinuxsource@gmail.com> writes:
>
> > As I think, experts might more be patient to newbies, right?
>
> In my experience, I've found that the experts here are *far* more
> patient and helpful than the whiners claim.

  There was a time when that may have been quite true, but that
  time has long since passed. What I see happening often is
  that many regulars are so enveloped in the preassumption that
  anyone posting a question doesn't do their home-work before
  hand, that they end up making more and more mistakes, such
  the case in this thread, and to be honest, this is what has
  driven the quality of this group to be as low as it is.


> Sadly, no matter how patient one is, or how many helpful fishing
> lessons one gives, there will inevitably be someone in the
> audience who feels entitled to a free fish dinner instead.

  I don't understand your reasoning. If you are saying the OP
  was seeking free fish, then you are clearly mistaken. If
  you are saying he who corected those presuming the question
  to be a FAQ, then you are also wrong.


> I suggest you keep reading a while - you'll quickly get a good feel
> for who is helpful here, and who's a self-entitled crank. A good
> indication of the latter is a half-shouted rant about how useless the
> regulars are, like the one to which you responded. :-)

  I never got the impression anyone was attempting to say that
  the "regulars", as you put it, are useless, but rather to
  correct the error they made (same error they make more and more
  often) and instead of letting it be, you are defending the error?


-- 
-Vern 




------------------------------

Date: Wed, 20 Aug 2008 19:56:29 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Help: Debug perl codes
Message-Id: <m17iab8clu.fsf@dot-app.org>

"Vernan R." <vron@byu.edu.invalid> writes:

> Sherm Pendley wrote:
>
>> Sadly, no matter how patient one is, or how many helpful fishing
>> lessons one gives, there will inevitably be someone in the
>> audience who feels entitled to a free fish dinner instead.
>
>   I don't understand your reasoning. If you are saying the OP
>   was seeking free fish, then you are clearly mistaken. If
>   you are saying he who corected those presuming the question
>   to be a FAQ, then you are also wrong.

Please don't put words in my mouth - if I had meant to say either of
those things, I would have. The OP's question was perfectly valid, not
in the FAQ, and those who directed her to the FAQ were mistaken.

There are a handful of people here who *did* demand answers that would
have been *trivially* answered with the most cursory search in the
docs. I'm not referring to the OP, but to those "defending" her
question by carrying on about how "mean" the regulars are. They've
behaved badly in the past, been slapped down for it, and now they're
carrying a grudge. As I said, it's easy to see who they are, by simply
watching the group for a while, and observing who tries to be helpful
and who does nothing but complain.

I don't think it's a problem that's endemic to this group, btw, just
human nature. In my experience, whenever you get a large enough group
of people together, there will inevitably be a few freeloaders and
whiners among them.

>> I suggest you keep reading a while - you'll quickly get a good feel
>> for who is helpful here, and who's a self-entitled crank. A good
>> indication of the latter is a half-shouted rant about how useless the
>> regulars are, like the one to which you responded. :-)
>
>   I never got the impression anyone was attempting to say that
>   the "regulars", as you put it, are useless

Did you *read* the rant she responded to? :-)

>   instead of letting it be, you are defending the error?

Of course not. What I take objection to is the popular notion among
whiners (including the one to whom the OP had responded) that such
things are intentional attacks. The picture that these people paint,
of being irrationally "attacked" by regulars who "hate newbies," is
nothing but a ridiculous caricature.

sherm--

-- 
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: Wed, 20 Aug 2008 20:58:34 -0400
From: "Thrill5" <nospam@somewhere.com>
Subject: Re: Help: Debug perl codes
Message-Id: <xaSdnZ1Et_chIDHVnZ2dnUVZ_gadnZ2d@comcast.com>


"Sherm Pendley" <spamtrap@dot-app.org> wrote in message 
news:m17iab8clu.fsf@dot-app.org...
> "Vernan R." <vron@byu.edu.invalid> writes:
>
>> Sherm Pendley wrote:
>>
>>> Sadly, no matter how patient one is, or how many helpful fishing
>>> lessons one gives, there will inevitably be someone in the
>>> audience who feels entitled to a free fish dinner instead.
>>
>>   I don't understand your reasoning. If you are saying the OP
>>   was seeking free fish, then you are clearly mistaken. If
>>   you are saying he who corected those presuming the question
>>   to be a FAQ, then you are also wrong.
>
> Please don't put words in my mouth - if I had meant to say either of
> those things, I would have. The OP's question was perfectly valid, not
> in the FAQ, and those who directed her to the FAQ were mistaken.
>
> There are a handful of people here who *did* demand answers that would
> have been *trivially* answered with the most cursory search in the
> docs. I'm not referring to the OP, but to those "defending" her
> question by carrying on about how "mean" the regulars are. They've
> behaved badly in the past, been slapped down for it, and now they're
> carrying a grudge. As I said, it's easy to see who they are, by simply
> watching the group for a while, and observing who tries to be helpful
> and who does nothing but complain.
>
> I don't think it's a problem that's endemic to this group, btw, just
> human nature. In my experience, whenever you get a large enough group
> of people together, there will inevitably be a few freeloaders and
> whiners among them.
>
>>> I suggest you keep reading a while - you'll quickly get a good feel
>>> for who is helpful here, and who's a self-entitled crank. A good
>>> indication of the latter is a half-shouted rant about how useless the
>>> regulars are, like the one to which you responded. :-)
>>
>>   I never got the impression anyone was attempting to say that
>>   the "regulars", as you put it, are useless
>
> Did you *read* the rant she responded to? :-)
>
>>   instead of letting it be, you are defending the error?
>
> Of course not. What I take objection to is the popular notion among
> whiners (including the one to whom the OP had responded) that such
> things are intentional attacks. The picture that these people paint,
> of being irrationally "attacked" by regulars who "hate newbies," is
> nothing but a ridiculous caricature.
>
> sherm--
>
> -- 
> My blog: http://shermspace.blogspot.com
> Cocoa programming in Perl: http://camelbones.sourceforge.net

My "rant" was directed only to the bullies that like to ridicule posters 
because *they think* someone asked a dumb question.  (There are no dumb 
questions, only dumb answers)  Yes there are those that want "free fish", 
but those are easy to spot and most ignore them anyway.  The OP's question 
was a valid one and the reply *quote*

>Please do not continue to use this newsgroup as a service
>that reads the docs to you.
>
>Make at least some small effort to answer your questions yourself
>before resorting to asking here.
>
>Have you seen the Posting Guidelines that are posted here frequently?

*end quote* offers no help to anyone.  Isn't one of the great things about a 
newsgroup is that your CAN use this newsgroup as a service to read the docs 
for you?   Is everyone suppose to have a photographic memory and remember 
every detail about Perl?  How does he know if the OP spent 2 hours 
researching or spent none?  Why does it that matter anyway? 




------------------------------

Date: Wed, 20 Aug 2008 16:35:57 -0700 (PDT)
From: fidokomik <fidokomik@gmail.com>
Subject: OT news server
Message-Id: <f557d045-10c3-4950-854c-8405a095995d@p25g2000hsf.googlegroups.com>

Please can anybody recommend me some news server? Now I read this
group using news client from news.felk.cvut.cz but is look that my
outgoing messages are lost at Czech Republic border :-)


------------------------------

Date: Wed, 20 Aug 2008 20:07:57 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: OT news server
Message-Id: <m1zln76xia.fsf@dot-app.org>

fidokomik <fidokomik@gmail.com> writes:

> Please can anybody recommend me some news server?

Free or paid? For free, I've had good results from aioe.org. They have
a fairly short retention period and don't carry binaries, but what
else can one expect for free? :-)

For money, I've yet to see a service that beats giganews.

sherm--

-- 
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: Thu, 21 Aug 2008 00:32:48 GMT
From: sln@netherlands.com
Subject: Re: OT news server
Message-Id: <9jdpa4h4iei9remqr5drotvlft9057i0mp@4ax.com>

On Wed, 20 Aug 2008 20:07:57 -0400, Sherm Pendley <spamtrap@dot-app.org> wrote:

>fidokomik <fidokomik@gmail.com> writes:
>
>> Please can anybody recommend me some news server?
>
>Free or paid? For free, I've had good results from aioe.org. They have
>a fairly short retention period and don't carry binaries, but what
>else can one expect for free? :-)
>
>For money, I've yet to see a service that beats giganews.

Hey, I just got a $10 service @ 20 gigs and 160 days.
I used to have 5 gigs for and a year for free with adelphia.
Now, I don't dnload binaries at the traditional sites, no need.
Since I use Agent, which is a deep recoreder, should I go for the ten
cents per month service and 5 day retention?

sln

>
>sherm--



------------------------------

Date: Wed, 20 Aug 2008 17:08:04 -0700 (PDT)
From: icebrakers2008@gmail.com
Subject: printing two consecutive lines
Message-Id: <e4bc22af-6e40-4109-a99f-1b9e09f8b887@z6g2000pre.googlegroups.com>

Hi,

I am new to perl, I have a sample file like this
***********************************************************************************
Path 11: VIOLATED Hold Check with Pin core1_2/tx_lr/ifft128/
u7_mem_fft_0/u5_
data_ram_5/\mem_reg[8][13] /CP
Endpoint:   core1_2/tx_lr/ifft128/u7_mem_fft_0/u5_data_ram_5/\mem_r
eg[8][13] /D  (v) checked with  leading edge of 'x_clk'
Beginpoint: core1_2/tx_lr/ifft128/u4_fft_core_top_0/
u0_fft_mux_0/\dout_5_
reg[13] /Q (v) triggered by  leading edge of 'x_clk'
Path Groups:  {reg2reg}
Other End Arrival Time          0.805
+ Hold                         -0.017
+ Phase Shift                   0.000
- CPPR Adjustment               0.055
+ Uncertainty                   0.100
= Required Time                 0.834
 Arrival Time                  0.795
 Slack Time                   -0.039
 Clock Rise Edge                      0.000
 = Beginpoint Arrival Time            0.000
     Timing Path:
****************************************************************************************

I need to print whole line which starts with 'Endpoint'  - But this
line is spread in two lines as shown above, I want to print this in
the same line. The whole file contains thousands of similar lines.  I
could able to print the line by searching "Endpoint" - but it only
gives half the line and other half is in next line, which I am not
able to print.

Here is what I have:

#!/usr/bin/perl
use warnings;
use strict;
my $fh;
open($fh, "<test2.rpt")  - # test2.rpt is the file containing lines I
mentioned above.
    or die "Can't open: $!";
while (my $line = <$fh>) # was $line
{
if ($line=~m/Endpoint:/) {
        print "\n";
            #print "$1";
            print "$line";
     }

}

Appreciate your help.

- SR









------------------------------

Date: Wed, 20 Aug 2008 20:25:02 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: printing two consecutive lines
Message-Id: <m1sksz6wpt.fsf@dot-app.org>

icebrakers2008@gmail.com writes:

> I am new to perl

Welcome aboard.

> , I have a sample file like this
> ***********************************************************************************
> Path 11: VIOLATED Hold Check with Pin core1_2/tx_lr/ifft128/
> u7_mem_fft_0/u5_
> data_ram_5/\mem_reg[8][13] /CP
> Endpoint:   core1_2/tx_lr/ifft128/u7_mem_fft_0/u5_data_ram_5/\mem_r
> eg[8][13] /D  (v) checked with  leading edge of 'x_clk'
> Beginpoint: core1_2/tx_lr/ifft128/u4_fft_core_top_0/
> u0_fft_mux_0/\dout_5_
> reg[13] /Q (v) triggered by  leading edge of 'x_clk'
> Path Groups:  {reg2reg}
> Other End Arrival Time          0.805
> + Hold                         -0.017
> + Phase Shift                   0.000
> - CPPR Adjustment               0.055
> + Uncertainty                   0.100
> = Required Time                 0.834
>  Arrival Time                  0.795
>  Slack Time                   -0.039
>  Clock Rise Edge                      0.000
>  = Beginpoint Arrival Time            0.000
>      Timing Path:
> ****************************************************************************************
>
> I need to print whole line which starts with 'Endpoint'  - But this
> line is spread in two lines as shown above, I want to print this in
> the same line. The whole file contains thousands of similar lines.  I
> could able to print the line by searching "Endpoint" - but it only
> gives half the line and other half is in next line, which I am not
> able to print.
>
> Here is what I have:
>
> #!/usr/bin/perl
> use warnings;
> use strict;

Warnings and strictures: Excellent!

> my $fh;
> open($fh, "<test2.rpt")  - # test2.rpt is the file containing lines I
> mentioned above.
>     or die "Can't open: $!";

Not just checking the open, but also printing $! to describe the
error. Also excellent!

> while (my $line = <$fh>) # was $line
> {
> if ($line=~m/Endpoint:/) {
>         print "\n";
>             #print "$1";
>             print "$line";

That should be:
              print $line;

But don't worry - always quoting is a common mistake. The reasons why
it's generally a bad idea are in the FAQ:

    perldoc -q quoting

>      }
>
> }

Is the "Endpoint" *always* two lines - never more nor less? If so, you
could simply read the second line separately:

    if ($line =~ /Endpoint:/) {
        my $line2 = <$fh>;
        print $line, $line2;
    }

sherm--

-- 
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: Thu, 21 Aug 2008 01:02:25 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: printing two consecutive lines
Message-Id: <Xns9B00D607EDBEBasu1cornelledu@127.0.0.1>

icebrakers2008@gmail.com wrote in
news:e4bc22af-6e40-4109-a99f-1b9e09f8b887@z6g2000pre.googlegroups.com: 

> I am new to perl, I have a sample file like this

Sample input snipped here for brevity ... Included with solution below.

> Here is what I have:
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> my $fh;
> open($fh, "<test2.rpt")  - # test2.rpt is the file containing lines I
> mentioned above.
>     or die "Can't open: $!";

Thanks for using warnings and strict as well as checking the return 
value of open.

You could write the open call more succinctly as:

my $filename = 'test2.rpt';
open my $fh, '<', $filename
   or die "Cannot open '$filename': $!";

> while (my $line = <$fh>) # was $line
> {
> if ($line=~m/Endpoint:/) {
>         print "\n";
>             #print "$1";
>             print "$line";
>      }
> }

#!/usr/bin/perl

use strict;
use warnings;

while ( my $line = <DATA> ) {
    next unless $line =~ /^Endpoint:/;
    print $line;
    while ( my $next = <DATA> ) {
        last if $next =~ /^Beginpoint:/;
        print $next;
    }
}

__DATA__
************************************************************************
***********
Path 11: VIOLATED Hold Check with Pin core1_2/tx_lr/ifft128/
u7_mem_fft_0/u5_
data_ram_5/\mem_reg[8][13] /CP
Endpoint:   core1_2/tx_lr/ifft128/u7_mem_fft_0/u5_data_ram_5/\mem_r
eg[8][13] /D  (v) checked with  leading edge of 'x_clk'
Beginpoint: core1_2/tx_lr/ifft128/u4_fft_core_top_0/
u0_fft_mux_0/\dout_5_
reg[13] /Q (v) triggered by  leading edge of 'x_clk'
Path Groups:  {reg2reg}
Other End Arrival Time          0.805
+ Hold                         -0.017
+ Phase Shift                   0.000
- CPPR Adjustment               0.055
+ Uncertainty                   0.100
= Required Time                 0.834
 Arrival Time                  0.795
 Slack Time                   -0.039
 Clock Rise Edge                      0.000
 = Beginpoint Arrival Time            0.000
     Timing Path:
************************************************************************
****************

__END__

C:\Temp> t
Endpoint:   core1_2/tx_lr/ifft128/u7_mem_fft_0/u5_data_ram_5/\mem_r
eg[8][13] /D  (v) checked with  leading edge of 'x_clk'

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


------------------------------

Date: Wed, 20 Aug 2008 15:52:37 -0500
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Re: Programming Languages Decisions
Message-Id: <lsudnQfINvGOGTHVnZ2dnUVZ_hqdnZ2d@earthlink.com>

<sln@netherlands.com> wrote in message 
news:fuhma4h2lqq92hqkgoduu3ak7514hcc13c@4ax.com...

> If your looking to solve unified field theory, it may not be what you 
> wan't.
> Its got its own programming environment that most engineers are 
> comfortable
> with, what else would you you need then? There's really no way around 
> learning
> macro's for these packages, so jump right in.

As I stated in the original post in this thread, I thought that it might be 
a good idea to have this discussion in the Newsgroups before the program I 
have developed was released for circulation.  And it does look like it was 
in fact a good idea.

The first version is up and running.  The program and support files were 
sent in a zip file to a research colleague who was able to get it running 
immediately on his computer.  The information exchange mechanism between 
Perl and Gnuplot being used is a little complex.  But it appears to work.

If the program is as popular as I believe it will be then it will likely be 
fairly important to get some type of "pipe" running between Perl and Gnuplot 
instead of having them exchange information through files.  If there are 
hundreds or thousands of people or more using some program it would probably 
be a good idea for it to have as stable a structure as possible.




------------------------------

Date: Wed, 20 Aug 2008 21:47:46 GMT
From: sln@netherlands.com
Subject: Re: Programming Languages Decisions
Message-Id: <8n2pa4dumsm2oogahgqgc95jc66u3i64gq@4ax.com>

On Wed, 20 Aug 2008 15:52:37 -0500, "E.D.G." <edgrsprj@ix.netcom.com> wrote:

><sln@netherlands.com> wrote in message 
>news:fuhma4h2lqq92hqkgoduu3ak7514hcc13c@4ax.com...
>
>> If your looking to solve unified field theory, it may not be what you 
>> wan't.
>> Its got its own programming environment that most engineers are 
>> comfortable
>> with, what else would you you need then? There's really no way around 
>> learning
>> macro's for these packages, so jump right in.
>
>As I stated in the original post in this thread, I thought that it might be 
>a good idea to have this discussion in the Newsgroups before the program I 
>have developed was released for circulation.  And it does look like it was 
>in fact a good idea.
>
>The first version is up and running.  The program and support files were 
>sent in a zip file to a research colleague who was able to get it running 
>immediately on his computer.  The information exchange mechanism between 
>Perl and Gnuplot being used is a little complex.  But it appears to work.
>
>If the program is as popular as I believe it will be then it will likely be 
>fairly important to get some type of "pipe" running between Perl and Gnuplot 
>instead of having them exchange information through files.  If there are 
>hundreds or thousands of people or more using some program it would probably 
>be a good idea for it to have as stable a structure as possible.
>
I'm sure your program will be embraced by your community.

Stable however, implies longevity. There is a littany of problems
surrounding the wrapping of code around free software, and the interfaces
they provide.

Those thousands are your intellectual customers. When upgrades happen, all
the way from the platform, up several steps, customers get irritated when
things don't go right. Interrest quickly wane's.

Your important discovery could be distributed via intellectual dissemination.
Have you thought of that? Let that proof be resolved and continued with
current technologies. Software is an after thought.

By the way, software is disposable, immediately replacable. Developers actions
include no more than 6 month's of expectancy of any technology.
Corporations know this, %70 of upgrades are because of platform/API upgrades,
what thier code base rides on. And the harness to make that happen is tremendous.
They never stop as well. To stop, is to lose.

Don't get into the mode of chasing your tail, because it will consume you.


sln




------------------------------

Date: Wed, 20 Aug 2008 17:54:55 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Score files (was Re: CLPM - a help group?)
Message-Id: <slrngap85v.e8j.tadmc@tadmc30.sbcglobal.net>

Charlton Wilbur <cwilbur@chromatico.net> wrote:
>>>>>> "TJMcC" == Tad J McClellan <tadmc@seesig.invalid> writes:
>
>    TJMcC> John Bokma <john@castleamber.com> wrote:
>
>     >> *ploink*
>
>    TJMcC> I did that 5 years ago.
>
> In the case of people who change their From line, how do you handle it?


Once they've revealed their willingness to change identities,
I usually make multiple entries in slrn's scorefile in addition
to the literal one that was already in there:

   % does not read docs for function being used
   %    eg: capture output from system()
   % or uses groups as a "read the docs to me" service
   Score:: -9998
           From: sbour@niaid.nih.gov
           From: sbour@
           From: Stephan Bour


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Thu, 21 Aug 2008 00:15:34 GMT
From: sln@netherlands.com
Subject: Re: Score files (was Re: CLPM - a help group?)
Message-Id: <bfcpa4pe83buhrhkuhd406h5b533k41oku@4ax.com>

On Wed, 20 Aug 2008 17:54:55 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:

>Charlton Wilbur <cwilbur@chromatico.net> wrote:
>>>>>>> "TJMcC" == Tad J McClellan <tadmc@seesig.invalid> writes:
>>
>>    TJMcC> John Bokma <john@castleamber.com> wrote:
>>
>>     >> *ploink*
>>
>>    TJMcC> I did that 5 years ago.
>>
>> In the case of people who change their From line, how do you handle it?
>
>
>Once they've revealed their willingness to change identities,
>I usually make multiple entries in slrn's scorefile in addition
>to the literal one that was already in there:
>
>   % does not read docs for function being used
>   %    eg: capture output from system()
>   % or uses groups as a "read the docs to me" service
>   Score:: -9998
>           From: sbour@niaid.nih.gov
>           From: sbour@
>           From: Stephan Bour

Please don't referece this as a continuation of "CLPM - a help group"
in which you actually intend to carry on the thread in a similar, not
to removed fashion.

You appear to be starting a new thread on how you make a KILL scorefile
strike right through the heart in a permanent way.

I don't think this bodes well as a subject. Am I right?
On the subject line, why do you lead people into thinking this has to do with
the "Perl help group?" thread when it doesen't???

Please title your personal software "Kill" tactics appropriately!

sln



------------------------------

Date: Wed, 20 Aug 2008 20:31:09 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Score files (was Re: CLPM - a help group?)
Message-Id: <m1od3n6wfm.fsf@dot-app.org>

sln@netherlands.com writes:

> Please title your personal software "Kill" tactics appropriately!

He *did* change the subject when the topic drifted. What part of
"Score files (was Re: CLPM - a help group?)" doesn't make that clear
to you?

sherm--

-- 
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

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 1808
***************************************


home help back first fref pref prev next nref lref last post