[31930] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3193 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 1 11:10:06 2010

Date: Mon, 1 Nov 2010 08:09:42 -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           Mon, 1 Nov 2010     Volume: 11 Number: 3193

Today's topics:
    Re: grep example's use of $_ confusing me. <justin.1010@purestblue.com>
    Re: perl parse (reg exp) <m@rtij.nl.invlalid>
    Re: perl parse (reg exp) <willem@turtle.stack.nl>
    Re: perl parse (reg exp) <m@rtij.nl.invlalid>
    Re: perl parse (reg exp) sln@netherlands.com
    Re: perl parse (reg exp) <peter@makholm.net>
        Reverse standard input <bandar.coal@gmail.com>
    Re: Reverse standard input <mvdwege@mail.com>
    Re: Reverse standard input <tadmc@seesig.invalid>
    Re: Reverse standard input <bugbear@trim_papermule.co.uk_trim>
    Re: Reverse standard input <vpm+news@serengetty.fr>
        use of "delete" for hash keys <ela@yantai.org>
    Re: use of "delete" for hash keys <tadmc@seesig.invalid>
    Re: use of "delete" for hash keys sln@netherlands.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 1 Nov 2010 13:34:34 +0000
From: Justin C <justin.1010@purestblue.com>
Subject: Re: grep example's use of $_ confusing me.
Message-Id: <a8s2q7-j0p.ln1@zem.masonsmusic.co.uk>

On 2010-10-29, Justin C <justin.1010@purestblue.com> wrote:
> I'm reading The Alpaca (Intermediate Perl - yeah, I know, do I *really*
> think I'm smart enough to be there yet?) and in Chapter 6 I find the
> following example:

Thanks, Tad and Jim. Things are clearer now.

   Justin.

-- 
Justin C, by the sea.


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

Date: Sat, 30 Oct 2010 20:17:09 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: perl parse (reg exp)
Message-Id: <524up7-q6p.ln1@news.rtij.nl>

On Sat, 30 Oct 2010 03:41:11 -0700, Jürgen Exner wrote:

> "Larry" <dontmewithme@got.it> wrote:
>>   I'm using this chunk of code to extract some content from a piece of
>>html.
> [...]
>>but it's not working..how should I go about?
> 
> To parse HTML you should use an HTML parser. Unless you are writing such
> a beast and you know what you are doing because you have experience in
> e.g. writing compilers it is in general A Very Bad Idea to try parsing
> HTLM using ad-hoc REs.
> 
> For further information see the FAQ:
> - "How do I match XML, HTML, or other nasty, ugly things with a regex?"
> - "How do I remove HTML from a string?" or the many, many previous
> discussions about this perpetual topic.

The one exception to this is when the input is not truly html, but 
nevertheless correctly displayed in a browser[1]. This is getting less 
and less common, but still happens.

In that case your options are:
1) Bitch to the website maker
2) Create an ad-hoc parser and hope it does not break
3) Try to repair the html before parsing.

M4


[1] "a" as in some browser, not necessary all browsers.


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

Date: Sat, 30 Oct 2010 18:28:09 +0000 (UTC)
From: Willem <willem@turtle.stack.nl>
Subject: Re: perl parse (reg exp)
Message-Id: <slrnicootp.2se1.willem@turtle.stack.nl>

Martijn Lievaart wrote:
) The one exception to this is when the input is not truly html, but 
) nevertheless correctly displayed in a browser[1]. This is getting less 
) and less common, but still happens.
)
) In that case your options are:
) 1) Bitch to the website maker
) 2) Create an ad-hoc parser and hope it does not break
) 3) Try to repair the html before parsing.

4) Fix the html module you're using to accept broken html.
5) Share this with the module author so everybody can benefit.

Or:

6) Hope somebody already did this and just use an html parser that
   handles broken html gracefully.


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT


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

Date: Sun, 31 Oct 2010 00:11:37 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: perl parse (reg exp)
Message-Id: <pphup7-q6p.ln1@news.rtij.nl>

On Sat, 30 Oct 2010 18:28:09 +0000, Willem wrote:

