[30477] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1720 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 15 14:09:47 2008

Date: Tue, 15 Jul 2008 11:09:14 -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, 15 Jul 2008     Volume: 11 Number: 1720

Today's topics:
    Re: comma quoted lists question <fawaka@gmail.com>
    Re: comma quoted lists question <jurgenex@hotmail.com>
    Re: comma quoted lists question <cartercc@gmail.com>
    Re: comma quoted lists question xhoster@gmail.com
    Re: comma quoted lists question <jurgenex@hotmail.com>
    Re: FAQ 1.12 What's the difference between "perl" and " <et@gmail.com>
    Re: FAQ 1.12 What's the difference between "perl" and " <uri@stemsystems.com>
    Re: FAQ 1.12 What's the difference between "perl" and " <noreply@gunnar.cc>
    Re: Fastest way to remove common substrings from a list <tzz@lifelogs.com>
    Re: Fastest way to remove common substrings from a list <wahab@chemie.uni-halle.de>
    Re: Fastest way to remove common substrings from a list (Greg Bacon)
    Re: Fastest way to remove common substrings from a list <daveb@addr.invalid>
    Re: Fastest way to remove common substrings from a list xhoster@gmail.com
    Re: Fastest way to remove common substrings from a list <wahab@chemie.uni-halle.de>
    Re: Fastest way to remove common substrings from a list <fawaka@gmail.com>
    Re: Fastest way to remove common substrings from a list <daveb@addr.invalid>
    Re: reliability problem with Finance::QuoteHist::Yahoo <brian.d.foy@gmail.com>
    Re: remove previous lines of a log file <sivarajesh.jarugula@gmail.com>
    Re: use/require, and variables <tzz@lifelogs.com>
    Re: use/require, and variables <glex_no-spam@qwest-spam-no.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 15 Jul 2008 17:10:52 +0200
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: comma quoted lists question
Message-Id: <63ca6$487cbdfc$89e0e08f$19628@news1.tudelft.nl>

On Tue, 15 Jul 2008 06:09:10 -0700, cartercc wrote:

> My users like to use Excel and I am not inclined to tell them they
> can't, nor am I inclined to 'educate' them on making sure that Excel
> doesn't change the file format. They honestly need the filtering and
> sorting capabilities that Excel provides, as some of these files are 106
> columns wide and thousands of rows deep. I have error checking in place
> that rejects improperly formed files, which I define as producing
> anything other than an X element array. However, this isn't
> satisfactory, because I have the burden of reformatting the file.
> 
> Comments? Suggestions? Any module that automagically reformats files?
> Will I have to write a reformatting script myself?
> 
> Thanks, CC.

There are many solutions to that. Like the others have said, educating 
your users is a step in the right direction. Another possible solution is 
using Excel files instead of CSV files. CPAN has a number of modules for 
that in the Spreadsheet:: namespace.

Leon Timmermans


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

Date: Tue, 15 Jul 2008 15:23:42 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: comma quoted lists question
Message-Id: <dkep74l0if1chh5vs72odmggmelrva5d87@4ax.com>

cartercc <cartercc@gmail.com> wrote:
>I create and deliver CSV files like this:
>"12345","John","Q","Public","123 Main Street","Anywhere,
>Alaska","800-555-1212"
>I create this in my program as a seven element array. Users modify the
>files, frequently using Excel, and return the files to me.
>Sometimes, Excel will mangle the file to this:

No, it doesn't.

>12345,John,Q,Public,123 Main Street,"Anywhere, Alaska",800-555-1212
>My script will read this as an eight element array (splitting
>"Anywhere, Alaska" on the comma).

Which is correct and valid CSV format. It may be convenient to blame
Microsoft for everything but in this case it is your program that is at
fault.

>Sometimes Excel will produce a tab delimited file like this:
>12345 John Q Public 123 Main Street "Anywhere, Alaska" 800-555-1212

This on the other hand is a problem between chair and keyboard caused by
saving the file as "Text (tab delimited)". Maybe this user has this even
set as his preference for saving work sheets, maybe even without
realizing what he is doing.

>My script will read this as a two element array.

And correctly so.

