[12337] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5937 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 9 18:07:29 1999

Date: Wed, 9 Jun 99 15:01:32 -0700
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, 9 Jun 1999     Volume: 8 Number: 5937

Today's topics:
    Re: Perl script to purge old messages in mailboxes ? (Marcel Grunauer)
    Re: Perl script to purge old messages in mailboxes ? <gellyfish@gellyfish.com>
        Perlshop - missing delimiter? cottleston@my-deja.com
    Re: Perlshop - missing delimiter? <cassell@mail.cor.epa.gov>
    Re: Regexpr for loop to handle e-address list <gellyfish@gellyfish.com>
    Re: Separating array into alphabetical array of arrays <Tobin@breathemail.net>
    Re: Sequently adding data to a hash with $x[x..x]??? <mats.pettersson@falukuriren.se>
        Setting cookies with CGI.pm <paulr@tc.umn.edu>
        sorting <Webdesigner@NewWebSite.com>
    Re: sorting (Andrew Johnson)
    Re: sorting <jbc@shell2.la.best.com>
    Re: VERSION numbers <zamboni@xnet-a-062.resnet.purdue.edu>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 09 Jun 1999 19:40:01 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Perl script to purge old messages in mailboxes ?
Message-Id: <375f37ba.2568623@enews.newsguy.com>

On 08 Jun 1999 11:18:18 +0200, Gildas PERROT <perrot@francenet.fr>
wrote:

>Hi,
>
>I am looking for a script which is able to first warn the user that
>some messages are too old.
>
>Thanks in advance for your help.			Gildas.

You write it yourself and if you run into any specific problems that
are related to Perl, you come back here.

Marcel



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

Date: 9 Jun 1999 21:15:44 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl script to purge old messages in mailboxes ?
Message-Id: <7jmli0$tj$1@gellyfish.btinternet.com>

[ Trimmed groups ]

In comp.lang.perl.misc Gildas PERROT <perrot@francenet.fr> wrote:
> Hi,
> 
> I am looking for a script which is able to first warn the user that
> some messages are too old.
> 

You could obtain the headers from the mailbox using modules from the
Mail-tools package available from CPAN:


#!/usr/bin/perl -w

use strict;

use Mail::Header;
use Mail::Util qw(read_mbox);

my @messages = read_mbox('/var/spool/mail/gellyfish');

foreach (@messages)
{
  my $header = new Mail::Header $_;
  print $header->get('Subject'),
        "\t",$header->get('Date'),"\n";
}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Wed, 09 Jun 1999 19:24:27 GMT
From: cottleston@my-deja.com
Subject: Perlshop - missing delimiter?
Message-Id: <7jmf0t$sjt$1@nnrp1.deja.com>

I am installing Perlshop for the first time and have everything working
except for the "shipping rate" button on the "current order" page. The
"shipping rate" buttons work fine on all of the other pages.  I have it
narrowed down to a very tiny piece of code, but I don't know enough to
figure out what's wrong with it.

