[22154] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4375 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 10 00:05:50 2003

Date: Thu, 9 Jan 2003 21:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 9 Jan 2003     Volume: 10 Number: 4375

Today's topics:
    Re: A tar utility written in Perl <pkent77tea@yahoo.com.tea>
    Re: Activeperl : ppm and GD <randy@theoryx5.uwinnipeg.ca>
        ActiveState PerlApp with SWIG dll (Andrew Allaire)
        EXCEL OLE functions <j.perez.montes@terra.es>
    Re: EXCEL OLE functions <jurgenex@hotmail.com>
    Re: EXCEL OLE functions <mgarrish@rogers.com>
    Re: grep  ==  ?? <fm_duendeBASURA@yahoo.com>
    Re: grep  ==  ?? (Malcolm Dew-Jones)
    Re: grep  ==  ?? (Tad McClellan)
    Re: How am I using sort wrong? (Joe)
    Re: Net::Ping issue <junk_nntp@hoopajoo.net>
        parsing xml with perl --- very urgent .. help please (reddy)
    Re: parsing xml with perl --- very urgent .. help pleas (Tad McClellan)
        Server sockets <luc@nospam.com>
    Re: Server sockets <spam@thecouch.homeip.net>
    Re: silly question -- please help! <sg7188@snet.net>
    Re: silly question -- please help! (Tad McClellan)
        stucked <mats.svensson2@telia.com>
    Re: stucked <mgjv@tradingpost.com.au>
    Re: Unix Vars declared in system() call -> %ENV (Sam Holden)
    Re: What is a simple way to read and write zip files? <hal@thresholddigital.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 10 Jan 2003 02:20:06 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: A tar utility written in Perl
Message-Id: <pkent77tea-4C86DC.01363310012003@[10.1.1.10]>

In article 
<Pine.GSO.4.44.0301091620580.3701-100000@rose.man.poznan.pl>,
 Marek Zawadzki <mzawadzk@man.poznan.pl> wrote:

> Is there a stable tar utility written in Perl? (possibly with
> Archive::Tar)
> I need tar with up to 255-characters-long pathnames support, and GNU
> tar doesn't compile there (Cray).
> I do have Perl though...

Have a look at
http://www.perl.com/language/ppt/src/tar/index.html

http://www.zope.org/Members/andym/TarFiles

They might do what you need.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Thu, 9 Jan 2003 20:42:52 -0600
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Activeperl : ppm and GD
Message-Id: <EqqT9.18510$7_.75007@news1.mts.net>

"Bob X" <bobx@linuxmail.org> wrote in
  message news:v9mT9.5026$Fj2.2959901@news2.news.adelphia.net...
[ ... ]
>
> Randy,
>
> Theoryx used to have the Storable.ppd file as well. I didn't notice it
gone
> until I tried to install the PlRPC.ppd and it errored out looking for
> Storable at the Log4perl site. Do you know of another place to find it?
>
> Bob

I just put up a Storable ppm package under
    http://theoryx5.uwinnipeg.ca/ppms/
(for ActivePerl 8xx builds).

best regards,
randy kobes





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

Date: 9 Jan 2003 15:42:35 -0800
From: Andrew.Allaire@na.teleatlas.com (Andrew Allaire)
Subject: ActiveState PerlApp with SWIG dll
Message-Id: <6bdb91de.0301091542.3bc627df@posting.google.com>

After looking for answers via lurking for quite some time, I have
finally signed up to post my latest dilema. If anyone has a quick
answer without troubling yourself to go into great detail...is there
any special trick to building a perlApp application which uses a dll
created with SWIG?


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

Date: Thu, 09 Jan 2003 23:14:01 GMT
From: Javier =?iso-8859-1?Q?P=E9rez?= Montes <j.perez.montes@terra.es>
Subject: EXCEL OLE functions
Message-Id: <3E1E025B.90687DAB@terra.es>

Hi!

First I'm not sure if this question is off topic here.

I need to access with Perl the OLE functions of Excel, I have few
examples but I need a more complete source or manual.

Looking around the net it seems that there is no manual. Exists such
documentacion?