>My users like to use Excel and I am not inclined to tell them they
>can't, nor am I inclined to 'educate' them on making sure that Excel
>doesn't change the file format. They honestly need the filtering and

Well, the education would be _NOT_ to select "Save As" -> "Text (tab
delimited)" when saving the file. You wouldn't want to accept any of the
other 24 possible file formats that Excel knows about, either, would
you?

>satisfactory, because I have the burden of reformatting the file.

Then just reject files in "Text (tab delimited)"  format. If users
deliberately save in a non-compatible format then it is their problem,
neither yours nor Excel's. Don't make it yours.

>Comments? Suggestions? Any module that automagically reformats files?

As for fields not enclosed in quotes: that is completely valid CSV and I
am very surprised that Text::CSV doesn't handle it. Could you please
provide a short sample script that demonstrates this deficancy?

jue


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

Date: Tue, 15 Jul 2008 08:28:48 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: comma quoted lists question
Message-Id: <d1c8ae20-fa2e-46b2-8030-9918d48056c0@e39g2000hsf.googlegroups.com>

To answer the question about 'educating' users, Excel helpfully offers
to keep the Excel compatible features when saving, which users do. The
solution of course is to save the final version (after all
corrections) in the CSV format, but my users are generally not
technical people, and my rejecting their non-CSV input isn't a
politically correct solution.

On Jul 15, 11:06 am, xhos...@gmail.com wrote:
> How do you avoid splitting that on that comma in the first case,
> where all fields are quoted rather than just that one?  If it works
> in the first case, it should work in the second case.  I'm guessing you
> aren't using one of the standard modules for processing CSV?

As part of error checking, I wrote a simple (simple-minded?) module
that checks for either (1) /\w,\w/ or (2) \/w","\w/ and adapts. And
yes, this sent me to CPAN where I will probably find something that
meets my needs.

> So then split on tabs instead when you see that the line has the right
> number of tabs in it.

Unfortunately, '123 Main Street' produces three array elements, and
'P. O. Box 123' produces four elements. Most of these files are large
and manually checking and altering them isn't doable.

CC


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

Date: 15 Jul 2008 15:39:26 GMT
From: xhoster@gmail.com
Subject: Re: comma quoted lists question
Message-Id: <20080715113928.343$4x@newsreader.com>

cartercc <cartercc@gmail.com> wrote:
>
> > So then split on tabs instead when you see that the line has the right
> > number of tabs in it.
>
> Unfortunately, '123 Main Street' produces three array elements, and
> 'P. O. Box 123' produces four elements.

Are you splitting on tabs, or on whitespace?  If you split on tabs, it
should not break up those fields, unless your users are replacing the
spaces inside those fields with tabs.  If they are doing that, then they
are not your users, they are enemy forces.  Get a different job forthwith
before they graduate from informatics sabotage to lethal weapons.

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: Tue, 15 Jul 2008 15:39:48 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: comma quoted lists question
Message-Id: <s1hp745tc9ijpe3qqt861fcmmqt6p2d069@4ax.com>

cartercc <cartercc@gmail.com> wrote:
>To answer the question about 'educating' users, Excel helpfully offers
>to keep the Excel compatible features when saving, which users do. The
>solution of course is to save the final version (after all
>corrections) in the CSV format, but my users are generally not
>technical people, and my rejecting their non-CSV input isn't a
>politically correct solution.

Well, then good luck with those 26 different file formats that Excel
knows about.

>On Jul 15, 11:06 am, xhos...@gmail.com wrote:
>> How do you avoid splitting that on that comma in the first case,
>> where all fields are quoted rather than just that one?  If it works
>> in the first case, it should work in the second case.  I'm guessing you
>> aren't using one of the standard modules for processing CSV?
>
>As part of error checking, I wrote a simple (simple-minded?) module
>that checks for either (1) /\w,\w/ or (2) \/w","\w/ and adapts. And
>yes, this sent me to CPAN where I will probably find something that
>meets my needs.
>
>> So then split on tabs instead when you see that the line has the right
>> number of tabs in it.
>
>Unfortunately, '123 Main Street' produces three array elements, and
>'P. O. Box 123' produces four elements. 