> 4) Fix the html module you're using to accept broken html.
> 5) Share this with the module author so everybody can benefit.
> 
> Or:
> 
> 6) Hope somebody already did this and just use an html parser that
>    handles broken html gracefully.

Should have thought of that, thanks. Know of any modules that do this?

M4


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

Date: Sat, 30 Oct 2010 19:26:43 -0700
From: sln@netherlands.com
Subject: Re: perl parse (reg exp)
Message-Id: <klkpc6tsb0nr3q4vh5274jefk6n9mi4m39@4ax.com>

On Sat, 30 Oct 2010 12:15:50 +0200, "Larry" <dontmewithme@got.it> wrote:

>Hi,
>
>   I'm using this chunk of code to extract some content from a piece of 
>html.
>
>($parse) = ($html =~ /<tbody>(.*?)<\/tbody>/sg);
>
>so that I can grab everything between <tbody> and </tbody>
>
>Now, I have a some <tr> tags I'd like to parse as follows:
>
><tr class="odd"></tr>
><tr class="even"></tr>
>
>Yet, I want to skip the attribute. I am a newbie with reg exp and I am stuck 
>at this:
>
>(@parse) = ($parse =~ /<tr (\W+)>(.*?)<\/tr>/sg);
>
>but it's not working..how should I go about?
>
>thanks 

Something like this maybe.

-sln

-------------------
use strict;
use warnings;

## Requires 5.10 or above

## OP:  Now, I have a some <tr> tags I'd like to parse as follows:
##        <tr class="odd"></tr>
##        <tr class="even"></tr>
##      Yet, I want to skip the attribute.

##
  my $xml = join '', <DATA>;

##
  my $open  = q{ <tr\s*( [^>]*? )(?<!\/)> };  
  my $close = q{ <\/tr\s*> };

  my $regx = qr/

      <script\s*[^>]*?(?<!\/)> .*? <\/script\s*>  
    |
      (?-i: <!(?:\[CDATA\[.*?\]\]|--.*?--|\[[A-Z][A-Z\ ]*\[.*?\]\])> )
    |
      ( #1
        (?: $open )  #2
        ( #3
           (?:
              (?>
                 (?:
                      (?-i: <!(?:\[CDATA\[.*?\]\]|--.*?--|\[[A-Z][A-Z\ ]*\[.*?\]\])> )
                    | (?! $open | $close ) . 
                 )+
              )
             | (?1)
           )*
        )
        $close
      )
  /ixs;

##
  my @records;

  while ( $xml =~ /$regx/g )
  {
    if (defined $1) {
        print "-->\$2 = '$2'\n";
        print "-->\$3 = '$3'\n";
        push @records, $3;
    }
  }

  print "---------\nDone!\n";

exit;

__DATA__


<![CDATA[
 <tr class="odd"> 
      trodd 
 </tr>
 <tr class="even">
      treven
 </tr>
]]>

<script> 
function search0(){ 
	document.forms[0].submit() 
} 
function Upper() 
{ 
	var up = document.getElementById("h_sn"); 
	return up.value = up.value.toUpperCase(); 
} 
</script> 

<TABLE width="800" BORDER=1 align="center" CELLPADDING=1 CELLSPACING=0> 
  <TR VALIGN="TOP" > 
    <TD colspan="11" align="left" valign="middle" class="style31"><img 
src="image1/Home/Export.png" width="45" height="13" /></TD> 
  </TR> 
  <TR VALIGN="TOP" > 
    <TD WIDTH="33" align="center" class="style25">Item</TD> 
    <TD width="73" align="center" class="style25">AWB No </TD> 
    <TD WIDTH="69" align="center" class="style25">Flight No </TD> 
    <TD WIDTH="87" align="center" class="style25">Flight Date</TD> 
    <TD WIDTH="42" align="center" class="style25">Origin</TD> 
    <TD WIDTH="42" align="center" class="style25">Dest</TD> 
    <TD WIDTH="99" align="center" class="style25">ULD No </TD> 
    <TD WIDTH="105" align="center" class="style25">Status</TD> 
    <TD WIDTH="50" align="center" class="style25"> Pieces </TD> 
    <TD WIDTH="58" align="center" class="style25">Weight </TD> 
    <TD WIDTH="96" align="center" class="style25">Time </TD> 
  </TR> 
    <TR bgcolor='#99CCFF' > 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">1</TD> 
    <TD ALIGN="left"  NOWRAP="TRUE" class="style12">176-75064953</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">EK 419</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Oct 15 2010 </TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">BKK</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">DXB</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Flight Change&nbsp;</TD> 
    <!--// This is check status --> 
    	    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Export 
