[23066] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5287 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 29 11:05:42 2003

Date: Tue, 29 Jul 2003 08:05:08 -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           Tue, 29 Jul 2003     Volume: 10 Number: 5287

Today's topics:
        Anyone build the Berkeley DBXML library for AS and Wind (Bob)
        Calculate directorysize from a list? (Math55)
    Re: Calculate directorysize from a list? <g4rry_sh0rt@zw4llet.com>
    Re: Currying functions <qrczak@knm.org.pl>
    Re: Getting the size of files from a list? (Math55)
    Re: Help needed on mkdir <abigail@abigail.nl>
    Re: How do you Call a Perl subroutine with a variable n (Tad McClellan)
    Re: How do you Call a Perl subroutine with a variable n <uri@stemsystems.com>
    Re: New to Perl - getting error <rpl-erroroneous@goldengate.net>
    Re: New to Perl - getting error <rpl-erroroneous@goldengate.net>
    Re: New to Perl (Tad McClellan)
    Re: New to Perl <asu1@c-o-r-n-e-l-l.edu>
    Re: New to Perl <g4rry_sh0rt@zw4llet.com>
    Re: Perl variable data "replacement" <usenet@expires082003.tinita.de>
    Re: porting perl scripts from NT to UNIX <kalinabears@iinet.net.au>
        remote readdir() (ARod)
    Re: remote readdir() <usenet@expires082003.tinita.de>
    Re: remote readdir() <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: remote readdir() <jurgenex@hotmail.com>
    Re: remote readdir() <abigail@abigail.nl>
    Re: remote readdir() <g4rry_sh0rt@zw4llet.com>
    Re: Result from a regex substitute <no_thanks@bms.umist.ac.uk>
        Sorting out sort (Peter Stokes)
    Re: var within reg expression news@roaima.freeserve.co.uk
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 29 Jul 2003 07:51:26 -0700
From: bobx@linuxmail.org (Bob)
Subject: Anyone build the Berkeley DBXML library for AS and Windows?
Message-Id: <1001ff04.0307290651.a57c8b4@posting.google.com>

I am on Windows and do not have a compiler. Had anyone compiled the
Berkeley DBXML library for Windows? I would like to try out DBXML.

Bob


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

Date: 29 Jul 2003 06:38:04 -0700
From: magelord@t-online.de (Math55)
Subject: Calculate directorysize from a list?
Message-Id: <a2b8188a.0307290538.afed4df@posting.google.com>

hi, i have the follwoing list. 


----

528k	/tmp/icons/4599-OS-X-GamePak.tar.gz
244k	/tmp/icons/4780-OS-Logos.tar.gz
744k	/tmp/icons/5042-XP-iCandy2.zip
123k    /tmp/icons/test/hallo.txt
456k    /tmp/icons/test/hallo1.doc


----

how can i calculate the size of the directories so the parent
directory has the size of all childdirs?


this is what i want:

/tmp/icons=2095
/tmo/icons/test=579

the problem is i do not know how many dirs i am reading from the file.
this is what i have so far. this will only get the size from the files
within a directory but it does not add childdirectories to the total
size of the parent.


---
sub main {

        
        my $args = $_[0];

        my %size;

        if ( $whichFile eq "AGELIST" ) {
            open DATA, "</tmp/mpf$$/AGELIST.mpf"
              or die "Couldn't open all: $!\n";
        }
        else {
            open DATA, "</tmp/mpf$$/FILTEREDLIST.mpf"
              or die "Couldn't open all: $!\n";
        }

        my @files = <DATA>;

        for (@files) {
            chomp;
            my ( $size, $path ) = split;

            my $bytes = toBytes $size;
            my $dir   = dirname $path;
            $size{$dir} += $bytes;
        }

        for (@files) {
            chomp;
            my ( $size, $path ) = split;

            next unless exists $size{$path};

            my $dir   = dirname $path;
            my $bytes = toBytes $size;
            $size{$dir} -= $bytes;
        }

#den berechneten Wert fuer die Ausgabe zurueckgeben (mit Klammern oder
ohne)
        if ( toUnit( $size{$args} ) eq "" ) {
            return ( toUnit( $size{$args} ) );
        }
        else {
            return "[" . ( toUnit( $size{$args} ) ) . "]";
        }
    }    # Ende von main
---