That's odd to say the least. Excel doesn't replace space with tab in
data unless someone goes to great length to do so manually.

jue


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

Date: Tue, 15 Jul 2008 09:59:54 -0700
From: "Gordon Corbin Etly" <et@gmail.com>
Subject: Re: FAQ 1.12 What's the difference between "perl" and "Perl"?
Message-Id: <6e43ccF596i8U1@mid.individual.net>

Ted Zlatanov wrote:
> On Sat, 12 Jul 2008 22:57:57 -0700 "Gordon Corbin Etly" wrote:

> > So why then is it in any way wrong to write "PERL", instead of
> > writing "Practical extraction and report language"?

> At this point, because you advocate it endlessly, we're all sick of
> hearing about it,

Has it ever occurred to you that some people are sick of hearing "don't 
write 'PERL'"? Has it ever occurred to you that that view may not be 
right, that that possibility exists? All I ever tried to do was engage 
in a civil debate about it, but unfortunately, there those who refuse to 
argue with fact and prefer to spin and even sling mud instead, rather 
provide a true explanation of why it's wrong.


> As the saying goes, "a fanatic is someone who can't change his mind

I have no issue conceding a point when given a solid refutation, but 
this has not been the case. So far, every attempt to refute my claim has 
fallen apart and I suspect there are those who are  unwilling to admit 
they are in fact wrong, so I put forth that it is not I who is unable to 
change their mind when presented with the facts.


> and won't change the subject."

I'm not sure what you mean here. The subject matter of this thread -is- 
about the naming of Perl. In other threads it's no different. I stick to 
the central topic, or that set by a tangent. Why are you writing 
misleading statements like this? Is it perhaps that some of you have 
become so desperate for your belief that you have to be dishonest?


> At least you're consistent over the last few months.  A man of
> conviction and firm opinion, for sure.  Too bad you can't apply it to
> your posting address

I have not changed it _that_ much, but it is anyone's choice to do so. 
And I have also explained that all you need to do is block on the name 
portion as I have never altered that, other than to add my middle name. 
This can even be done without a regex.


--
Gordon C. Etly
Email: perl -e "print q{}.reverse(q{moc.liamg@ylte.nodrog})" 




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

Date: Tue, 15 Jul 2008 17:19:35 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: FAQ 1.12 What's the difference between "perl" and "Perl"?
Message-Id: <x7bq0zvzdk.fsf@mail.sysarch.com>

>>>>> "GCE" == Gordon Corbin Etly <et@gmail.com> writes:

  GCE> Ted Zlatanov wrote:
  >> On Sat, 12 Jul 2008 22:57:57 -0700 "Gordon Corbin Etly" wrote:

  >> > So why then is it in any way wrong to write "PERL", instead of
  >> > writing "Practical extraction and report language"?

  >> At this point, because you advocate it endlessly, we're all sick of
  >> hearing about it,

  GCE> Has it ever occurred to you that some people are sick of hearing "don't 
  GCE> write 'PERL'"? Has it ever occurred to you that that view may not be 
  GCE> right, that that possibility exists? All I ever tried to do was engage 
  GCE> in a civil debate about it, but unfortunately, there those who refuse to 
  GCE> argue with fact and prefer to spin and even sling mud instead, rather 
  GCE> provide a true explanation of why it's wrong.

nah, we are just sick of you. and in the larger perl community which you
don't seem to care about, this does matter. go to a yapc or oscon and
say PERL all the time. look at the faces of those who think you are not
a worthy perl hacker. 

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Tue, 15 Jul 2008 19:56:02 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: FAQ 1.12 What's the difference between "perl" and "Perl"?
Message-Id: <6e46ltF57q93U1@mid.individual.net>

Uri Guttman wrote:
> go to a yapc or oscon and say PERL all the time. look at the faces of 
> those who think you are not a worthy perl hacker.

I guess that few would notice. Or is it a pronouncing matter besides the 
spelling matter? ;-)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Tue, 15 Jul 2008 10:16:40 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <86tzerw52f.fsf@lifelogs.com>

On Tue, 15 Jul 2008 06:02:38 -0700 (PDT) "freesoft12@gmail.com" <freesoft12@gmail.com> wrote: 