Any help (link) is welcome.

Thanks Javier.


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

Date: Thu, 09 Jan 2003 23:57:57 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: EXCEL OLE functions
Message-Id: <90oT9.39650$1c.5375@nwrddc01.gnilink.net>

Javier Pérez Montes wrote:
> I need to access with Perl the OLE functions of Excel, I have few
> examples but I need a more complete source or manual.

perldoc Win32::OLE

jue




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

Date: Fri, 10 Jan 2003 04:09:25 GMT
From: "mgarrish" <mgarrish@rogers.com>
Subject: Re: EXCEL OLE functions
Message-Id: <VHrT9.280993$F2h1.76047@news01.bloor.is.net.cable.rogers.com>


"Javier Pérez Montes" <j.perez.montes@terra.es> wrote in message
news:3E1E025B.90687DAB@terra.es...

> I need to access with Perl the OLE functions of Excel, I have few
> examples but I need a more complete source or manual.

http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/faq/Windows/A
ctivePerl-Winfaq12.html

It really seems to boil down to your familiarity with OLE objects and
methods, though (if you've done any VBA, that would be a big help). How
comfortable you are with the semantics will determine how easily you can use
the Win32::OLE module to automate tasks with Perl. You might want to try the
ActiveState Perl newsgroups for more information on the subject. I've also
seen some books on OLE automation with Perl, but not having had the pressing
need to use OLE, I couldn't give an opinion on which, if any, would be worth
the money.

Matt




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

Date: Fri, 10 Jan 2003 03:26:08 GMT
From: monkeys paw <fm_duendeBASURA@yahoo.com>
Subject: Re: grep  ==  ??
Message-Id: <k3rT9.304132$qF3.37247@sccrnsc04>

David K. Wall wrote:

> steven farris <sfarris9@insightbb.com> wrote on 09 Jan 2003:
> 
>> I'm porting some code and the following line has me stumped:
>> 
>>     } elsif ( $frequency =~ m!^ON\s+(.+)$!x) {
>>         #ON date [,date ...]
>>         $schedule = 1 if
>>             grep $_ == $sched_rundate, &make_date_list($1);
>> 
>> The make date list function returns an array of
>> date strings.
>> 
>> what's going on in the conditional grep statement?
> 
> It's checking to see if any of the date strings returned by
> make_date_list($1) are numerically equal to $sched_rundate.  grep()
> is in scalar context, so it returns the number of times its condition
> is true.  In case you don't know, $1 is what was returned by the
> capturing parentheses in the regular expression in the elsif
> condition.

  Yes, i am aware of the $1. I guess the source of my confusion
  is why is "$_ == $sched_rundate" in there? Why not just:

  grep $sched_rundate, @dates


> 
> If make_date_list() is returning a list of strings, then the
> comparison operator should be 'eq', not '==', i.e.;
> 
>     $schedule = 1 if
>         grep $_ eq $sched_rundate, make_date_list($1);
> 
> $sched_rundate is also a string, right?
> 
> You probably don't need to call make_date_list() with the & in front
> of it.  See 'perldoc perlsub'.
> 
> If you're porting this then you probably don't need to fix it, but
> there do seem to be some odd things going on.
> 



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

Date: 9 Jan 2003 19:52:21 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: grep  ==  ??
Message-Id: <3e1e4375@news.victoria.tc.ca>

monkeys paw (fm_duendeBASURA@yahoo.com) wrote:
: David K. Wall wrote:

: > steven farris <sfarris9@insightbb.com> wrote on 09 Jan 2003:
: > 
: >> I'm porting some code and the following line has me stumped:
: >> 
: >>     } elsif ( $frequency =~ m!^ON\s+(.+)$!x) {
: >>         #ON date [,date ...]
: >>         $schedule = 1 if
: >>             grep $_ == $sched_rundate, &make_date_list($1);
: >> 
: >> The make date list function returns an array of
: >> date strings.
: >> 
: >> what's going on in the conditional grep statement?
: > 
: > It's checking to see if any of the date strings returned by
: > make_date_list($1) are numerically equal to $sched_rundate.  grep()
: > is in scalar context, so it returns the number of times its condition
: > is true.  In case you don't know, $1 is what was returned by the
: > capturing parentheses in the regular expression in the elsif
: > condition.

:   Yes, i am aware of the $1. I guess the source of my confusion
:   is why is "$_ == $sched_rundate" in there? Why not just:

:   grep $sched_rundate, @dates

Because (relative to the grep) $sched_rundate is a fixed (numeric) value,
where as $_ == $sched_rundate is an expression that gives a variable
(boolean) value for each date.


: > 
: > If make_date_list() is returning a list of strings, then the
: > comparison operator should be 'eq', not '==', i.e.;
: > 
: >     $schedule = 1 if
: >         grep $_ eq $sched_rundate, make_date_list($1);
: > 
: > $sched_rundate is also a string, right?
: > 
: > You probably don't need to call make_date_list() with the & in front
: > of it.  See 'perldoc perlsub'.
: > 
: > If you're porting this then you probably don't need to fix it, but
: > there do seem to be some odd things going on.
: > 


--


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

Date: Thu, 9 Jan 2003 22:09:51 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: grep  ==  ??
Message-Id: <slrnb1shsf.r7c.tadmc@magna.augustmail.com>

monkeys paw <fm_duendeBASURA@yahoo.com> wrote:
> David K. Wall wrote:
>> steven farris <sfarris9@insightbb.com> wrote on 09 Jan 2003:
>> 
>>> I'm porting some code and the following line has me stumped:
>>> 

>>>         $schedule = 1 if
>>>             grep $_ == $sched_rundate, &make_date_list($1);

>>> what's going on in the conditional grep statement?
>> 
>> It's checking to see if any of the date strings returned by
>> make_date_list($1) are numerically equal to $sched_rundate.

>   I guess the source of my confusion
>   is why is "$_ == $sched_rundate" in there? Why not just:
> 
>   grep $sched_rundate, @dates


Because then it would be testing for some other condition.  :-)

