[29589] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 833 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 8 21:09:41 2007

Date: Sat, 8 Sep 2007 18:09:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 8 Sep 2007     Volume: 11 Number: 833

Today's topics:
        A flexible multi-level UL/LI constructor <tuxedo@mailinator.com>
    Re: Q on localizing *STDOUT and fork <nobull67@gmail.com>
    Re: Switching with case in perl ? <lerameur@yahoo.com>
    Re: Switching with case in perl ? <dummy@example.com>
    Re: Switching with case in perl ? <mritty@gmail.com>
    Re: Switching with case in perl ? <lerameur@yahoo.com>
    Re: usenet posting of perl release (Randal L. Schwartz)
    Re: usenet posting of perl release (Douglas Wells)
    Re: We urgently require SAP consultant with 5 year of S <uri@stemsystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 08 Sep 2007 22:27:09 -0400
From: Tuxedo <tuxedo@mailinator.com>
Subject: A flexible multi-level UL/LI constructor
Message-Id: <fbv0j3$5nm$03$1@news.t-online.com>

Hi!

Some time ago I received much help on this group in piecing together a
fairly simple two-level HTML list but where conditional output depending on
a current page variable and various other peculiarities were required.

For a similar but somewhat more complex purpose, I'd like find a suitable
method of generating the following nested HTML list structure:

    o  Heading 1
          o Subject 1.1
          o Subject 1.2
          o Sub heading 1.3
                o Subject 1.3.1
                o Subject 1.3.2
          o Subject 1.4
          o Subject 1.5

Ultimately, the list will be converted by CSS and Javascript into a typical
drop-menu. This allows text browsers to gracefully fall back on the
original list structure, while presenting most people with a fancy
drop-menu. The complete HTML output would appear as follows:

<div class="menu">

<ul>

  <li class="expand"><a href="heading1.html">Heading 1</a>
      
     <ul>

       <li><a href="subject1.1.html">Subject 1.1</a></li>
       <li><a href="subject1.2.html">Subject 1.2</a></li>

       <li class="expand"><a href="subheading1.3.html">Sub heading 1.3</a>

            <ul>
               <li><a href="subject1.3.1.html">Subject 1.3.1</a></li>
               <li><a href="subject1.3.2.html">Subject 1.3.2</a></li>
            </ul>

       </li>

       <li><a href="subject1.4.html">Subject 1.4</a></li>
       <li><a href="subject1.5.html">Subject 1.5</a></li>

     </ul>

 </li>

</ul>

</div>

The above example would generate one multi-level drop-menu only, while in
reality, the complete navigation system will consist of several drop-menus
which are all aligned horizontally in a typical page header style.

Some menus may include two, three, four and even five level UL's. One level
only can also exist in the odd situation, which would simply display a
top-level link without a drop-menu.

Each menu will be placed within separate <div class=menu> tags. In short,
without href's, classes and ID's, an example of two menus follows below. In
this case the first menu has three levels and the second has four levels:

<!-- first menu, containing UL's and LI's with maximum three levels -->

<div class="menu">

<ul>
  <li>Heading 1
      
     <ul>

       <li>Subject 1.1</li>
       <li>Subject 1.2</li>

       <li>Sub heading 1.3

           <ul>
               <li>Subject 1.3.1</li>
               <li>Subject 1.3.2</li>
           </ul>

       </li>

       <li>Subject 1.4</li>
       <li>Subject 1.5</li>

     </ul>

  </li>

</ul>

</div>

<!-- second menu, containing UL's and LI's with maximum four levels -->

<div class="menu">

<ul>

  <li>Heading 2
      
     <ul>

        <li>Subject 2.1</li>

        <li>Sub heading 2.2

            <ul>
               <li>Subject 2.2.1</li>
               <li>Sub heading 2.2.2
                  
                   <ul>
                      <li>Subject 2.2.2.1</li>
                      <li>Subject 2.2.2.2</li>
                   </ul>

               </li>

            </ul>

        </li>

        <li>Subject 2.3</li>
        <li>Subject 2.4</li>
        <li>Subject 2.5</li>
        <li>Subject 2.6</li>
        <li>Subject 2.7</li>

     </ul>

  </li>

</ul>

</div>

The above first-level UL's/LI's ("Subject 1" and "Subject 2"), always
contain only one link in it's own level, followed directly by the
opening of a second-level nested UL. This allows CSS to style all others
initially as hidden, until the first level heading is hovered. But this
posting is not about CSS and so I have excluded any such code. However,
should anyone want the accompanying CSS, I would be happy to post
it here. In fact, different types of CSS menus can be built upon the same
or similar type of UL/LI structures and these can naturally only work as
expected if the correct list structures are in place to start with.