Transshipment</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">3</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">743.00</TD> 
    <TD ALIGN="right"  NOWRAP="TRUE" class="style12">Oct 14 2010  5:37PM  </TD> 
  </TR> 
    <TR bgcolor='#99FFCC' > 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">2</TD> 
    <TD ALIGN="left"  NOWRAP="TRUE" class="style12">176-75064953</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">EK 419</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Oct 15 2010 </TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">BKK</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">DXB</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">&nbsp;</TD> 
    <!--// This is check status --> 
    	    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Accepted</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">3</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">743.00</TD> 
    <TD ALIGN="right"  NOWRAP="TRUE" class="style12">Oct 14 2010  5:37PM  </TD> 
  </TR> 
    <TR bgcolor='#99CCFF' > 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">3</TD> 
    <TD ALIGN="left"  NOWRAP="TRUE" class="style12">176-75064953</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">EK 373</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Oct 15 2010 </TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">BKK</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">DXB</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Flight Change&nbsp;</TD> 
    <!--// This is check status --> 
    	    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Export 
Transshipment</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">3</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">743.00</TD> 
    <TD ALIGN="right"  NOWRAP="TRUE" class="style12">Oct 14 2010  6:12PM  </TD> 
  </TR> 
    <TR bgcolor='#99FFCC' > 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">4</TD> 
    <TD ALIGN="left"  NOWRAP="TRUE" class="style12">176-75064953</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">EK 373</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Oct 15 2010 </TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">BKK</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">DXB</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">SHC&nbsp;</TD> 
    <!--// This is check status --> 
    	    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Export 
Transshipment</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">3</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">743.00</TD> 
    <TD ALIGN="right"  NOWRAP="TRUE" class="style12">Oct 14 2010  6:12PM  </TD> 
  </TR> 
    <TR bgcolor='#99CCFF' > 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">5</TD> 
    <TD ALIGN="left"  NOWRAP="TRUE" class="style12">176-75064953</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">EK 373</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Oct 14 2010 </TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">BKK</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">DXB</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Flight Change&nbsp;</TD> 
    <!--// This is check status --> 
    	    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Export 
Transshipment</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">3</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">743.00</TD> 
    <TD ALIGN="right"  NOWRAP="TRUE" class="style12">Oct 14 2010  6:42PM  </TD> 
  </TR> 
    <TR bgcolor='#99FFCC' > 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">6</TD> 
    <TD ALIGN="left"  NOWRAP="TRUE" class="style12">176-75064953</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">EK 373</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Oct 14 2010 </TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">BKK</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">DXB</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">PMC31131EK&nbsp;</TD> 
    <!--// This is check status --> 
    	    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Manifested</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">3</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">743.00</TD> 
    <TD ALIGN="right"  NOWRAP="TRUE" class="style12">Oct 14 2010  6:57PM  </TD> 
  </TR> 
    <TR bgcolor='#99CCFF' > 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">7</TD> 
    <TD ALIGN="left"  NOWRAP="TRUE" class="style12">176-75064953</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">EK 373</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Oct 14 2010 </TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">BKK</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">DXB</TD> 
    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">&nbsp;</TD> 
    <!--// This is check status --> 
    	    <TD ALIGN="center"  NOWRAP="TRUE" class="style12">Departed</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">3</TD> 
    <TD ALIGN="RIGHT"  NOWRAP="TRUE" class="style12">743.00</TD> 
    <TD ALIGN="right"  NOWRAP="TRUE" class="style12">Oct 14 2010  9:54PM  </TD> 
  </TR> 
  </TABLE> 
 