It would be testing if any of the list elements are "true",
rather than if they are equal to some particular value.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 9 Jan 2003 15:43:12 -0800
From: jjulian_97@yahoo.com (Joe)
Subject: Re: How am I using sort wrong?
Message-Id: <88a42151.0301091543.488f2a50@posting.google.com>

Ryan Shondell <shondell@cis.ohio-state.edu> wrote in message news:<xcw65sykwqn.fsf@psi.cis.ohio-state.edu>...
> jjulian_97@yahoo.com (Joe) writes:
> 
> > This seems like it should work according to the FM (this is the entire
> > script, I'm just trying to see how sort works - I'm still a newb):
> > 
> > @cdata = (5, -10, 3, 12, -2, -14, 16, -16);
> > @cdata = sort ($a <=> $b) @cdata;
>                 ^         ^
> You want {} instead of ()...
> 
> @cdata = sort {$a <=> $b} @cdata;
> 
> Check out perldoc -f sort for more info.

Damn notebook screens... :) Misread the docs. Thanks


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

Date: Thu, 09 Jan 2003 20:31:22 -0800
From: Steve Slaven <junk_nntp@hoopajoo.net>
Subject: Re: Net::Ping issue
Message-Id: <v1sj4r67mb7522@corp.supernews.com>

Sunil wrote:
>>>Is there any way I can have a common script which runs on both
>>>windows and unix and checks successfully for hosts on both
>>>unix and windows.
>>
>>Here is one way:
>>if ($^O =~ /win/i)
>>   { print "OS is Windows of some sort:$^O\n"; }
>>elsif ($^O =~ /x$/i)
>>   { print "OS Unix type:$^O\n"; }
>>else
>>   { print "OS is neither Windows nor Unix:$^O\n"; }
> 
> 
> 
> This does not help as the onky way i am able to ping windows hosts from my
> unix box is to use "icmp"
> 
> How can I check for the existance od a NT host from a unix host without
> using "icmp"
> 
> 
> Thanks,
> Sunil.
> 
> 
> 
While pretty cludgy, you could try something like:

my $pingok = 0;
my $host = 'something.com';
if ($^O =~ /win/i)
    { $pingok = `ping -n 1 $host` =~ /Received = 1/ ? 1 : 0; }
elsif ($^O =~ /x$/i)
    { $pingok = `ping -c 1 $host` =~ /1 packets received/ ? 1 : 0; }
else
    { print "OS is neither Windows nor Unix:$^O\n"; }

Of course it will break if your ping tools don't give the expected 
output, but you could get fancier using a hash to identify platforms and 
match strings like:

my %mstring = (
	linux => {
		cmd => 'ping -c 1 %s',
		match => '1 packets received'
	},
	windows => {
		cmd => 'ping -n 1 %s',
		match => 'Received = 1'
	}
);
my $execstr = sprintf( $mstring{ $^O } -> { cmd }, 'somewhere.com' );
my $matchstr = $mstring{ $^O } -> { match };
my $pingok = `$execstr` =~ /\Q$mstring\E/;

Like I said, cludgy though, and not tested.

-- 
+----------------------------------------------------------------------------+
;; It appears that /dev/null is a conforming XSL processor
+----------------------------------------------------------------------------+
Steve Slaven - http://hoopajoo.net
MIS Programmer, Horizon Distribution - http://horizondistribution.com
Office: (509) 453-3181 x 254 / Fax: (509) 457-5769



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

Date: 9 Jan 2003 17:21:58 -0800
From: vanikandoori@yahoo.com (reddy)
Subject: parsing xml with perl --- very urgent .. help please
Message-Id: <6cd469c.0301091721.11f2c2d2@posting.google.com>

iam trying to parse a xml file. But the data between the tags does not
come up completely . let me explain clearing
I take the body of an email which is in a xml file format and put that
into a file addingteh start tag and end tag
say the email body has this
<firstname>xyz</firstname>
<lastname>pppp</lastname>
<occupation>lkllklk</occupation>
<address>1234 dexon street
apt no :3333
sunnyvale, ca -95051</address>
I took the body into a file adding the starttag and endtag
and the file look like this
<info>
<firstname>xyz</firstname>
<lastname>pppp</lastname>
<occupation>lkllklk</occupation>
<address>1234 dexon street
apt no :3333
sunnyvale, ca -95051</address>
</info>
now iam paring to get the content between the tags.The last tag which
has multiple lines does not show up properly .. mean iam geting only
the first line.. other lines r missing
the code is:
my $filename = $key->config_var("temp_xml");
    #my $filename = "/home/httpd/html/key74/perl/tempxml.xml";
    open (FILE,">$filename") || "Can't creat $filename; $!";
    # my $xmlheader = "<?xml version="1.0"?>";
    my $starttag = "<email_body>";
    my $endtag = "</email_body>";
    my @data_file = @{$mail->body};
    open(DAT,">$filename") || die("Could not open file!");
    print DAT "$starttag\n@data_file$endtag\n"; 
    close(DAT);
    # initialize the parser
    my $parser = XML::Parser->new( Handlers => 
    {                          
    Char  => \&char_handler      });
    $parser->parsefile($filename);
    my @data_stack;
    sub char_handler
     { 
     	 my ($p, $data) = @_;
         #$data =~ s/\n|\t//g;
         push(@data_stack, { data=>$data });
      
     }
     my @stackdata;
     foreach my $d (@data_stack)
     {
    	push(@stackdata,"$$d{ data }");
     }
     my $k=0;
     my @stackdata1;
     for(my $i=0;$i<@stackdata;$i++) {
        #$stackdata[$i]=~ s/\n|\t//g;
        #chomp $stackdata[$i];
        #$stackdata[$i] =~ tr/\n\t//d;
        if(length($stackdata[$i]) > 1 ){
        push(@stackdata1,"$stackdata[$i]");
        $k++;
        }
     }
     my $fname = $stackdata1[0];
     my $lname = $stackdata1[1];
     my $ocp = $stackdata1[2];
     my $add = $stackdata1[3];