The above examples shows the basic UL/LI nesting which the Perl script needs
to generate. However, some additional details needs to be considered to know
exactly what type of coding methods may best serve the particular purpose.

For example, the Perl script needs to recognize which LI's are followed by a
nested UL and print such entries with a specific HTML class:

<li class="expand">

This allows CSS to place a visual indicator, such as, a small arrow (>)
next to the linked area from where sub-menus unfold when hovered. For
example, when hovering Sub heading 1.3, it's nested sub-menu, including
Subject 1.3.1 and 1.3.2, appear directly to the right of the hovered area:

+-----------------------------------------------------------------
| Heading 1       > |  Heading 2  >  |   Heading 3  >   |  etc.
+-------------------------------------------------------------
| Subject 1.1       | 
+-------------------+
| Subject 1.2       |
+-------------------+----------------+
| Sub heading 1.3 > | Subject 1.3.1  |  
+-------------------+----------------+
| Subject 1.4       | Subject 1.3.2  |
+-------------------+----------------+
| Subject 1.5       |
+-------------------+

The Perl program will also need to know where within a menu the current HTML
page is represented by traversing the various href values in arrays or
hashes. The current page is identified by a CGI environment variable as:

$current::page = $ENV{DOCUMENT_NAME} || 'undefined';

All HTML documents will exist in one directory level (DocumentRoot) and no
page will be linked to twice from the navigation menus. Therefore, a
same DOCUMENT_NAME conflict will never occur in any of the Perl references.

The LI entry matching the current document should appear as a non-link and
with a unique HTML ID. For example, if the $current::page matches
subject1.3.1.html, then that entry should be printed in the menu as:

<li id=CURRENT_PAGE>Subject 1.3.1</li>

Furthermore, the program will need to be aware of the navigational pathway,
via the arrays or hashes, so it can:

1) Return a text string that displays where the user is, so if the current
page is subject1.3.1.html, then this string would become:

    You are in: Heading 1 > Sub heading 1.3 > Subject 1.3.1

2) Output a specific HTML class in the relevant href tags in the pathway, so
when the current page is subject1.3.1.html, a class, e.g. "PATH", would
apply to the entries at the nesting positions that lead up to the current
page. In this case, these two separate HTML tags would appear as:

   <a href="heading1.html" class="PATH">Heading 1</a>
   
   <a href="subheading1.3.html" class="PATH">Sub heading 1.3</a>

What signifies pathway LI's is that they can only exist directly after the
opening of LI's with opening UL's before the corresponding LI is closed.
Heading 1 and Sub heading 1.3 in this case are both nesting points and the
pathway to the current page.

Apart from the existence of the menu header, subheading1.3.html will not
present any special content. These type of pages only summarize content
that exist on the sub-menu pages which they represent. Such pathway pages,
including those at first levels, i.e. heading1.html and heading2.html, fill
the same type of purpose in this navigation system, i.e. they are simply
Tables of Contents. Anyhow, this has more to do with the site's content
organization than with the actual functions of the Perl program itself.

Would some kind of multi-level hash arrays, perhaps using Tie::IXHash, be
an appropriate method to generate these type of menu lists?

The procedure is only meant to output dynamically generated menus across all
pages of a site through SSI within a localhost environment. In other words,
the script will not run for each and every page request in a real web
server situation, so no system performance limitations apply. A different
procedure will save all pages in static form to transfer onto a web server.

The projects objective is to maintain a navigation menu across a site via
one Perl script, allowing for navigation links of each separate menu to be
easily modified across the site, including the varying levels of nesting.

In summary, the Perl program should ideally do the all the following:

1) Generate the multi-level UL/LI structure defined in hashes or arrays.
2) Print the current page menu entry differently from others.
3) Identify and print LI's of nesting points differently, as well as return
the navigational pathway string.

What would be a good way to glue these points together? How can the first
point be constructed with a suitable loop for example?

Any ideas, including barebone code examples, that can help lead me in the
right direction, would be greatly appreciated!

Many thanks,
Tuxedo

-- 
One thing the inventors can't seem to get the bugs out of is fresh paint.



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