---
sub toBytes {
        my $size = shift;

        if ( $size =~ tr/k$//d ) {
            $size *= 1024;
        }
        elsif ( $size =~ tr/M$//d ) {
            $size *= 1024 * 1024;
        }

        $size;
    }    #Ende von toBytes

sub toUnit {

        my $size = shift;

        if ( $size > 1024 * 1000 ) {

            $size = sprintf "%.1f M", $size / ( 1024 * 1024 );

        }
        elsif ( $size > 1024 ) {

            $size = sprintf "%.1f k", $size / 1024;

        }

        $size;
    }    #Ende von toUnit

---


i am calling the main method like that:


main(/var/log)


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

Date: Tue, 29 Jul 2003 15:14:58 +0000
From: Garry Short <g4rry_sh0rt@zw4llet.com>
Subject: Re: Calculate directorysize from a list?
Message-Id: <bg5vmt$mo4$1$8300dec7@news.demon.co.uk>

Math55 wrote:

> hi, i have the follwoing list.
> 
> 
> ----
> 
> 528k  /tmp/icons/4599-OS-X-GamePak.tar.gz
> 244k  /tmp/icons/4780-OS-Logos.tar.gz
> 744k  /tmp/icons/5042-XP-iCandy2.zip
> 123k    /tmp/icons/test/hallo.txt
> 456k    /tmp/icons/test/hallo1.doc
> 
> 
> ----
> 
<SNIP>
Okay, assuming the above file is in list.txt:

my %hash;
open FILE, "list.txt" or die "Can't open list.txt: $!\n";
while (<FILE>) {
  shift;
  my ($size, $dir) = split;
  my @f = split /\//, $dir;
  while (@f) {
    $hash{$dir} += $size;
    pop(@f);
    $dir = join "/", @f;
  }
}
close FILE;
foreach my $level (sort keys %hash) {
  print "$level = $hash{$level}\n";
}

I think that works ...
Sorry I've rewritten it rather than fix your code - too much to read :-)

HTH,

Garry




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

Date: Tue, 29 Jul 2003 16:10:36 +0200
From: Marcin 'Qrczak' Kowalczyk <qrczak@knm.org.pl>
Subject: Re: Currying functions
Message-Id: <2036656.JDBFX3mFtT@qrnik.knm.org.pl>

Ed Avis wrote:

> If in Perl you want to use a regexp which is not known until run time,
> but on the other hand expect that the same regexp will be used often,
> then one way to get the right result is to construct a closure:

It's simpler to write qr/$pattern/ - it's a scalar which you can store
in a variable.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


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

Date: 29 Jul 2003 06:46:10 -0700
From: magelord@t-online.de (Math55)
Subject: Re: Getting the size of files from a list?
Message-Id: <a2b8188a.0307290546.340c890b@posting.google.com>

inwap@inwap.com (Joe Smith) wrote in message news:<nVsSa.512$603.25445@iad-read.news.verio.net>...
> In article <a2b8188a.0307071035.30c2b396@posting.google.com>,
> Math55 <magelord@t-online.de> wrote:
> >hi, how must i change the code so it shows the sum of all
> >childdirectories from a directory? for example:
> 
> You can use one of my old programs to do that.
> 
>    unix% lsf -du -x -o files.lsf /
>    unix% head files.du
>    K-bytes dirs files directory
>    2756727   25    13 .
>    1092378   33    14 usr
>    1063652    5     0 utility
>     716172   23     8 utility/local
>     478649   33     0 var
>     394761   30   126 utility/local/lib
>     247475    6     3 usr/openwin
>     195077    3    21 var/log
>     194757    8     1 utility/gnu
> 
> Look for 'lsf' in http://www.inwap.com/mybin/ .
> (I tried to e-mail that file to you but <magelord@t-online.de> bounced.)
> 	-Joe

hi, thanks. i tried it, but somehow i do not understand the output.
how can i add this to the program you posted before?

THANKS


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

Date: 29 Jul 2003 14:58:35 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Help needed on mkdir
Message-Id: <slrnbid2sr.t90.abigail@alexandra.abigail.nl>