fc> Given a list containing various UNIX directory paths:

fc> @list = qw(
fc> /home/bart
fc> /home/bart/foo
fc> /usr/lib/
fc> /home/bart/foo/xyz
fc> /home/bart/foo/xyz/live.cpp )

fc> I want to trim this list to contain:

fc> @list = qw(
fc> /usr/lib/
fc> /home/bart/foo/xyz/live.cpp )

fc> Is there a better way than this possibly n^2 algorithm below.

fc> my @to_be_removed_indices = ();
fc> for (my $index=0; $index < #list; ++$index) {
fc>     my $current_item = $list[$index];
fc>    ++$index;
fc>    for (my $j = $index; $j < $#list; ++$j) {
fc>       if ($current_item =~ m/$list[$j]/) {   # is the current item a
fc> substring of another
fc>          push (@to_be_removed_indices, $index); # schedule its removal
fc>          last; # break
fc>      }
fc> }
fc> # Remove matched items

If @to_be_removed_indices has less than 5 elements, don't worry about
it, your complexity is too low to matter.  Even 10 elements won't make a
big difference.  Complexity measurements matter when you get into
thousands and millions of items ($disclaimers_go_here).

Otherwise, you can do many optimizations.  First one I see is that you
should use index() instead of a match if you want to check for
substrings.  Another is to find the ASCII characters not in
@to_be_removed_indices, let's say they are qw/q w p/, and then exclude
any string that doesn't have those characters.  You can also do a trie
of your search strings, or build an regex alternation of them and hope
the regex engine can optimize it for you.  The general idea is to
pre-process as much as possible, and let Perl use index() instead of
regular expressions when possible.

Ted


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

Date: Tue, 15 Jul 2008 17:17:13 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <g5if1o$1lfk$1@nserver.hrz.tu-freiberg.de>

Dave B wrote:
> Dave B wrote:
> 
>>   push(@newlist,$s) unless /$s/;
> 
> This is probably better and safer:
> 
>    push(@newlist,$s) unless /^\Q$s\E/;

You won't need all that if you start from an already *sorted* list,
a single map will do:

my @result = map { $list[$_]=~/^\Q$list[$_-1]\E./ ? () : $list[$_] } 1..$#list;

Regards

M.




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

Date: Tue, 15 Jul 2008 10:21:11 -0500
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <ENKdnQHd4ez6XeHVnZ2dnUVZ_vGdnZ2d@posted.hiwaay2>

In article <1d887445-3277-4e77-9251-d5e6eeaac143@k30g2000hse.googlegroups.com>,
    freesoft12@gmail.com <freesoft12@gmail.com> wrote:

: for (my $index=0; $index < #list; ++$index) {

That should be either $index <= $#list or $index < @list.

Below is a solution that uses Text::Trie (available from the
CPAN), but it doesn't preserve order:

    #! /usr/bin/perl

    use warnings;
    use strict;

    use Data::Dumper;
    use Text::Trie qw/ Trie /;

    sub longest {
      my($trie) = @_;

      if (ref $trie) {
        if (ref $trie->[0]) {
          foreach my $node (@$trie) {
            return map longest($_), @$trie;
          }
        }
        else {
          my $head = shift @$trie;

          my @result;
          foreach my $n (@$trie) {
            if (ref $n) {
              push @result => longest($n);
            }
            else {
              push @result => $n if length $n;
            }
          }

          map $head . $_, @result;
        }
      }
      else {
        return $trie;
      }
    }

    my @list = qw(
      /home/bart
      /home/bart/foo
      /usr/lib/
      /home/bart/foo/xyz
      /home/bart/foo/xyz/live.cpp
      /home/bart/foo/xyz/quux
      /etc/bar
      /home/baz
      /lib
      zap
    );

    my @trie = Trie @list;

    my @l = longest \@trie;
    print Dumper \@l;

Enjoy,
Greg
-- 
It is hard to imagine a more stupid or more dangerous way of making
decisions than by putting those decisions in the hands of people who
pay no price for being wrong.
    -- Thomas Sowell


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

Date: Tue, 15 Jul 2008 17:23:15 +0200
From: Dave B <daveb@addr.invalid>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <g5ifdv$u7b$1@registered.motzarella.org>

Mirco Wahab wrote:

>>>   push(@newlist,$s) unless /$s/;
>> This is probably better and safer:
>>
>>    push(@newlist,$s) unless /^\Q$s\E/;
> 
> You won't need all that if you start from an already *sorted* list,
> a single map will do:
> 
> my @result = map { $list[$_]=~/^\Q$list[$_-1]\E./ ? () : $list[$_] } 1..$#list;

I agree that using map is more Perl-style, but the above statement alone
doesn't work. You need at least this:

my @result=map{$list[$_]=~/^\Q$list[$_-1]\E./ ?():$list[$_-1] } 1..$#list;
push @result, $list[-1];

-- 
D.


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

Date: 15 Jul 2008 15:30:17 GMT
From: xhoster@gmail.com
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <20080715113019.378$gu@newsreader.com>

"freesoft12@gmail.com" <freesoft12@gmail.com> wrote:
> Hi,
>
> Given a list containing various UNIX directory paths:
>
> @list = qw(
> /home/bart
> /home/bart/foo
> /usr/lib/
> /home/bart/foo/xyz
> /home/bart/foo/xyz/live.cpp )
>
> I want to trim this list to contain:
>
> @list = qw(
> /usr/lib/
> /home/bart/foo/xyz/live.cpp )


That isn't a complete enough specification.  What if there is a
/foo/home/bart? How about a /home/bartzilla?


>
> Is there a better way than this possibly n^2 algorithm below.

Almost anything would be better than the below.  It doesn't compile.
And once #list is turned to $#list, it does compile but leaves
@to_be_removed_indices empty, so it doesn't what you say you want done.
If you are happy with a wrong answer, then there are much better ways than
n^2 to achieve that.

>
> my @to_be_removed_indices = ();
> for (my $index=0; $index < #list; ++$index) {
>     my $current_item = $list[$index];
>    ++$index;

You are incrementing ++$index twice, so only even numbered indexes are
being "processed".

etc.

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: Tue, 15 Jul 2008 17:34:15 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <g5ig1n$1lpj$1@nserver.hrz.tu-freiberg.de>

Dave B wrote:
> Mirco Wahab wrote:
>> my @result = map { $list[$_]=~/^\Q$list[$_-1]\E./ ? () : $list[$_] } 1..$#list;
> 
> I agree that using map is more Perl-style, but the above statement alone
> doesn't work. You need at least this:
> 
> my @result=map{$list[$_]=~/^\Q$list[$_-1]\E./ ?():$list[$_-1] } 1..$#list;
> push @result, $list[-1];
> 

Yes, you are right. I saw the mistake and corrected it (tried to):

my @result =
    (
       (map { $list[$_+1] =~ /^\Q$list[$_]\E./ ? () : $list[$_] } 0..$#list-1),
       $list[-1]
    );

but you have been faster. The last element was missing.

Thanks & Regards

M.


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

Date: Tue, 15 Jul 2008 17:43:24 +0200
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <38b64$487cc59c$89e0e08f$19628@news1.tudelft.nl>

On Tue, 15 Jul 2008 16:47:17 +0200, Dave B wrote:

> freesoft12@gmail.com wrote:
> 
> If your condition is "remove a string if it's a substring of another,
> matching *at the beginning*", then the following code seems to work:
> 

>   push(@newlist,$s) unless /$s/;

You should really quotemeta $s or else weird things can happen if it 
contains regexp meta characters. Better yet I would write that line as:

push(@newlist, $s) if substr($_, 0, length $s) ne $s.

Since that doesn't waste time looking for a substring if it isn't at the 
start.

Leon Timmermans


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

Date: Tue, 15 Jul 2008 17:51:59 +0200
From: Dave B <daveb@addr.invalid>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <g5ih3s$abs$1@registered.motzarella.org>

Leon Timmermans wrote:

>>   push(@newlist,$s) unless /$s/;
> 
> You should really quotemeta $s or else weird things can happen if it 
> contains regexp meta characters. Better yet I would write that line as:
> 
> push(@newlist, $s) if substr($_, 0, length $s) ne $s.
> 
> Since that doesn't waste time looking for a substring if it isn't at the 
> start.

I fixed both issues in a subsequent post.

-- 
D.


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

Date: Tue, 15 Jul 2008 11:41:38 -0500
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: reliability problem with Finance::QuoteHist::Yahoo
Message-Id: <150720081141384787%brian.d.foy@gmail.com>

In article
<139c6723-6a71-423c-9769-bbfc48fb2b89@d45g2000hsc.googlegroups.com>,
Ted Byers <r.ted.byers@gmail.com> wrote:

> This project is at its beginning, proof of concept, stage.   The plan
> was to do an initial test using data from yahoo, and then proceed to
> buying a datafeed from a commercial source.

In that case you might make your own data source with whatever data you
like (and that data doesn't have to represent anythign real). You can
then test it and use it anyway that you like, and insert as many
special cases as you like.

These sorts of modules don't need to be anything fancy. It could be a
big data structure witha single subroutine to return the right thing
for each input. It doesn't need to think about it at all. 

Good luck :)


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

Date: Tue, 15 Jul 2008 10:39:07 -0700 (PDT)
From: rajesh <sivarajesh.jarugula@gmail.com>
Subject: Re: remove previous lines of a log file
Message-Id: <ad58eb96-163e-4014-9e0b-9366e3a1c88e@w7g2000hsa.googlegroups.com>

Hi,
       I am unable to use this script. It gives the output file with
the lines until the keyword is found. after the first occurance of the
keyword, starting from there all lines are getting deleted.
I am adding code for your reference. I want to find out ENUMERR which
is there in the line no.11. my resultant output file should not have
line no: 9,10,11. Remaining all should be intact.

Thanks in Advance
rajesh


 endtask : collect_e_daita
    3                         |
    4 ncvlog: *W,LBLMAT (../_src/_hard/_vc/lcdport_vc/sv/
nec_lcdport_vc_etype_monitor.sv,1      68|24): Label/name mismatch:
collect_e_data - collect_e_daita.
    5 (`include file: ../_src/_hard/_vc/lcdport_vc/sv/
nec_lcdport_vc_etype_monitor.sv line       168, `include file: ../_src/
_hard/_vc/lcdport_vc/sv/nec_lcdport_vc_top.sv line 47,       `include
file: ../_src/_hard/_tb/_lcdbif_top.sv line 26, file: ../_src/_hard/
_tb/nec      _lcdbif_tb_top.sv line 39)
    6      apb_trans_cov.sample();
    7                         |
    8 ncvlog: *W,ECSSDM (./INCA_libs/irun.lnx86.06.20.nc/svpplib/h/
sivajar/lcdbif/_veri/_rando      m/_src/_hard/_uvc/apb_uvc/sv/
apb_uvc_master_monitor.sv,149|24): The 'sample' met      hod is called
upon a covergroup instance whose declaration has a default sampling
condit      ion associated with it.
    9     `ovm_field_int   (rd_wr,        OVM_ALL_ON)
   10                                               |
   11 ncvlog: *W,ENUMERR (../_src/_hard/_uvc/apb_uvc/examples/../
examples/dummy_memconfig_      types.sv,8|46): This assignment is a
violation of SystemVerilog strong typing rules for       enumeration
datatypes.
   12     `ovm_field_int   (rdy_int,        OVM_ALL_ON)


On Jul 12, 9:24=A0pm, j...@toerring.de (Jens Thoms Toerring) wrote:
> rajesh <sivarajesh.jarug...@gmail.com> wrote:
> > =A0 =A0 =A0 I need a parser logic in perl. I need to read a log file li=
ne by
> > line and search for a keyword. Once the keyword is found in any line,
> > I need to remove the previous two lines and current line. My new log
> > file, should not have these three lines.
>
> On most systems files are simply a sequence of bytes and you
> can't cut out something from the middle. It's not like a deck
> of cards, where each card is a line in the file, and where
> you can pull out a few cards from the middle. You have to
> copy everything from the old file to a new one (of course ex-
> cept the bits you want to remove) and then replace the old
> file by the new one. So in your case you have to keep three
> lines in memory, writing the oldest one out if the newest
> one does not contain the keyword you were looking for. Only
> if it's in the newest line forget about the three lines and
> copy all the rest of the contents of the old file to the new
> one. Something like this should do:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> open my $in, =A0'<', 'log' =A0 =A0 or die "Can't open log file.\n";
> open my $out, '>', 'log.new' or die "Can't open replacement file.\n";
>
> my @lines;
> $lines[ 0 ] =3D <$in>;
> $lines[ 1 ] =3D <$in>;
>
> while ( <$in> ) {
> =A0 =A0 if ( /KEYWORD/ ) {
> =A0 =A0 =A0 =A0 while ( <$in> ) {
> =A0 =A0 =A0 =A0 =A0 =A0 print $out $_;
> =A0 =A0 =A0 =A0 }
> =A0 =A0 =A0 =A0 last;
> =A0 =A0 }
> =A0 =A0 print $out shift @lines;
> =A0 =A0 push @lines, $_;
>
> }
>
> close $out;
> close $in;
> rename 'log.new', 'log';
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Regards, =
Jens
> --
> =A0 \ =A0 Jens Thoms Toerring =A0___ =A0 =A0 =A0j...@toerring.de
> =A0 =A0\__________________________ =A0 =A0 =A0http://toerring.de




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

Date: Tue, 15 Jul 2008 10:18:39 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: use/require, and variables
Message-Id: <86prpfw4z4.fsf@lifelogs.com>

On Tue, 15 Jul 2008 10:48:27 +0100 Nick Wedd <nick@maproom.co.uk> wrote: 

NW> I have always found that putting "use strict" makes life easier for me.
NW> But now, I am trying to use what C programmers call "#include".  I
NW> have a "main.pl" file, which needs to include another file where
NW> values are assigned to a variable.  I have tried all combinations of
NW>   use "includedfile.pl"   or   require "includedfile.pl"
NW>   declaring the variable (a hash) in the main file, or the included file
NW>   declaring the variable  before or after the use/require statement
NW>   declaring the variable as "my" or as "local"
NW> but whatever I try, Perl complains about uninitialised or undeclared
NW> variables.

NW> I have found that if I don't declare my hash at all, and use
NW> 'require "includedfile.pl"', it behaves as I want, the values assigned
NW> in the included file are usable in the main file.  Of course, failing
NW> to declare a variable means I can't use 'use strict'.

NW> So, I would like to know what the recommended way is of declaring the
NW> kind of variable that you get when you just use one without declaring
NW> it.  This way, I would be able to have my #include working and still
NW> have "use strict" there to help me.

Consider YAML, XML, AppConfig, etc. data-oriented configuration modules.
They'll make the task easier, you'll be able to edit the configuration
files with external tools if needed, and they'll be less of a risk to
your software.

Ted


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

Date: Tue, 15 Jul 2008 12:42:42 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: use/require, and variables
Message-Id: <487ce192$0$48225$815e3792@news.qwest.net>

Nick Wedd wrote:
> In message <6e3b3gF51g4fU1@mid.individual.net>, Gunnar Hjalmarsson
> <noreply@gunnar.cc> writes
>> Nick Wedd wrote:
>>> I have always found that putting "use strict" makes life easier for me.
>>>  But now, I am trying to use what C programmers call "#include".  I
>>> have  a "main.pl" file, which needs to include another file where
>>> values are  assigned to a variable.
>> It's not crystal clear what you mean - some code would have been nice -
>> but...
> 
> Ok.  main.pl says, among other things,
>   require "freqs.pl";
>   $w += @{$indfreq{"foo"}}[5];

IMHO that'd be a bit cleaner as:

	$indfreq{ 'foo' }[5]

or if you like to have it be more explicit:

	$indfreq{ 'foo' }->[5]

> and freqs.pl has many lines such as
>   $indfreq{"foo"} = [ 0, 0, 0, 0, 19440, 68160, 54960, 8640 ];
>   $indfreq{"bar"} = [ 0, 0, 0, 0, 14400, 67800, 59640, 9360 ];
[...]


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

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


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