<script> 
function show_adv(){ 
	var ko = document.getElementById("showadv"); 
	//var ko2 = document.getElementById("showadv2"); 
	ko.style.display="";  
	//ko2.style.display="";  
} 
</script> 



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

Date: Sun, 31 Oct 2010 09:04:06 +0100
From: Peter Makholm <peter@makholm.net>
Subject: Re: perl parse (reg exp)
Message-Id: <877hgyss95.fsf@vps1.hacking.dk>

"Larry" <dontmewithme@got.it> writes:

>   I'm using this chunk of code to extract some content from a piece of
> html.

As other already said, use a module that already parses HTML.

> <tr class="odd"></tr>
> <tr class="even"></tr>
>
> Yet, I want to skip the attribute. I am a newbie with reg exp and I am
> stuck at this:
>
> (@parse) = ($parse =~ /<tr (\W+)>(.*?)<\/tr>/sg);

Try reading it out loud. You are trying to match "the exact string
'<tr' followed by a space. Then capturing a non-zero number of
non-word characters. Then a '>' and then capturing as few characters
as possible. Finally mathc the exact string '</tr>'".

So between '<tr ' and '>' you tries to capture a string of non-word
characters. But in you example you have plenty of word-characters
there.

> but it's not working..how should I go about?

First you have to listen to the people telling you to use one of the
existing HTML parsing modules.

//Makholm


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

Date: Mon, 1 Nov 2010 06:35:19 -0700 (PDT)
From: perler wannabe <bandar.coal@gmail.com>
Subject: Reverse standard input
Message-Id: <6dc88753-8935-48be-b62b-65a18dc0a58e@32g2000yqz.googlegroups.com>

Hi,

Why my script doesn't reverse my input?

#!/usr/bin/perl -w
@lines=<STDIN>;
@backwardlines=reverse @lines;
print @backwardlines;

This script print the same thing as my keyboard input.

So if I input:
beginning perl

the output will be:
beginning perl

I am expecting the following output though:
perl beginning

Am I missing something?

Thanks


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

Date: Mon, 01 Nov 2010 14:38:41 +0100
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: Reverse standard input
Message-Id: <8639rl5fku.fsf@gareth.avalon.lan>

perler wannabe <bandar.coal@gmail.com> writes:

> Hi,
>
> Why my script doesn't reverse my input?
>
> #!/usr/bin/perl -w
> @lines=<STDIN>;
> @backwardlines=reverse @lines;
> print @backwardlines;
>
> This script print the same thing as my keyboard input.
>
> So if I input:
> beginning perl
>
> the output will be:
> beginning perl
>
> I am expecting the following output though:
> perl beginning
>
> Am I missing something?

Yup.

The <> operator is called readline for a reason. 

You're trying to reverse the order between a single line and itself.

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


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

Date: Mon, 01 Nov 2010 08:56:17 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Reverse standard input
Message-Id: <slrnicti3l.fbh.tadmc@tadbox.sbcglobal.net>

perler wannabe <bandar.coal@gmail.com> wrote:
> Hi,
>
> Why my script doesn't reverse my input?
>
> #!/usr/bin/perl -w
> @lines=<STDIN>;
> @backwardlines=reverse @lines;
> print @backwardlines;
>
> This script print the same thing as my keyboard input.
>
> So if I input:
> beginning perl
>
> the output will be:
> beginning perl
>
> I am expecting the following output though:
> perl beginning
>
> Am I missing something?


Yes. You are missing the difference between lines and words.

Your program reverses lines. 

But you seem to want a program that reverses "words" instead.


------------------------
#!/usr/bin/perl
use warnings;
use strict;

while (<STDIN>) {
    my @words = reverse split;
    print "@words\n";
}
------------------------


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Mon, 01 Nov 2010 13:58:37 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: Reverse standard input
Message-Id: <1pOdna3D2c8TWlPRnZ2dnUVZ8t6tnZ2d@brightview.co.uk>

Mart van de Wege wrote:
> 
> Yup.
> 
> The <> operator is called readline for a reason. 

But, from the camel book:

 >> However, if you use the operator in a list context, a list consisting of all remaining input lines is returned, one line per list element.

   BugBear


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