Koo Yee Seong (jimmykoo@pacific.net.sg) wrote on MMMDCXIX September
MCMXCIII in <URL:news:bg4ms3$mjv$1@nobel2.pacific.net.sg>:
??  I understand that to create a directory, I use
??  
??  mkdir ('directory',744);
??  but when i try to use a variable for directory it wont work...
??  
??  like
??  $directory = "/home/new_directory";
??  mkdir ("$directory",744);
??  
??  I need to use a variable to store the path to directory created as the
??  changes from time to time.
??  
??  Will any kind people please help me out as this is quite urgent. thanks
??  alot.


Hmmm, 'it wont work'. I love such reports. Specially from someone
who has an urgent need to have a fix. It's soooooooooo clear what
you mean by 'it wont work'. Like when you go to your doctor, all
you need to say 'it hurts' and "I'm in a hurry", and he will just
know how to make you better. No details necessary, especially not
when you are in a hurry.

Don't even bother asking Perl what the problem is. No, just go to
the fast Usenet, with lots of doctors that don't need any specific
information.

I think your 'mkdir' is homeless, and you know about those homeless
types, they often don't work.



Abigail
-- 
   my $qr =  qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
      $qr =~  s/$qr//g;
print $qr, "\n";


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

Date: Tue, 29 Jul 2003 08:30:09 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How do you Call a Perl subroutine with a variable name?
Message-Id: <slrnbictn1.3jp.tadmc@magna.augustmail.com>

Fred <fred.illig@lmco.com> wrote:

> I want to call this subroutine
> (x) via an array element - @array = (a,b,c,x,y,z);
> ($outvar1, $outvar2) = &$array[3]($invar1,$invar2,$invar3);


Use a "dispatch table".


> How do I make a call to a subroutine where the name of the subroutine
> to be called is being derived from an element in an array?  


By using "symbolic references".

But *don't do that*!


> We have a
> variable as the subroutine name that we want to use.


Use real references instead of symbolic references.


> A real live example
> would be great.


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

my @subs = ( \&a, \&b, \&x );  # array of code references

foreach my $i ( 0..2 ) {
   $subs[$i]->( 'one', 'two', 'three');
}

sub a { print "a(@_) got called\n" }
sub b { print "b(@_) got called\n" }
sub x { print "x(@_) got called\n" }
--------------------------------------------


But using a hash instead of an array is often nicer:

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

my %subs = ( a => \&a, b => \&b, x => \&x );  # hash of code references

foreach my $i ( 'a', 'b', 'x' ) {
   $subs{$i}->( 'one', 'two', 'three');
}

sub a { print "a(@_) got called\n" }
sub b { print "b(@_) got called\n" }
sub x { print "x(@_) got called\n" }
--------------------------------------------


-- 
    Tad McClellan                          LMCO employee 1985-1997
    tadmc@augustmail.com                   
    Fort Worth, Texas


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

Date: Tue, 29 Jul 2003 14:48:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How do you Call a Perl subroutine with a variable name?
Message-Id: <x7d6ftqth7.fsf@mail.sysarch.com>

>>>>> "F" == Fred  <fred.illig@lmco.com> writes:

  F> If anyone has any working solutions to my problem, maybe you could gut
  F> the code and send me your structure (how you actually got an array
  F> element, that is a subroutine's name, to be able to be called as a
  F> variable).

you didn't listen to what people said. the solutions you got were
working. you DO NOT WANT to do what you claim you want to do. do not
call subnames by a variable. it is dangerous, bug prone and not a good
idea. how many more times do we have to tell you this? search google
groups in this group for 'dispatch table'. you will find many threads
showing you how to do this in a safe and simple manner.

  F> Thanks again for all your effort.

why thank us if you don't take our advice. you still seem to be
headstrong about doing your way and that is wrong. dispatch tables are
easy and commonly used. calling subs via a variable is annoying, tricky
and danger prone. which do you want to do based on that information? 

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: Tue, 29 Jul 2003 09:11:18 -0500
From: "Bob" <rpl-erroroneous@goldengate.net>
Subject: Re: New to Perl - getting error
Message-Id: <3f26805b$0$101$8f4e7992@newsreader.goldengate.net>

"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnbibsj7.vkt.sholden@flexal.cs.usyd.edu.au...
> On Mon, 28 Jul 2003 23:01:58 -0500, Bob <rpl-erroroneous@goldengate.net>
wrote:
> >
> > c:\tmp>  perl -lne'print for $last + 1 .. $_ - 1; $last = $_'  data
> >
> > where data is file with 4  lines..
> > 10001
> > 10003
> > 10004
> > 10005
> >
> > on w2k sp2 system - I get following error msg
> > Can't find string terminator "'" anywhere before EOF at -e line 1.
>
> perldoc -q one-liner
>
> Why don't Perl one-liners work on my DOS/Mac/VMS system?
> --
> Sam Holden
>

