Adriano Allora wrote:
        Dispursed amongst the code are my comments.

> Hi to all,
> I need to delete in a list of files, and in each file of newsgroups,
> all the posts which contents quoted lines. ONLY IF these lines are
> effectively repeating the non quoted text.
> I'm actually working on a single file in the directory, but the
> moment in which I have to work on a multi-file directory is
> approaching to me, and I'm not able to make works two files in the
> same time. 
> 
> I create a file (the control-file) in which there are stored all the
> quoted lines.
> I open the control-file then I verify if each quoted line is repeating
> other text.
> If a line is doing it, I delete all the post.
> 
> ---------------under this line the script----------------------------
> 
> #!/usr/bin/perl -w
> 
> use strict;
> my ($temp,$actual,$var);
> my $del = 0;
> 
> my $fileName = "/Users/pes/Desktop/TC4ctrl/test2.txt";
> open (INPUT, $fileName) or die "File not opnd cos $!";
> my $control = <INPUT>;
        You are only reading one line and it will have a \n character as part of the 
line.
        If you want the whole file in, then you should do something like:
        @control = <INPUT>;
        Now you have the whole file, but you also have \n associated with each quote. 
Are you sure you want     \n associated with the quote because you will need to have 
\n as part of quote to match.  I think you might want something like:
        while ( <INPUT> ) {
           chomp;       # remove \n
           push ( @control, $_ );
       }
> close(INPUT);

> $^I = '';
> 
> @ARGV = </Users/pes/Desktop/TC4/*.txt>;
> while(<>){
> # if it's the end of a post...
>            if (/={8}/g)
>                    {
> # ... the script  knows if it must print the entire post...
>                    if ($del == 0)
>                            {
>                            $temp .= "\n========\n";
>                            print $temp;
>                            $temp = "";
>                            }
> # ... or if it must delete it
>                    else
>                            {
>                            $temp = "";
>                            $del = 0;
>                            }
>                    }
> # if there's a quoted line it compare the line without quoting
> # with all the line in the control files
> # in my intentions when there's the first repetition it decide
> # set the erasure-variable $del to 1 ("yes, delete it!") and continue
> # the while cycle...... this block does not work
>            elsif (/^>/g)
>                    {
>                    $actual = $=B4;
>                    while ($control)
                           foreach my $MyControl ( @control ) {
>                            {
>                            $del = ($control =~ /$actual/m);

                                     if ( /$MyControl/ ) {
                                          $del++;
                                          last;
                              }
   Adrian, if you don't get out then it will depend on the last check whether or not 
it will work for delete or not.  From your description, you state if you find one hit, 
then you want to delete.
  Wags ;)


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  • Help with this! Adriano Allora
    • Wagner, David --- Senior Programmer Analyst --- WGO

Reply via email to