when i print the $add i get only the first line. i tried to eliminate
teh \n's and \t's then it works fine but all the data is in a single
line. But i don't want it that way i want to the output as i entered
with the new line etc.like
when i print $add it should be like this
1234 dexon street
apt no :3333
sunnyvale, ca -95051.
can anyone help me with this. 
thanks.


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

Date: Thu, 9 Jan 2003 21:47:15 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: parsing xml with perl --- very urgent .. help please
Message-Id: <slrnb1sgi3.qvp.tadmc@magna.augustmail.com>

reddy <vanikandoori@yahoo.com> wrote:

> iam trying to parse a xml file. But the data between the tags does not
> come up completely .


> and the file look like this
><info>
><firstname>xyz</firstname>
><lastname>pppp</lastname>
><occupation>lkllklk</occupation>
><address>1234 dexon street
> apt no :3333
> sunnyvale, ca -95051</address>
></info>


> now iam paring to get the content between the tags.The last tag which
> has multiple lines does not show up properly .. mean iam geting only
> the first line.. other lines r missing



> the code is:


What on earth are you doing in this code?


>     open (FILE,">$filename") || "Can't creat $filename; $!";


What is that open() for?

You never use the FILE filehandle.


>     # initialize the parser
>     my $parser = XML::Parser->new( Handlers => 



There is almost always a better way than using XML::Parser nowadays.

With data as simple as yours, there is a much much better way...


>     {                          
>     Char  => \&char_handler      });
>     $parser->parsefile($filename);
>     my @data_stack;
>     sub char_handler
>      { 
>      	 my ($p, $data) = @_;
>          #$data =~ s/\n|\t//g;
>          push(@data_stack, { data=>$data });
>       
>      }


If you have a look at the contents of the data structure that
you've built at this point, you'll see that everything you
need is in there somewhere:

   use Data::Dumper;
   print Dumper(\@data_stack), "\n";

Just write code to get it out.


>      my @stackdata;
>      foreach my $d (@data_stack)
>      {
>     	push(@stackdata,"$$d{ data }");
>      }
>      my $k=0;
>      my @stackdata1;
>      for(my $i=0;$i<@stackdata;$i++) {
>         #$stackdata[$i]=~ s/\n|\t//g;
>         #chomp $stackdata[$i];
>         #$stackdata[$i] =~ tr/\n\t//d;
>         if(length($stackdata[$i]) > 1 ){
>         push(@stackdata1,"$stackdata[$i]");
>         $k++;
>         }
>      }


I have no idea what that code is supposed to be doing.

I think you wrote one loop to make hash refs, and another
loop to dereference them.

What for? Why not just save the string data straightaway?


>      my $fname = $stackdata1[0];
>      my $lname = $stackdata1[1];
>      my $ocp = $stackdata1[2];
>      my $add = $stackdata1[3];
> when i print the $add i get only the first line. 


The other lines are in $stackdata1[4], $stackdata1[5]...


> i want to the output as i entered
> with the new line etc.like
> when i print $add it should be like this
> 1234 dexon street
> apt no :3333
> sunnyvale, ca -95051.


You cannot use XML::Parser like that.

There may be _many_ calls to char_handler() while inside
the _same_ element.

In the ridiculous extreme, it would be perfectly legal for
XML::Parser to call the char_handler() with one character
at a time.

You should stick the chars in a buffer in char_handler(),
and then get the chars out of the buffer when you encounter
the end tag for the containing element.

-------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use XML::Parser;

my $xml = '<info>
<firstname>xyz</firstname>
<lastname>pppp</lastname>
<occupation>lkllklk</occupation>
<address>1234 dexon street
apt no :3333
sunnyvale, ca -95051</address>
</info>
';

my $parser = XML::Parser->new( Handlers => { Char => \&char_handler,
                                             Start  => \&start_handler,
                                             End  => \&end_handler,
                                           });
my %data;
$parser->parse($xml);
my $add = $data{address};
print "($add)\n";

my $chars;
sub char_handler { $chars .= $_[1] }
sub start_handler { $chars = '' }

sub end_handler {
   $data{$_[1]} = $chars;
   $chars = '';
}
-------------------------------


But why do in 15 lines what can be done in 3 lines?


