[10308] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3903 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 6 12:07:25 1998

Date: Tue, 6 Oct 98 09:02:47 -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           Tue, 6 Oct 1998     Volume: 8 Number: 3903

Today's topics:
        rcp problem <tim.schelfhout@telenet.be>
    Re: rcp problem <lbenfie1@s_p_a_m.ford.com>
    Re: read subdirectories (Pete Ratzlaff)
    Re: read subdirectories <jdf@pobox.com>
    Re: read subdirectories <jdporter@min.net>
    Re: RFC: "Build'n'Play" installation tool <jimbo@soundimages.co.uk>
    Re: scope question (Pete Ratzlaff)
        Scripts on CPAN are live! kstar@isinet.com
        Set::Scalar 0.004 released <jhi@alpha.hut.fi>
    Re: sort question? <jdporter@min.net>
    Re: Split question - retain the pattern? (Bart Lateur)
    Re: Split question - retain the pattern? <jdporter@min.net>
        Text::FillIn 0.04 ken@forum.swarthmore.edu
        Trying to transform string into array with split??? <brettr@centuryinter.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 6 Oct 1998 13:43:58 GMT
From: "Schelfhout T" <tim.schelfhout@telenet.be>
Subject: rcp problem
Message-Id: <01bdf12f$1973ac50$c236000a@tl000549>

Hi there,

I'm fairly new at perl and experiencing a problem which I can't resolve :

The question is that I need to do a remote copy with arguments that need to
be substituted by the shell.  That is :
rcp abc:/export/home/test/$((`date +%y%m%d`-1)) /export/home/`date +%y%m%d`
First question : Is it possible ? (which I'm sure it is)
Second question : how do i go about it ?(of course)

I tried the following:

$LOGDIR=/export/home/test
$LOCAL=/apps/test
system ("rcp  abc\:$LOGDIR $LOCAL");

Any ideas ? comments are wellcome

Thanks


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

Date: Tue, 06 Oct 1998 15:10:43 +0100
From: Lee Benfield <lbenfie1@s_p_a_m.ford.com>
Subject: Re: rcp problem
Message-Id: <361A24E3.4C35@s_p_a_m.ford.com>

Schelfhout T wrote:
> 
> Hi there,

Hi. *8)

> The question is that I need to do a remote copy with arguments that 
> need to be substituted by the shell. 

Err, when you say shell, do you mean script, or environment?

If it's the environment, don't force bash to put them in, do it
yourself by looking at the %ENV hash.

> Second question : how do i go about it ?(of course)
> 
> I tried the following:
> 
> $LOGDIR=/export/home/test
> $LOCAL=/apps/test
> system ("rcp  abc\:$LOGDIR $LOCAL");

Hope this isn't *too* much of a newbie answer, but you might try
constructing the entire string for the system call first, so you
can print it to stderr before you system() it...

ie.

my $LOGDIR="/export/home/test";
my $LOCAL="/apps/test";
my $syscall = "rcp abc:$LOGDIR $LOCAL";
print STDERR "$syscall\n";
system ($syscall);

unless I forget the syntax for rcp (which is likely and I can't check
from here) you shouldn't need a \ preceeding the :  (?)

Hope that helps.

Lee.


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Lee A Benfield, Ford Motor Co. | The above are my opinions alone.
                               | I couldn't afford better ones...


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

Date: 5 Oct 98 16:16:56 GMT
From: rpete@ascda3.harvard.edu (Pete Ratzlaff)
Subject: Re: read subdirectories
Message-Id: <3618f0f8.0@cfanews.harvard.edu>

Richard Ahier (richarda@profil-cdi.qc.ca) wrote:
> Hi,

> I try since a week to make a recursive script who read a directory and all
> his subdirectories.
> I just need directories not files.
> Does somebody have a script to suggest.

Here's one I wrote up in a hurry which recursively prints all
subdirectories of a given directory. Modify to suit your own needs:

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

my $DIR = @ARGV ? shift : '.';
$DIR =~ s/\/$//; # remove trailing slashes
print "Subdirectories of '$DIR':\n";
print_subs($DIR);

#
# print subdirectories of a directory
#
sub print_subs {
	my $dir = shift;
	opendir(DIR,$dir) or do {
		warn "Could not open directory '$dir': $!\n";
		return;
	};
	my @files = readdir(DIR);
	closedir DIR;

	foreach (@files) {
		$_ = $dir .'/'.$_;
		(-d $_) and do {
			/\/\.{1,2}$/ and next; # '.' and '..' don't count
			print "$_\n";
			print_subs($_);
		};
	}

}

-------------
Peter Ratzlaff                    Harvard-Smithsonian Center for Astrophysics
Office B102                       60 Garden St, MS 21, Cambridge MA 02138 USA
<pratzlaff@cfa.harvard.edu>       phone: 617 496 7714


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

Date: 06 Oct 1998 15:36:19 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: "Richard Ahier" <richarda@profil-cdi.qc.ca>
Subject: Re: read subdirectories
Message-Id: <m3r9wl95ik.fsf@joshua.panix.com>