Date: Sat, 08 Sep 2007 07:45:17 -0700
From:  Brian McCauley <nobull67@gmail.com>
Subject: Re: Q on localizing *STDOUT and fork
Message-Id: <1189262717.141946.142730@50g2000hsm.googlegroups.com>

On 3 Aug, 20:02, Brian McCauley <nobul...@gmail.com> wrote:
> On Aug 3, 4:55 pm, kj <so...@987jk.com.invalid> wrote:

> > If anyone happens to know the CPAN module that Brian is referring
> > to here please let me know.  I looked for it without any luck.  I
> > searched for terms like "redirect" and "redirection".  (FWIW, I
> > did my search with Google restricted to site:search.cpan.org.)
>
> I think I was miss-remembering either Hook::Output::File or
> SelectSaver - neither of which does what you want.

For the sake of the archives, I'd like to add that various modules
with "Capture" in the name do indeed do what the OP was seeking and
maybe this is what I was remembering.




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

Date: Sat, 08 Sep 2007 09:20:58 -0700
From:  lerameur <lerameur@yahoo.com>
Subject: Re: Switching with case in perl ?
Message-Id: <1189268458.951318.62620@g4g2000hsf.googlegroups.com>

On Sep 8, 7:43 am, Joe Smith <j...@inwap.com> wrote:
> lerameurwrote:
> >    if($minutes_count<10) {
> >       $minutes_count="0$minutes_count";
> >    } else {
> >       $minutes_count=$minutes_count;
> >    }
>
> Yarg!  Haven't you ever used sprintf?
>
> > $logTime = $year$month$day$hours;
>
>    $logTime = sprintf "%04d/%02d/%02d_%02d:%02d",
>                   $year, $month, $day, $hour, $minute;
>
> And are you aware thatPerlhas the ability to increment strings?
>
>    perl-le '$n="00";$s="cw";print $n++," ",$s++ for (0..12)'
>
> That comes into play if you have
>    $value = "00";
> instead of
>    $value = 0;
> and then use $value++ or ++$value.
>
>         -Joe

hello again, thanks for the function, it works good.
I am new to perl so i dont know all the internal functions.
I get the following error from this line , can you tell me why:

for my $minute (0..59) {
my $logtime = strftime("%y%m%d%H%M", 0, $minute, $hours, $day, $month
-1, $year + 100), "\n";  #line 20
   print $logtime,"\n";
}

error: Useless use of constant in void context at line 20.

k



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

Date: Sat, 08 Sep 2007 19:09:38 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: Switching with case in perl ?
Message-Id: <SrCEi.40233$vP5.25179@edtnps90>

lerameur wrote:
> On Sep 8, 7:43 am, Joe Smith <j...@inwap.com> wrote:
>> lerameurwrote:
>>>    if($minutes_count<10) {
>>>       $minutes_count="0$minutes_count";
>>>    } else {
>>>       $minutes_count=$minutes_count;
>>>    }
>> Yarg!  Haven't you ever used sprintf?
>>
>>> $logTime = $year$month$day$hours;
>>    $logTime = sprintf "%04d/%02d/%02d_%02d:%02d",
>>                   $year, $month, $day, $hour, $minute;
>>
>> And are you aware thatPerlhas the ability to increment strings?
>>
>>    perl-le '$n="00";$s="cw";print $n++," ",$s++ for (0..12)'
>>
>> That comes into play if you have
>>    $value = "00";
>> instead of
>>    $value = 0;
>> and then use $value++ or ++$value.
> 
> hello again, thanks for the function, it works good.
> I am new to perl so i dont know all the internal functions.
> I get the following error from this line , can you tell me why:
> 
> for my $minute (0..59) {
> my $logtime = strftime("%y%m%d%H%M", 0, $minute, $hours, $day, $month
> -1, $year + 100), "\n";  #line 20
>    print $logtime,"\n";
> }
> 
> error: Useless use of constant in void context at line 20.

The ', "\n"' at the end of line 20 is the problem.  You are assigning "\n" to 
$logtime because of the comma opertor.



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Sat, 08 Sep 2007 16:32:40 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Switching with case in perl ?
Message-Id: <1189294360.133756.55430@22g2000hsm.googlegroups.com>