-------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use XML::Simple;

my $xml = '<info>
<firstname>xyz</firstname>
<lastname>pppp</lastname>
<occupation>lkllklk</occupation>
<address>1234 dexon street
apt no :3333
sunnyvale, ca -95051</address>
</info>
';

my $ref = XMLin( $xml );
my $add = $ref->{address};
print "($add)\n";
-------------------------------


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 9 Jan 2003 23:03:46 +0000 (UTC)
From: luc wastiaux <luc@nospam.com>
Subject: Server sockets
Message-Id: <slrnb1s024.sh5.luc@grizzly.dont-panic.info>

I want to write a perl NNTP server (for a special application), but I have
nver done any network programming with perl, where could I find a
comparison of the different methods for using sockets in perl? (Socket,
IO::Socket, IO::Select) ?

-- 
luc wastiaux
$> finger luc@info.4002.org


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

Date: Thu, 09 Jan 2003 20:14:13 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Server sockets
Message-Id: <3E1E1E65.5080801@thecouch.homeip.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1



luc wastiaux wrote:
| I want to write a perl NNTP server (for a special application), but I have
| nver done any network programming with perl, where could I find a
| comparison of the different methods for using sockets in perl? (Socket,
| IO::Socket, IO::Select) ?
|

IO::Socket and IO::Select are pretty low-level.  I don't think you need
to venture that far down the complexity chain, especially if you're new
at network programming.

Take a look at pre-existing modules to help you concentrate on the NNTP
protocol rather than the transport:

http://search.cpan.org/search?query=nntp&mode=all

http://search.cpan.org/search?query=daemon&mode=all

Best of luck.

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+Hh5leS99pGMif6wRAqGZAKD2NyDFHaWBSX/XcXNDUnojnYEyUgCgpND8
RYp4X/SQmazW2kVmD4F8rdU=
=r+y7
-----END PGP SIGNATURE-----



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

Date: Fri, 10 Jan 2003 02:31:06 GMT
From: Tom Hamilton <sg7188@snet.net>
Subject: Re: silly question -- please help!
Message-Id: <KfqT9.9333$9E3.2476302374@newssvr10.news.prodigy.com>

tom wrote:

> Hi,
> 
> I have lots of files with the following structure:
> 
> Wnt8  Krl     SoxB1   Krox    Otx     Eve
> -0.069        0.028   -0.025  -0.011  0.0171  -0.022
> -0.066        -0.011  -0.035  0.002   -0.001  0.007
> -0.064        0.0171  -0.040  0.030   0.025   0.009
> etc...
> 
> and I need to convert each one to the following format for use with
> somebody else's program:
> 
> Wnt8 -0.069
> Krl 0.028
> SoxB1 -0.025
> Krox -0.011
> Otx 0.017
> Eve -0.022
> Wnt8 -0.066
> Krl -0.011
> SoxB1 -0.035
> Krox 0.002
> Otx -0.001
> Eve 0.007
> etc...
> 
> Any ideas on how to do this in Perl? I'm drawing a big blank.. I'd
> really appreciate it!!! Thank you!!
> 
> Sincerely,
> 
> Tom


The Perl Cookbook is a wise investment.


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

Date: Thu, 9 Jan 2003 21:48:16 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: silly question -- please help!
Message-Id: <slrnb1sgk0.qvp.tadmc@magna.augustmail.com>

tom <theiman@comcast.net> wrote:

> Subject: silly question -- please help!


Please put the subject of your article in the Subject of your article.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 10 Jan 2003 01:34:19 GMT
From: "Mats" <mats.svensson2@telia.com>
Subject: stucked
Message-Id: <20030110.023434.213975407.1898@telia.com>

Hi

I'm building a threaded messageboard with perl and mysql but I can't come
up with an algoritm for threading the messages, I have looked over the
net to find something that could lead me in the right direction but can't
find anything. Isn't this a common task in cgi-programming? 

 ...the positive thing is that I have learned a _lot_ about hashes...

/Mats


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

Date: Fri, 10 Jan 2003 02:12:24 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: stucked
Message-Id: <slrnb1sb08.opk.mgjv@verbruggen.comdyn.com.au>