The "continue shopping" button sets just before the shipping rates
button on the "current order" screen.  I can use an image for any of the
other button with no problem, but as soon as I use an image for the
"continue shopping" button, the "shipping rates" button (right next to
it) starts working like the "continue shopping" button.  I'm
thinking there might be some type of a delimiter missing between the two
fields in the code.  Can anyone help me with this?

 if ($add_cart != 1)
  {
  print '<td>';
  if ($button_image{'CONTINUE SHOPPING'} eq '')
   {print "<input type=submit name=ACTION value=\"CONTINUE
SHOPPING\">";}
  else
   {
   print "<input type=hidden name=ACTION value=\"CONTINUE SHOPPING\">";
   print "<input type=image name=Continue_Shopping
src=\"$image_location/$button_image{'CONTINUE SHOPPING'}\" border=0>";
   }
  print '</td>';
  }
 if (! ($shipping_type eq 'included' || $shipping_type eq 'none') )
  {
  print '<td>';
  if ($button_image{'SHIPPING RATES'} eq '')
   {print "<input type=submit name=ACTION value=\"SHIPPING RATES\">";}
  else
   {
   print "<input type=hidden name=ACTION value=\"SHIPPING RATES\">";
   print "<input type=image name=Shipping_Rates
src=\"$image_location/$button_image{'SHIPPING RATES'}\" border=0>";
   }
  print '</td>';



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 09 Jun 1999 13:59:22 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: cottleston@my-deja.com
Subject: Re: Perlshop - missing delimiter?
Message-Id: <375ED5AA.82565BF3@mail.cor.epa.gov>

[courtesy cc to poster]

cottleston@my-deja.com wrote:
> 
> I am installing Perlshop for the first time and have everything working
> except for the "shipping rate" button on the "current order" page. The
> "shipping rate" buttons work fine on all of the other pages.  I have it
> narrowed down to a very tiny piece of code, but I don't know enough to
> figure out what's wrong with it.
> [big snip of code]

Then you'll be pleased to know that there's a listserv devoted
solely to Perlshop, where you should be able to get some fast,
reliable assistance.  Just send an e-mail to the following
address to subscribe:

perlshop-subscribe@topica.com

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 9 Jun 1999 22:04:36 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Regexpr for loop to handle e-address list
Message-Id: <7jmodk$10e$1@gellyfish.btinternet.com>

On Wed, 09 Jun 1999 16:34:35 GMT dalehend@flash.net wrote:
> On Wed, 9 Jun 1999 09:07:08 -0700, Tom Phoenix <rootbeer@redcat.com>
> wrote:
>>On Wed, 9 Jun 1999 dalehend@flash.net wrote:
>>
>>> Does have an example that I can expand on in order to parse a quoted
>>> email list that can be 1 or more lines. In other words -
>>> "john\@town.com ben\@town.com younme\@work.com
>>>              sebastian\@town.org isaac\@town.org"
>>
>>What do you do with e-mail addresses containing quote marks or spaces?
>>Write to <"fred & barney"@redcat.com> if you don't believe that there are
>>such addresses. :-)
>>
>>To do this properly, you'd need to parse the addresses. See whether the
>>Mail::Address module from CPAN will help you to do what you need. Good
>>luck!
>>
> 
> The email list is the value for a $variable, so all I am wanting to do
> is parse a quoted list.
> 

Yeah but you still want to use Mail::Address (part of the Mail-tools
package from CPAN) :


#!/usr/bin/perl -w

use strict;

use Mail::Address;

my $list =<<'BLAH';
doris&sceptic@gellyfish.com blah@[194.112.49.16]
"pager:1123567"@somepager.com
normail@woof.com "Yowsa - its me"@thing.com
BLAH

my @addresses = Mail::Address->parse($list);

foreach (@addresses)
{
  print $_->format,"\n";
}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Tue, 8 Jun 1999 21:42:56 +0100
From: "Tobin" <Tobin@breathemail.net>
Subject: Re: Separating array into alphabetical array of arrays
Message-Id: <375ed135@news2.vip.uk.com>

Hi,

I would have thought you could do this by using the 'substr' command. What
you could do is, after sorting the array, step through each 'record' or
element taking the first letter and comparing it with the previous one. If
there it is different, then tell perl to create a new file.  To get the
first letter using substr try something like this...

(this code is not checked but it should give the idea)

# initialise the first letter to a, or whatever the first one might be
$previousLetter = 'a'

foreach(@mySortedArray)
{ 
  # if the current letter is not equal to the previous one...
  if ( ! (substr($_, 0, 1) eq $previousLetter))
  { #... change the name of the output file which is being written to 
    $outputFile  =  substr($_, 0, 1 ) . ".txt"; 
  }
  
  #write element to output file here  
 blah blah...

  # update the previous letter to be the current one for next iteration of loop.
  $previousLetter = substr($_, 0, 1);
}