"Richard Ahier" <richarda@profil-cdi.qc.ca> writes:

> I try since a week to make a recursive script who read a directory
> and all his subdirectories.
> I just need directories not files.

Do not write your own. Do not use the other hand-rolled solutions that 
have appeared in this thread. Use the module that's built for the
task.

  use File::Find;
  my @dirs = ();
  find(
       sub {-d && push @dirs, $File::Find::name}, 
       '/usr/local'
      );



-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 06 Oct 1998 10:30:46 -0400
From: John Porter <jdporter@min.net>
Subject: Re: read subdirectories
Message-Id: <361A2996.F0E5DE67@min.net>

Pete Ratzlaff wrote:
> 
> Here's one I wrote up in a hurry which recursively prints all
> subdirectories of a given directory. Modify to suit your own needs:

I sure do wonder what people have against using standard, robust,
portable modules like File::Find.

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: 06 Oct 1998 15:58:14 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: RFC: "Build'n'Play" installation tool
Message-Id: <ulnmt20vt.fsf@jimbosntserver.soundimages.co.uk>

Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> writes:

> 
> For a woman of my obvious distinction I doubt that I could use such a
> product as it has a certain taint to it. What about "Pop 'n' Go"? as in
> "Pop that sucker in cd n gooo baby gooo. Or "Mount 'n' Go"? Mount that
> puppy and go to town...*mwwhaahaahaa* but I digress....
>  

Okay, okay. You win. But I still think you are perverted. Maybe not a
pervert, the jury is still out. But certainly perverted.

Love always.
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


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

Date: 6 Oct 98 15:20:52 GMT
From: rpete@ascda3.harvard.edu (Pete Ratzlaff)
Subject: Re: scope question
Message-Id: <361a3554.0@cfanews.harvard.edu>

Ian Lowe (Ian_Lowe@fanniemae.com) wrote:

> open(DF,"/usr/ucb/df -Fufs | grep -v Filesystem |");
>     while (<DF>) {
>        chop;
>        ($size,$capacity) = (split(/\s+/))[1,4];
>         $size = "$size" / 1000;
>         %FSSIZE = ("$size","$capacity");
> }

> foreach $key (keys (%FSSIZE)) {
>     print "at $key we have $FSSIZE{$key}\n";
> }

> This will NOT print out the hash keys and value correctly.  However, if
> I nest the foreach loop within the while loop, it does.  Why is this? 
> Do I need to predeclare the variables as globals somehow?  If so, how?

You are probably not seeing the output you expect because of the strange
way you're reseting %FSSIZE each time through the while (<DF>) loop.
It is hard to tell what you wanted the hash keys to be in this case,
but as it stands the key will be $size and the value will be $capacity.

Cheers,
-Pete Ratzlaff <pratzlaff@cfa.harvard.edu>


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

Date: 6 Oct 1998 15:29:19 GMT
From: kstar@isinet.com
Subject: Scripts on CPAN are live!
Message-Id: <6vdd0f$cvv$1@news.neta.com>

By popular demand, developers can now upload scripts to CPAN!  Scripts
can be browsed alphabetically, and by author-assigned categories.

Information on using this feature is available from Comprehensive Perl
Archive Network (CPAN) sites worldwide.  To select from a list of sites,
go to:

    http://www.perl.com/CPAN