On Fri, 10 Jan 2003 01:34:19 GMT,
	Mats <mats.svensson2@telia.com> wrote:
> Hi
> 
> I'm building a threaded messageboard with perl and mysql but I can't come
> up with an algoritm for threading the messages, I have looked over the
> net to find something that could lead me in the right direction but can't
> find anything. Isn't this a common task in cgi-programming? 

Normally what you would do is make sure that each message has a unique
id, and that each followup refers to at least the message it follow up
to, and possibly to its parents as well.

This is for example how Usenet works.

Of course, this really has nothing to do with Perl at all, since the
question and the answer would have been the same if you were writing
in C, java or befunge.

Martien
-- 
                        | 
Martien Verbruggen      | Never hire a poor lawyer. Never buy from a
Trading Post Australia  | rich salesperson.
                        | 


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

Date: 10 Jan 2003 01:57:11 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Unix Vars declared in system() call -> %ENV
Message-Id: <slrnb1sa3n.702.sholden@flexal.cs.usyd.edu.au>

On Thu, 09 Jan 2003 17:32:56 -0500,
	Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> Christopher Hamel wrote:
>> 
>> Perhaps this is easy; perhaps it's impossible.
>> 
>> Within a Perl program, I have a desire to launch a Unix Korn shell
>> script that exports a number of variables.  A snippet of the program
>> looks as follows:
>> 
>>   if [[ $HOST = "0xae026c0" ]] ; then
>>     export SERVER=test21
>>   else [[ $HOST = "0xae02647" ]] ; then
>>     export SERVER=prod21
>>   fi
>> 
>>   export FP_DIR=/i2/$ENVIRONMENT/fp
>> 
>> (pretty basic stuff)
>> 
>> Is there any way to launch this program within Perl and have the
>> variable declarations within the program update %ENV?
> 
> Sure:
>    open SHELL_SCRIPT, "-|", '. my_unix_script >/dev/null; env'
>       or die "Couldn't start shell script: $!";
>    my $lastkey = "";
>    while( my $keyvalue = <SHELL_SCRIPT> ) {
>       chomp($keyvalue);
>       my ($key, $value) = split /=/, $keyvalue, 2;
>       if( defined($value) ) {
>          $ENV{$lastkey = $key} = $value;
>       } else {
>          $ENV{$lastkey} .= "\n" . $key;
>       }
>    }
>    close SHELL_SCRIPT
>       or die "Error running shell script: \$? == $?\n";

Of course that will get it wrong if the script did something really aweful like:

foo='howdy
bar=baz'
export foo

But of course that's just silly :)

-- 
Sam Holden



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

Date: Fri, 10 Jan 2003 01:19:55 GMT
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: What is a simple way to read and write zip files?
Message-Id: <%cpT9.628630$P31.240550@rwcrnsc53>

Thanks.

I've looked at it. (And downloaded it and been exerpimenting w/ it.) It's 
VERY poorly documented.  There are examples, but they leave a lot of holes 
for someone who doesn't know whatever C or C++ library this is accessing.  
It is also strongly OO, and it uses other IO modules which, to many, might 
be easy to understand, but to someone still trying to learn OO and IO, it 
is very hard to follow.

I was hoping to find something with straightforward where I could do 
something like using a simple read or write function.

Hal

Benjamin Goldberg wrote:

> Hal Vaughan wrote:
>> 
>> I am working with something that is close to an odd mailmerge.  I need
>> to open a file, modify it, then close it.  The only problem is the
>> files I have to modify are OpenOffice.org files, which are compressed
>> zip files and contain more than one file.
>> 
>> I don't want to mess with temp files, since I have to read in a master
>> file and produce a very large number of files from it.  The easiest
>> thing for me to do would be to read the entire file into a scalar and
>> then uncompress it (or read it directly to an uncompressed scalar),
>> make my changes to the content, then re-compress it and write it back
>> out to a new file.
> 
> Look into Archive::ZIP, on CPAN.
> 



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

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.  

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 V10 Issue 4375
***************************************


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