Date: Mon, 1 Nov 2010 15:37:35 +0100
From: Vivien MOREAU <vpm+news@serengetty.fr>
Subject: Re: Reverse standard input
Message-Id: <slrnictk5f.6bf.vpm+news@pitchu.serengetty.fr>

On 2010-11-01, bugbear wrote:

> Mart van de Wege wrote:
>> 
>> Yup.
>> 
>> The <> operator is called readline for a reason. 
>
> But, from the camel book:
>
> >> However, if you use the operator in a list context, a list consisting of all remaining input lines is returned, one line per list element.

Yes, one line of input per list element:
__EXAMPLE__
hello world
42
__END__

is ('hello world', '42').

-- 
Vivien MOREAU



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

Date: Mon, 1 Nov 2010 14:02:53 +0800
From: "ela" <ela@yantai.org>
Subject: use of "delete" for hash keys
Message-Id: <iall6g$sip$1@ijustice.itsc.cuhk.edu.hk>

For the following codes, the 2nd and 3rd lines print out a lot of IDs and 
keys and the corresponding hash values. However, after executing the 4th 
line, none is left for the 5th line to print. The 1st line should make 
%absent contain more hash values than to delete by the 4th line. So I doubt 
that I misunderstand something in usage, could anybody point the problem 
out?


    my %absent = map {$_ => 1} keys %Priseq;
    foreach $key (keys %absent) {print $key, '=', $absent{$key}, "\n"; 
<STDIN>;}
    foreach $key (@ids) {print $key, "\n"; <STDIN>;}
    foreach $key (@ids) {delete $absent{$key};}
    foreach $key (keys %absent) {print $key, '=', $absent{$key}, "\n"; 
<STDIN>;} 




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

Date: Mon, 01 Nov 2010 09:00:28 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: use of "delete" for hash keys
Message-Id: <slrnictibh.fbh.tadmc@tadbox.sbcglobal.net>

ela <ela@yantai.org> wrote:
> For the following codes, the 2nd and 3rd lines print out a lot of IDs and 
> keys and the corresponding hash values. However, after executing the 4th 
> line, none is left for the 5th line to print. The 1st line should make 
> %absent contain more hash values than to delete by the 4th line. So I doubt 
> that I misunderstand something in usage, could anybody point the problem 
> out?


No, because we don't know what data you have.


>     my %absent = map {$_ => 1} keys %Priseq;


What does %Priseq contain?


>     foreach $key (keys %absent) {print $key, '=', $absent{$key}, "\n"; 
><STDIN>;}
>     foreach $key (@ids) {print $key, "\n"; <STDIN>;}
>     foreach $key (@ids) {delete $absent{$key};}


What does @ids contain?


>     foreach $key (keys %absent) {print $key, '=', $absent{$key}, "\n"; 
><STDIN>;} 


Please supply a short and complete program *that we can run* that
illustrates the problem you are having.

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


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Mon, 01 Nov 2010 07:15:52 -0700
From: sln@netherlands.com
Subject: Re: use of "delete" for hash keys
Message-Id: <7oitc6lartc2cuotmhaglu4cldvathpr8d@4ax.com>

On Mon, 1 Nov 2010 14:02:53 +0800, "ela" <ela@yantai.org> wrote:

>For the following codes, the 2nd and 3rd lines print out a lot of IDs and 
>keys and the corresponding hash values. However, after executing the 4th 
>line, none is left for the 5th line to print. The 1st line should make 
>%absent contain more hash values than to delete by the 4th line. So I doubt 
>that I misunderstand something in usage, could anybody point the problem 
>out?
>
>
>    my %absent = map {$_ => 1} keys %Priseq;
>    foreach $key (keys %absent) {print $key, '=', $absent{$key}, "\n"; 
><STDIN>;}
>    foreach $key (@ids) {print $key, "\n"; <STDIN>;}
>    foreach $key (@ids) {delete $absent{$key};}
>    foreach $key (keys %absent) {print $key, '=', $absent{$key}, "\n"; 
><STDIN>;} 
>

I don't understand. If you take the 4th word from the  end of the
3rd line from the top of the last key and put it in the right spot,
it should work.

-sln


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3193
***************************************


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