Note the absence of a trailing `/'.  The browsable scripts repository
can be found at:

    http://www.perl.com/CPAN/scripts/index.html

Instructions for uploading your script can be found at:

    http://www.perl.com/CPAN/scripts/new/submitting.html

Special thanks to Andreas Koenig (a.koenig@franz.ww.tu-berlin.de),
Jarkko Hietaniemi (jhi@iki.fi), Nathan Torkington (gnat@frii.com),
and The Perl Institute (http://www.perl.org/) for their support
in making this service available.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum




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

Date: 6 Oct 1998 15:20:45 GMT
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Set::Scalar 0.004 released
Message-Id: <6vdcgd$bc0$1@news.neta.com>


This release is just a minor maintenance release to the 'Classic'
0.003 release.  Nothing has changed in functionality.  The only
changes are in installation (this should install easier than the 0.003)
and in coping with less warnings with more recent releases Perl
(the 0.003 was born when perl 5.002 and dinosaurs ruled the earth).

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen




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

Date: Tue, 06 Oct 1998 10:21:42 -0400
From: John Porter <jdporter@min.net>
Subject: Re: sort question?
Message-Id: <361A2776.57C1F48C@min.net>

Brand Hilton wrote:
> 
>   print sort {substr($a,-2,1) cmp substr($b,-2,1) || $a cmp $b} <>;

That's wrong, those should be substr($a,-1) and substr($b,-1).

Anyway, here's a faster one, by over 4x:

@outputs =
map { substr($_,1) }
sort
map { substr($_,-1) . $_ }
@inputs;

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Tue, 06 Oct 1998 13:53:40 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Split question - retain the pattern?
Message-Id: <361a1fde.23649826@news.ping.be>

Bart Lateur wrote:

>Something like this might work (untested); if it doesn't, it should at
>least serve as an inspiration.
>
>	@sentences = /(.*?[?.])\s+/g;

It doesn't work. Two reasons:

 1) it doesn't accept newlines for ".". Either replace them by spaces
first, or use the //s modifier.
 2) It drops the finale sentence.

This one kinda works:

	@sentence = $text =~ /(.*?[?.]\s+|.+)/sg;

except that it now doesn't drop the line ending spaces.

I sincerely dislike this about Perl: a simple version of anything will
almost certainly contain some horrible bugs. 

	Bart.


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

Date: Tue, 06 Oct 1998 10:29:21 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Split question - retain the pattern?
Message-Id: <361A2941.55C956FA@min.net>

Bart Lateur wrote:
> 
> This one kinda works:
> 
>    @sentence = $text =~ /(.*?[?.]\s+|.+)/sg;
> 
> except that it now doesn't drop the line ending spaces.

This one works.
It doesn't attempt to remove the line-ending whitespaces;
and it loses any text after the last dot/bang/hook.

@sentences = /(.*?[.!?](?:\s+|$))/gs;

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: 6 Oct 1998 15:24:23 GMT
From: ken@forum.swarthmore.edu
Subject: Text::FillIn 0.04
Message-Id: <6vdcn7$ccm$1@news.neta.com>

Hi,

The URL

    http://forum.swarthmore.edu/~ken/modules/archive/Text-FillIn-0.04.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/KWILLIAMS/Text-FillIn-0.04.tar.gz
  size: 10012 bytes
   md5: 958607d303437f4653592e421238b5ae


CHANGES:
0.03  Thu Oct  1 20:46    EDT 1998
   There are Significant Changes In The Interface.
   - The default delimiters, hooks, and path now have accessor functions.
   - One can now set the delimiters, hooks, and path for an instance of
     a template without affecting the default, or other templates.
     This is achieved by letting these facts be object data rather than
     just package variables.
   - Because of the above change, code which uses this module cannot
     change the delimiters, hooks, or path by assigning to variables in
     the Text::FillIn package anymore.
   - The get_text() and set_text() methods are now deprecated, use the
     text() method instead, which takes an optional argument for setting
     the text.  The deprecated methods will be removed in a future version.
   - Same goes for get_property() and set_property().  Use property() now.
   - Fixed a bug in the interpret engine - a '2' was hard-coded which
     should have been length(right delimiter).
   - Hook functions now take the hook character as a second argument, making
     it possible for one function to handle several kinds of hooks.

   Thanks to Jesse Chisholm for most of these suggestions.

0.04  Sun Oct  4 00:22:55 CDT 1998
   - Added support for using another object's method calls as interpretation
     hooks.  Potentially powerful feature suggested by Jesse Chisolm.
   - Please note that the get_text(), set_text(), get_property(), and
     set_property() methods will go away in version 0.05.  Migrate
     to text() and property().


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

Date: Tue, 6 Oct 1998 08:27:26 -0500
From: "brettr" <brettr@centuryinter.net>
Subject: Trying to transform string into array with split???
Message-Id: <6vd635$l1d$2@newsread1-mx.centuryinter.net>

I'm reading information in from a file. The script extracts this information
which is mainly environment variables. The entire script logs banner clicks.
What I'm trying to do with this particular piece of code is read in just the
date from the last record. I've already read the data into @filein. The
records are separated by a <P>.  However, I can't get just that first line
of the last record to read in. Data from the file is below the code. Here's
the code:

$line_c = 0;
print "filein = @filein";
foreach $line (@filein){
$hold = $line_c++;
print "$hold";
}
print "<br>line_c = $hold<br>";
print "filein = @filein[$hold]<br>";
print "holdit = $hold<br>";

@filein[$hold] =~ s/\<P>$//g;
print "fileinbfarrayw = @filein[$hold]<br>";

@filein[$hold] = split(/<BR>/);
print "fileinafarray = @filein[$hold]<br>";
#$pushed = push(@filein, " ");
#print "pushed = $pushed<br>";
print "filearray = @filein[1]";

This is data from the file:

10/06/98 01:13:27 CDT<BR>  Remote Host: ppp078.iw.centuryinter.net<BR>
Remote Addr: 209.162.161.92<BR>  From: http://www.url.com/temp.html<BR>
With: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)<P>
10/06/98 06:41:13 CDT<BR>  Remote Host: ppp121.iw.centuryinter.net<BR>
Remote Addr: 209.162.162.135<BR>  From: http://www.url.com/temp.html<BR>
With: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)<P>

You can see there is only 2 records in the file. I'm trying to get the
latest date which would be in the last record - 10/06/98 06:41:13 CDT.

Also, how would I transform the date into something formatted like this -
Tuesday October 6, 1998?




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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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