On Sep 8, 3:09 pm, "John W. Krahn" <du...@example.com> wrote:
> lerameur wrote:
> > On Sep 8, 7:43 am, Joe Smith <j...@inwap.com> wrote:
> >> lerameurwrote:
> >>>    if($minutes_count<10) {
> >>>       $minutes_count="0$minutes_count";
> >>>    } else {
> >>>       $minutes_count=$minutes_count;
> >>>    }
> >> Yarg!  Haven't you ever used sprintf?
>
> >>> $logTime = $year$month$day$hours;
> >>    $logTime = sprintf "%04d/%02d/%02d_%02d:%02d",
> >>                   $year, $month, $day, $hour, $minute;
>
> >> And are you aware thatPerlhas the ability to increment strings?
>
> >>    perl-le '$n="00";$s="cw";print $n++," ",$s++ for (0..12)'
>
> >> That comes into play if you have
> >>    $value = "00";
> >> instead of
> >>    $value = 0;
> >> and then use $value++ or ++$value.
>
> > hello again, thanks for the function, it works good.
> > I am new to perl so i dont know all the internal functions.
> > I get the following error from this line , can you tell me why:
>
> > for my $minute (0..59) {
> > my $logtime = strftime("%y%m%d%H%M", 0, $minute, $hours, $day, $month
> > -1, $year + 100), "\n";  #line 20
> >    print $logtime,"\n";
> > }
>
> > error: Useless use of constant in void context at line 20.
>
> The ', "\n"' at the end of line 20 is the problem.  You are
> assigning "\n" to $logtime because of the comma opertor.

No he's not.  = has a higher precedence than ,.  He's assigning the
results of strftime(...) to $logtime, and then that assignment and the
"\n" are both evaluated by the , operator.

$ perl -MO=Deparse,-p -e'my $x = foo(), 5;'
((my $x = foo()), '???');
-e syntax OK


Regardless, you are correct as to what the problem is, just not what
the end result is.

To the OP:  Don't blindly copy my code and then modify it without even
bothering to understand it.  When I posted that code, I was printing
the strftime() and then the "\n" in the same statement.  In your
modification, you changed the print to a variable assignment, and then
tried to print the variable and another newline.

Paul Lalli



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

Date: Sat, 08 Sep 2007 17:15:17 -0700
From:  lerameur <lerameur@yahoo.com>
Subject: Re: Switching with case in perl ?
Message-Id: <1189296917.537785.191800@22g2000hsm.googlegroups.com>


> > >>> $logTime = $year$month$day$hours;
> > >>    $logTime = sprintf "%04d/%02d/%02d_%02d:%02d",
> > >>                   $year, $month, $day, $hour, $minute;
>
> > >> And are you aware thatPerlhas the ability to increment strings?
>
> > >>    perl-le '$n="00";$s="cw";print $n++," ",$s++ for (0..12)'
>
> > >> That comes into play if you have
> > >>    $value = "00";
> > >> instead of
> > >>    $value = 0;
> > >> and then use $value++ or ++$value.
>
> > > hello again, thanks for the function, it works good.
> > > I am new toperlso i dont know all the internal functions.
> > > I get the following error from this line , can you tell me why:
>
> > > for my $minute (0..59) {
> > > my $logtime = strftime("%y%m%d%H%M", 0, $minute, $hours, $day, $month
> > > -1, $year + 100), "\n";  #line 20
> > >    print $logtime,"\n";
> > > }
>
> > > error: Useless use of constant in void context at line 20.
>
> > The ', "\n"' at the end of line 20 is the problem.  You are
> > assigning "\n" to $logtime because of the comma opertor.
>
> No he's not.  = has a higher precedence than ,.  He's assigning the
> results of strftime(...) to $logtime, and then that assignment and the
> "\n" are both evaluated by the , operator.
>
> $perl-MO=Deparse,-p -e'my $x = foo(), 5;'
> ((my $x = foo()), '???');
> -e syntax OK
>
> Regardless, you are correct as to what the problem is, just not what
> the end result is.
>
> To the OP:  Don't blindly copy my code and then modify it without even
> bothering to understand it.  When I posted that code, I was printing
> the strftime() and then the "\n" in the same statement.  In your
> modification, you changed the print to a variable assignment, and then
> tried to print the variable and another newline.
>
> Paul Lalli

Well I thought I did understand...

here the whole code for that part:

for my $minute (0..59) {
my $logtime = strftime("%y%m%d%H%M", 0, $minute, $hours, $day, $month
-1, $year + 100) ;
   #open each traffic log files and append them to one files
		open (FILE_1,"</*$year$month$day$hours$minute*/");  #............
#Line 23
			foreach $line (<FILE_1>) {
				if ($line =~ m/david/) {
					open (FILE, ">>$year$month$day$hours.txt");
						@items =  split(",",$line);
						print FILE $items[0], ",", $items[1], ",", $items[2],",",
$items[2], ";" . "\n";
					close(FILE);
		}
	}
 } #closing  for my minute loop
		close (FILE_1);