Hope this helps!....

T o b e s



Marc Bissonnette wrote in message ...
>I've recently completed a script that reads in a pipe deparate file of names, 
>addresses, etc, sorts them, formats them and prints to file, thanks to help 
>recieved from this group (thanks again!). Now here's what I need to do:
 ....

>....Marc Bissonnette
>InternAlysis
>Corporate Internet Research and Results!
>http://www.internalysis.com
>





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

Date: Wed, 09 Jun 1999 23:28:11 +0200
From: Mats Pettersson <mats.pettersson@falukuriren.se>
Subject: Re: Sequently adding data to a hash with $x[x..x]???
Message-Id: <375EDC6B.FD9511C7@falukuriren.se>

Tad McClellan wrote:
> 
> Mats Pettersson (mats.pettersson@falukuriren.se) wrote:
> : Any ideas?
> 
>    Yes.
> 
>    Tell us what you want to do.
> 
>    If you are speaking of a hash, then you need keys and values.
> 
>    What are your keys?
> 
>    What are your values?

Ok!

Sorry, i try to explain it better.

I have a file with several lines of data. Each line has numeric (integer) values separated by comma, as follows...

vv,ll,kk,dd,kk,dd,kk,dd....(...and so on)

 ...where vv= some number (always first on the line),
         ll = length of data (number of pairs of keys and values)
         kk = key
         dd = value

The first two values of each line should NOT get in the %hash.

Since there are several lines of data, i want to build a %hash and add data to it as i loop through the lines.

Now, the problem is; if i (after an apropriate split, of course) do a "%hash = @line[2..5]", the previus line of data gets "lost" at each iteration through the loop.

So, after the loop i end up with just the last line in the file, not a complete %hash of all the keys and values in the file put together.

Is there somekind of operator like "+=" (tried it, doesn't work) i can use, or do i have to build a @scalar first and assign it to the %hash afterwards?

Like i have it now, i use a for() loop to insert the keys and values, but it would be neat if there was a simpler way.

Mats


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

Date: Wed, 09 Jun 1999 16:35:07 -0500
From: Paul Rubenis <paulr@tc.umn.edu>
Subject: Setting cookies with CGI.pm
Message-Id: <375EDE0B.663577F0@tc.umn.edu>

I am having a devil of a time getting a valid cookie created with
CGI.pm.  I try to set the cookie in the first form.  The cookie value is
a hash of hashes.  When I try to read that cookie, I can get the first
set of key values out of the hash, but nothing else...

first form:

  $cookie = $query->cookie(-name=>'nameofcookie',
                        -value=>\%HoHs,
                        -expires=>'+2h');

  print $query->header(-cookie=>$cookie);

second form:

%HoH = $query->cookie(-name'nameofcookie');


	I can get values from 'keys %HoH', but if I try to 'keys %{ $HoH{$key}
}' nothing is returned.  They typical look of the %HoH is:

%HoH = (
	'key' => {
			'key_' => {
					'key__' => value,
					'key2__' => value,
				  },
			'key2_' => {										'key__' => value,
					'key2__' => value,
				   },
	'key2' => {

		  }

	You get the idea.  I can get the first set of keys, but nothing beyond
this.  I have found no reference in the CGI.pm docs about limitations of
the datastructures passed in as cookie values.  If anyone sees a glaring
mistake on my part, I'd appreciate some feedback.  Thanks.

-Paul Rubenis
paulr@tc.umn.edu


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

Date: Wed, 09 Jun 1999 18:48:59 GMT
From: Floyd Morrissette <Webdesigner@NewWebSite.com>
Subject: sorting
Message-Id: <7jmcun$rom$1@nnrp1.deja.com>

Hi, I have this perl script which sorts the records in a text file
database. Currently it sorts by ASCII format. I want it to sort
numerically. I was hoping this script could be modified to do this.
Could someone please help me with this or point me in the right
direction? Thank you. Script below:

open(FILE, "$database")  || die "Content-type: text/html\n\nCannot open
database!";

$count=0;
@row1 =<FILE>;
close (FILE);

while (@row1[$count] ne "")

        {
        $row = @row1[$count];
        @row = split (/\::/, $row);
        $sortable_field = $row[1];
        unshift (@row, $sortable_field);
        $new_row = join ("\::", @row);
        push (@new_rows, $new_row);
        $count++
        }

# Next, sort the lines of the database


        @sorted_rows = reverse sort (@new_rows);

#now put the field back where it belongs

@database_rows = ();
 foreach $sorted_row (@sorted_rows)
    {
    @row = split (/\::/, $sorted_row);
    $sorted_field = shift (@row);
    $old_but_sorted_row = join ("\::", @row);
    push (@database_rows, $old_but_sorted_row);
    }


# print the results into the database

        open(FILE, ">$database");
        print FILE (@database_rows);
        close(FILE);


--
Get your web site from http://www.NewWebSite.com
Consultation is always free.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 09 Jun 1999 20:21:22 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: sorting
Message-Id: <61A73.5337$WL.106508@news2.rdc1.on.home.com>

In article <7jmcun$rom$1@nnrp1.deja.com>,
 Floyd Morrissette <Webdesigner@NewWebSite.com> wrote:
! Hi, I have this perl script which sorts the records in a text file
! database. Currently it sorts by ASCII format. I want it to sort
! numerically. I was hoping this script could be modified to do this.
! Could someone please help me with this or point me in the right
! direction? Thank you. Script below:

please see the documentation on the sort function:
      perldoc -f sort

next, please see the faq entry in perlfaq4:
      How do I sort an array by (anything)?

This last one will show you a technique called
the schwartzian transform which will allow you
to reduce your script to just a handful of lines.

regards
andrew


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

Date: 09 Jun 1999 20:52:13 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: sorting
Message-Id: <375ed3fd$0$213@nntp1.ba.best.com>

Floyd Morrissette <Webdesigner@NewWebSite.com> wrote:
> Hi, I have this perl script which sorts the records in a text file
> database. Currently it sorts by ASCII format. I want it to sort
> numerically.

>         @sorted_rows = reverse sort (@new_rows);

Use the numeric sort ("spaceship") operator: <=> and an explicit sort
block:

@sorted_rows = reverse sort {$a <=> $b} @new_rows;

you could also lose the 'reverse' by switching the position of $a and
$b:

@sorted_rows = sort {$b <=> $a} @new_rows;

Lots of additional detail available by entering:

perldoc -f sort
perldoc -q sort (which gives you the 'How do I sort an array by
(anything)?' entry from perlfaq4)

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: 09 Jun 1999 15:50:17 -0500
From: Diego Zamboni <zamboni@xnet-a-062.resnet.purdue.edu>
Subject: Re: VERSION numbers
Message-Id: <cwpv3514l2.fsf@xnet-a-062.resnet.purdue.edu>

ijg@csc.liv.ac.uk (I.J. Garlick) writes:
> Can some one explain the $VERSION variable to me because there sure seems
> to be a weird way of getting it to equal version numbers.
> [...]
> even I can work out how VERSION gets set but as to why?

The VERSION variable can be used to request a specific version of a
module. For example, you can do the following:

use Module 1.36;

and then Perl will produce an error if the variable $Module::VERSION
is smaller than 1.36.

The Perl documentation uses the following slightly more complex way
of assigning VERSION using the RCS tag $Revision$:

$VERSION = do { my @r = (q$Revision: 2.21 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker

The advantage of this over the other ways you showed in your message is
that it correctly deals with multiple-dot revision numbers (2.21.2, for
example) that sometimes occur.

Best regards,
--Diego


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5937
**************************************

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