that explains why  perldoc -q terminator  or perldoc -q EOF   or a host of
other perldoc inquiries did not provide me with an answer.
thanks






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

Date: Tue, 29 Jul 2003 09:13:16 -0500
From: "Bob" <rpl-erroroneous@goldengate.net>
Subject: Re: New to Perl - getting error
Message-Id: <3f2680d2$0$100$8f4e7992@newsreader.goldengate.net>

"John W. Krahn" <krahnj@acm.org> wrote in message
news:3F25F4BB.AC444B5A@acm.org...
> Bob wrote:
> >
> > John W. Krahn" <krahnj@acm.org> wrote in message
> > news:3F25A113.37BFFF08@acm.org...
> > > nos wrote:
> > > >
> > > > I am looking for a way to look into a file and determine the next
> > > > number in a sequence that is not present within a range of numbers.
> > > > Example:
> > > > File    10000
> > > >         10001
> > > >         10003
> > > >         10004
> > > >
> > > > I want it to find 10002 as the missing number. Any suggestions.
> > > perl -lne'print for $last + 1 .. $_ - 1; $last = $_' yourfile
> >
> > c:\tmp>  perl -lne'print for $last + 1 .. $_ - 1; $last = $_'  data
> >
> > where data is file with 4  lines..
> > 10001
> > 10003
> > 10004
> > 10005
> >
> > on w2k sp2 system - I get following error msg
> > Can't find string terminator "'" anywhere before EOF at -e line 1.
>
> Sorry, I don't use Windows, but my understanding from reading the Perl
> documentation is that you have to use " instead of ' when running on
> Windows.
>
> perl -lne"print for $last + 1 .. $_ - 1; $last = $_"  data
>
>
> John
> --
> use Perl;
> program
> fulfillment

thanks.  that works..  ( in a way)..  starts at 1





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

Date: Tue, 29 Jul 2003 07:58:55 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: New to Perl
Message-Id: <slrnbicrsf.3jp.tadmc@magna.augustmail.com>

Garry Short <g4rry_sh0rt@zw4llet.com> wrote:
> Brett Irving wrote:

>> <BODY>
>>       <!-- ***INSERT NEW CONTENT HERE*** -->
>> </BODY>


> something like this would work:
                      ^^^^^^^^^^

No it won't...