here is my full code.  I get the error: readline() on closed
filehandle FILE_1 at C:\Perl\eg\ccc.pl line 23.
I want to create one log file out of 5 log files that are created
every hour. I am not sure how to use the '*' the log file is in the
format log_$year$month$day$hours$minute_.txt

k



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

Date: Sat, 08 Sep 2007 10:18:55 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: usenet posting of perl release
Message-Id: <86fy1poz28.fsf@blue.stonehenge.com>

>>>>> "simil" == simil  <dsimil@gmail.com> writes:

simil>    Thanks for the links. But, I was looking for the exact posting made
simil> by larry wall in comp.sources.misc usenet group. I searched the group
simil> but couldn't find anything :(. And regarding the content of the first
simil> post at http://sources.isc.org/devel/lang/perl.txt ,why is the date
simil> Jan 31, 1988 and not Dec 18, 1987?

I think we're all going off the CVS date which is 1987-12-18 as the
'birthday', although you're right, it wasn't published to comp.sources.unix
until the end of January 1988.

I found

  http://groups.google.com/group/comp.sources.unix/msg/bb3ee125385ae25f

which seems to be the first post of the first kit of Perl 1.0, dated
01 Feb 1988.

print "Just another Perl hacker,"; # the original

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: Sat, 8 Sep 2007 14:17:50 -0400 (EDT)
From: see@signature.invalid (Douglas Wells)
Subject: Re: usenet posting of perl release
Message-Id: <fbup0e$119h$1@flame.contek.com>

In article <1189242668.136439.47220@y42g2000hsy.googlegroups.com>,
  simil <dsimil@gmail.com> writes:
> > > "Larry Wall released the first released version 1.0 of perl to the
> > > comp.sources.misc newsgroup on December 18, 1987". Almost everybody
> > > must have seen this line when they first start learning perl. But
> > > where the hell is that posting? I have been trying to find out that
> > > posting but in vain. Can anybody point me to that? I am just curious.
> 
>    Thanks for the links. But, I was looking for the exact posting made
> by larry wall in comp.sources.misc usenet group. I searched the group
> but couldn't find anything :(. And regarding the content of the first
> post at http://sources.isc.org/devel/lang/perl.txt ,why is the date
> Jan 31, 1988 and not Dec 18, 1987?

I suspect some of that information is wrong.  According to my
archives, perl v1.0 went out on comp.sources.unix (not .misc) dated
"1 Feb 88." See <news:50@fig.bbn.com> or
<http://groups.google.com/group/comp.sources.unix/msg/bb3ee125385ae25f?dmode=source&hl=en>.

I looked in my USENET archive CD-ROM dated July 1993, and I see
no Perl release that early on comp.sources.misc.  I do note,
however, that volume 1 of c.s.m is missing from that archive --
and may have never existed. (Volume 2 of c.s.m started in early 1988.)

I don't know about the date discrepancy.  Note that the c.s.u
moderator did a lot of checking of input, and many submissions
took quite a lot of additional work (and time) before they were
portable enough and compiled cleanly enough to go out under the
c.s.u manteau.  It's also possible that a submission didn't work
well with non-UNIX systems and was kicked over to c.s.u from c.s.m
(although, and I repeat, I have no knowledge of this particular
situation).

 - dmw

-- 
 .   Douglas Wells             .  Connection Technologies      .
 .   Internet:  -sp9804- -at - contek.com-                     .


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

Date: Sat, 08 Sep 2007 16:13:39 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: We urgently require SAP consultant with 5 year of SAP experience
Message-Id: <x7ps0tdtjg.fsf@mail.sysarch.com>

>>>>> "TM" == Tad McClellan <tadmc@seesig.invalid> writes:

  TM> usenet@DavidFilmer.com <usenet@DavidFilmer.com> wrote:
  >> On Sep 7, 8:53 pm, Uri Guttman <u...@stemsystems.com> wrote:
  >>> does SAP stand for:
  >> 
  >> The maroon OP held his shift
  >> key down,


  TM> That is simply the

  TM>    Law of Case Conservation

  TM> in action.

  TM> The uc()'s missing in Uri's posts show up in spammer's posts.

  TM> :-)

HEY, I UPPERCASED SAP!!

URI

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

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


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