>   if ($t =~ /<!-- ***INSERT NEW CONTENT HERE*** --->/) {
                    ^^^                       ^^^ ^^^

   if ($t =~ /<!-- \*\*\*INSERT NEW CONTENT HERE\*\*\* -->/) {


But pattern matching is not the Right Tool, since we are not
looking for a pattern. 

We are looking for a constant string, so this would be better:

   if ( index($t, '<!-- ***INSERT NEW CONTENT HERE*** -->') >= 0 ) {


>       print OUTFILE "$c";


A useless use of double quotes.

   perldoc -q quot

      What's wrong with always quoting "$vars"?


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


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

Date: 29 Jul 2003 14:02:02 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: New to Perl
Message-Id: <Xns93C76612EEC66asu1cornelledu@132.236.56.8>

balgorg@hotmail.com (Brett Irving) wrote in 
news:4f68b81.0307281731.70f885c6@posting.google.com:

> Hi I am new to perl and am trying to do some test functions that will
> let me substitute html from one file into another using markers ie.
> 
> <HTML>
> 
> <HEAD>
> </HEAD>
> 
> <BODY>
>       <!-- ***INSERT NEW CONTENT HERE*** -->
> </BODY>
> 
> </HTML>

This can get way out of hand rather quickly. You might want to take a 
look at HTML::Template at search.cpan.org.


-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: Tue, 29 Jul 2003 15:34:35 +0000
From: Garry Short <g4rry_sh0rt@zw4llet.com>
Subject: Re: New to Perl
Message-Id: <bg60rl$mo4$3$8300dec7@news.demon.co.uk>

Tad McClellan wrote:

> Garry Short <g4rry_sh0rt@zw4llet.com> wrote:
>>   if ($t =~ /<!-- ***INSERT NEW CONTENT HERE*** --->/) {
>                     ^^^                       ^^^ ^^^
> 
>    if ($t =~ /<!-- \*\*\*INSERT NEW CONTENT HERE\*\*\* -->/) {
> 
<SIGH> That's what happens when you post code without really thinking about
it - cheers for correcting that, Tad, should have picked that up myself :-)


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

Date: 29 Jul 2003 13:12:08 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Perl variable data "replacement"
Message-Id: <bg5rr8$k7uf0$1@ID-24002.news.uni-berlin.de>

Tassilo v. Parseval wrote:
> Also sprach Tina Mueller:
>> doesn't URI::Find::Schemeless put the url with "http://" into
>> $_[0]? so that you can do:
>> sub { qq{<a href="$_[0]">$_[1]</a>} }

> Ah, it does indeed. It puts a URI::URL object into $_[0] that has
> overloaded stringification.

oh, it's an object. i didn't see *that*, just printed it =)

-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -


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

Date: Tue, 29 Jul 2003 23:15:04 +1000
From: "Sisyphus" <kalinabears@iinet.net.au>
Subject: Re: porting perl scripts from NT to UNIX
Message-Id: <3f267469$0$23610$5a62ac22@freenews.iinet.net.au>


"mani srinivas potnuru" <potnuru@students.uiuc.edu> wrote in message
news:Pine.GSO.4.31.0307282029080.9550-100000@ux13.cso.uiuc.edu...
>
> Hi,
> I am newbie to Perl in general. But i need to port a perl script which
> uses WIN32 API to unix. I am wondering if anybody has some pointers about
> how to go about this task.
>

You can't port Win32::API to Unix ..... so for a start you have to write the
script so that it doesn't 'use Win32::API;' (or any other Win32 module).

Beyond that, I don't think there are any *general* pointers - it depends
upon what the script actually does.

Cheers,
Rob




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

Date: 29 Jul 2003 06:06:07 -0700
From: Arthurkog@yahoo.com (ARod)
Subject: remote readdir()
Message-Id: <4a7949b4.0307290506.66fc711f@posting.google.com>

Is there a way to use readdir to get the directory structure of a
remote server?  If not, is there another function that can do this?


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

Date: 29 Jul 2003 13:22:26 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: remote readdir()
Message-Id: <bg5sei$k7uf0$2@ID-24002.news.uni-berlin.de>

ARod wrote:
> Is there a way to use readdir to get the directory structure of a
> remote server?  If not, is there another function that can do this?

that depends on what you mean by "remote server".

hth, tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -


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

Date: Tue, 29 Jul 2003 13:29:03 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: remote readdir()
Message-Id: <Xns93C79D0236480elhber1lidotechnet@62.89.127.66>

Tina Mueller wrote:

> ARod wrote:
>> Is there a way to use readdir to get the directory structure of a
>> remote server?  If not, is there another function that can do this?
> 
> that depends on what you mean by "remote server".


Someone who brings him the remote when he can't reach it.


Duh.


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Tue, 29 Jul 2003 13:31:05 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: remote readdir()
Message-Id: <tGuVa.19642$v9.3257@nwrddc01.gnilink.net>

ARod wrote:
> Is there a way to use readdir to get the directory structure of a
> remote server?

What kind of remote server? NFS and the directory structure of an NFS share?
Sure, just mount it.

> If not, is there another function that can do this?

Probably, depending upon what kind of server you are talking about. Trivial
for FTP. Impossible for HTTP because that kind of functionality is not
supported by the HTT protocol.
Don't know about WAIS or News or or ....

jue




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

Date: 29 Jul 2003 14:24:30 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: remote readdir()
Message-Id: <slrnbid0su.t90.abigail@alexandra.abigail.nl>

ARod (Arthurkog@yahoo.com) wrote on MMMDCXIX September MCMXCIII in
<URL:news:4a7949b4.0307290506.66fc711f@posting.google.com>:
**  Is there a way to use readdir to get the directory structure of a
**  remote server?  If not, is there another function that can do this?


Yes. You first have to mount the directory you want to read though.
NFS and Samba are two protocols that are used often.

On Unix, you would do something like:

    $ mount -t nfs remote.server.tla:/path/to/dir /mnt


Of course, if you want to do this often, or transparantly, you could
use the automounter.


Abigail
-- 
CHECK {print "another "}
INIT  {print "Perl "   }
BEGIN {print "Just "   }
END   {print "Hacker\n"}


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

Date: Tue, 29 Jul 2003 15:30:37 +0000
From: Garry Short <g4rry_sh0rt@zw4llet.com>
Subject: Re: remote readdir()
Message-Id: <bg60k7$mo4$2$8300dec7@news.demon.co.uk>

Abigail wrote:

> ARod (Arthurkog@yahoo.com) wrote on MMMDCXIX September MCMXCIII in
> <URL:news:4a7949b4.0307290506.66fc711f@posting.google.com>:
> **  Is there a way to use readdir to get the directory structure of a
> **  remote server?  If not, is there another function that can do this?
> 
> 
> Yes. You first have to mount the directory you want to read though.
> NFS and Samba are two protocols that are used often.
> 
> On Unix, you would do something like:
> 
>     $ mount -t nfs remote.server.tla:/path/to/dir /mnt
> 
> 
> Of course, if you want to do this often, or transparantly, you could
> use the automounter.
> 
> 
> Abigail

And if you're using some brand of Windoze,

my $remote = '\\remote_server\remote_share\file_structure_within_share';
readdir $remote or die "Can't READDIR $remote: $!\n";


Or, if you use double quotes to define $remote so that you can include a
variable, double-up the backslashes :

foreach $folder (@list) {
  $remote = "\\\\server\\share\\$folder";
  ...
}

HTH,

Garry




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

Date: Tue, 29 Jul 2003 14:55:48 +0100
From: Chris <no_thanks@bms.umist.ac.uk>
Subject: Re: Result from a regex substitute
Message-Id: <3f268711$1@news.umist.ac.uk>

Julia deSilva wrote:
> Hi there all,
> 
> I sure this is really obvious but what's the syntax for this please:
> 
> my $string1 = "mark had a little dog";
> $string1  =~ s/dog/lamb/g; # $string1 is "mary had a little lamb"
> 
> 
> But ................
> my $string1 = "mark had a little dog";
> my $string2 = $string1 =~ s/dog/lamb/g;
> This returns
> $string2 = 1 (presumably a boolean for substitute done)
> whereas I want it to return $string2 = "mary had a little lamb";

If you want to keep the $string1 to remain as "mark had a little dog" 
and have $string2 be the changed string do this:

my string1 = my string2 = "mark had a little dog";
$string2 =~ s/dog/lamb/g;

BTW This substitution won't ever give "mary had a little lamb" it will 
give you "mark had a little lamb".



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

Date: 29 Jul 2003 07:55:58 -0700
From: peterstokes@operamail.com (Peter Stokes)
Subject: Sorting out sort
Message-Id: <10876b94.0307290655.50e56394@posting.google.com>

I'm trying to extract a column from a flatfile database and print it
alphabetically. I can get the data out, but I can't get it to sort.

The database is pipe-separated in a plain text file and looks like
this:

Ref_no|Title|County|Another_field|And_another|And_another
1234|A Name|Devon|Data here|More data here|And more data
1234|A Name|Somerset|Data here|More data here|And more data
1234|A Name|Nottinghamshire|Data here|More data here|And more data
1234|A Name|Essex|Data here|More data here|And more data
 ... and so on

My routine is as follows:

#open the file 
open (INFILE, 'database.txt') or die "could not open listing file - 
$!";
while (<INFILE>) {
#split the array at the separator
	@out = split /\|/;
#select the field with the county names	
	@out = $out[2];
#clean out duplicates 
	@out = grep ( (($out{$_}++ < 1) || 0), @out); 
#delete blank lines left by duplicates	
	if (@out == 1) {
		print sort @out, "\n";
	}
	else {
		print "";
	}
}
#close the file to tidy up
close INFILE;
#eof

When I print out the results, I get, typically:
Devon
Somerset
Nottinghamshire
Essex

 ... which is the order they appear in the database, and they haven't
sorted alphabetically. I've tried it from every angle I can think, but
I must be missing one because I can't make this result alphabetical. I
get the same result wherever I put the 'sort' command.

Thanks in anticipation


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

Date: Tue, 29 Jul 2003 14:24:15 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: var within reg expression
Message-Id: <v49iv-mlh.ln1@moldev.cmagroup.co.uk>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> This is getting confusing. John made a typo, and Chris illustrated his
> point using the original incorrect expression.

Sorry! You're quite correct

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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