[29412] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 656 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 17 11:10:02 2007

Date: Tue, 17 Jul 2007 08:09: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, 17 Jul 2007     Volume: 11 Number: 656

Today's topics:
    Re: Handling Large files (a few Gb) in Perl <wahab@chemie.uni-halle.de>
    Re: Handling Large files (a few Gb) in Perl <sydches@gmail.com>
    Re: Handling Large files (a few Gb) in Perl <wahab@chemie.uni-halle.de>
    Re: Handling Large files (a few Gb) in Perl <wahab@chemie.uni-halle.de>
    Re: Handling Large files (a few Gb) in Perl <paduille.4061.mumia.w+nospam@earthlink.net>
    Re: Handling Large files (a few Gb) in Perl <paduille.4061.mumia.w+nospam@earthlink.net>
    Re: Handling Large files (a few Gb) in Perl <paduille.4061.mumia.w+nospam@earthlink.net>
    Re: Handling Large files (a few Gb) in Perl <sydches@gmail.com>
    Re: Handling Large files (a few Gb) in Perl <wahab@chemie.uni-halle.de>
    Re: how do i print/report my class hierarchy <gcerrai@etnoteam.it>
        Recursively Removing Embedded Quotes <BuckTheManTurgidson@gmail.com>
    Re: Recursively Removing Embedded Quotes <wahab@chemie.uni-halle.de>
    Re: Use UTF-8 in Log::StdLog? <paduille.4061.mumia.w+nospam@earthlink.net>
        Using the split function <shmh@bigpond.net.au>
    Re: Using the split function <usenet@larseighner.com>
    Re: Using the split function <bik.mido@tiscalinet.it>
    Re: Using the split function <bik.mido@tiscalinet.it>
    Re: Using the split function <shmh@bigpond.net.au>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 17 Jul 2007 12:18:12 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Handling Large files (a few Gb) in Perl
Message-Id: <f7i514$qp3$1@nserver.hrz.tu-freiberg.de>

sydches@gmail.com wrote:
> Hi,
> 
> I am a beginner (or worse) at Perl.
> 
> I have a need to find the longest line (record) in a file. The below
> code works neatly for small files.
> But when I need to read huge files (in the order of Gb), it is very
> slow.
> 
> I am running this on a laptop with Windows XP, 1.7 GHz processor with
> 1 Gb of RAM
> I am using ActivePerl

Id did some test on a linux machine (Athlon XP/2500+, 1Gig)
to clear this up.

First, is put the stuff on the good ole Maxtor server
drive, generate the 1G file and run the perl program:

    winner: 1002 at 795

    real    0m31.034s
    user    0m7.080s
    sys     0m2.350s

The real perl process did need 7 seconds then + 2 seconds
operating system file handling. The difference up to the
whole time of 31 sec is the time needed to get the file
from the raw disk drive (a 1G file won't be buffered).


Next, I move the dir to a new WD server drive, generate
the 1G file an run the perl program:

    winner: 1002 at 200

    real    0m15.603s
    user    0m7.290s
    sys     0m2.030s


What we see here - the whole time has been halved,
but the time the perl needed is almost exactly the
same. We measured the different disk bandwidths.


Regards

M.

Perl source used:

==>
   use strict;
   use warnings;

   my ($l, $n) = (-1, -1);

   open my $fh, '<', 'del.txt' or die "can't do anything $!";
   while( <$fh> ) {
     ($l, $n) = (length, $.) if $l < length
   }
   close $fh;

   print "winner: $l at $n\n";
<==


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

Date: Tue, 17 Jul 2007 05:03:13 -0700
From:  "sydches@gmail.com" <sydches@gmail.com>
Subject: Re: Handling Large files (a few Gb) in Perl
Message-Id: <1184673793.694186.34840@e16g2000pri.googlegroups.com>

Hi,

I think it's only fair that we do this on the same file.

***************************************Begin*******************************=
=AD
********
open(F1, ">c:/perl/testout/HugeFile.txt");

for ($index =3D 0; $index <=3D 1000000; $index++)
   {
      print F1 "This line is 32 characters long  \n";
      print F1 "This line
is
101 characters long \n";
   }
close F1;
****************************************End********************************=
=AD
********

The C code times are as follows:
The current time is: 17:30:47.20
The current time is: 17:30:55.00

Thanks!
Sydney



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

Date: Tue, 17 Jul 2007 14:19:58 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Handling Large files (a few Gb) in Perl
Message-Id: <f7ic5e$snl$1@nserver.hrz.tu-freiberg.de>

sydches@gmail.com wrote:
> Hi,
> 
> I think it's only fair that we do this on the same file.
> open(F1, ">c:/perl/testout/HugeFile.txt");
> 
> for ($index = 0; $index <= 1000000; $index++)
>    {
>       print F1 "This line is 32 characters long  \n";
>       print F1 "This line
> is
> 101 characters long \n";
>    }
> close F1;

Your file size will be

   1000000 * (32 + 101) ==> 133000000

which is almost 128 MB or 0.128 GB

Try:

==>

use strict;
use warnings;

my $count = 10_000_000;

open my $fh, '>', 'del.txt' or die "can't write $!";

print $fh (
'This line is 32 characters long
 .................................... This line is 101 characters long ..............................
' ) while $count--;

close $fh;

<==

This will result in a file of 128GB. Post your C results then.

Regards

M.


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

Date: Tue, 17 Jul 2007 14:22:02 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Handling Large files (a few Gb) in Perl
Message-Id: <f7ic9a$snl$2@nserver.hrz.tu-freiberg.de>

Mirco Wahab wrote:
> 
> This will result in a file of 128GB. Post your C results then.

OOPS, lost the dot:

must read: "This will result in a file of 1.28GB"

Sorry, M.




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

Date: Tue, 17 Jul 2007 12:27:10 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Handling Large files (a few Gb) in Perl
Message-Id: <yA2ni.7833$rR.7313@newsread2.news.pas.earthlink.net>

On 07/17/2007 03:47 AM, sydches@gmail.com wrote:
> Hi,
> 
> My apologies. The times were off the mark. It takes less than 3
> seconds (277 milliseconds).
> The start time is: 14:04:35.97
> The end time is: 14:04:38.74
> [...]

No, this is not 277 milliseconds; it's 2.77 seconds or 2770 milliseconds.

> Here's the source code in C. [...]

No, it's C++.

> # include <fstream.h>
> [...]

You must have a fast machine. Either that or your program is buggy.

I have a 1300mhz AMD CPU with 512mb. I wrote both a C and a Perl version
of this program, and this is what I got:

> $ ls -ln ~/tmp/junk/big
> -rw-r--r--  1 **** **** 2088763392 2007-07-17 06:33 /home/****/tmp/junk/big
> $
> $ cat count-lines.c
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <time.h>
> #include <string.h>
> 
> int main (int argc, const char ** argv)
> {
>     const char * filename = 0;
>     FILE * handle = 0;
>     time_t starttime = 0;
>     time_t endtime = 0;
>     long line_number = 0;
>     long line_length = 0;
>     long lnno = 0;
>     static char line [10000];
> 
>     if (argc < 2) {
>         fprintf(stderr, "No filename\n");
>         return EXIT_FAILURE;
>     }
> 
>     filename = argv[1];
>     handle = fopen(filename, "r");
>     if (0 == handle) {
>         perror(filename);
>         return EXIT_FAILURE;
>     }
> 
>     starttime = time(0);
> 
>     while (fgets(line,sizeof(line),handle)) {
>         lnno++;
>         long length = strlen(line);
>         if (length > line_length) {
>             line_length = length;
>             line_number = lnno;
>         }
>     }
>     fclose(handle);
> 
>     endtime = time(0);
> 
>     printf("%ld is the longest line with %ld characters\n",
>             line_number, line_length);
>     printf("%ld seconds elapsed\n", (long) (endtime-starttime));
> 
>     return EXIT_SUCCESS;
> }
> 
> 
> $ cat count-lines.pl
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my ($line_number, $line_length) = (0,0);
> my $starttime = time();
> 
> while (<>) {
>     my $length = length($_);
>     if ($length > $line_length) {
>         $line_length = $length;
>         $line_number = $.;
>     }
> }
> close(ARGV);
> 
> my $endtime = time();
> 
> print "$line_number is the longest line with $line_length characters\n";
> printf "%d seconds elapsed\n", ($endtime-$starttime);
> 
> $
> $
> $ ./count-lines ~/tmp/junk/big
> 9580 is the longest line with 3836 characters
> 51 seconds elapsed
> $
> $ ./count-lines.pl ~/tmp/junk/big
> 9580 is the longest line with 3836 characters
> 106 seconds elapsed
> $
> $ # For a bytecode-compiled scripting language, that's pretty damn good!
> $

I expected Perl to take ten to twenty times longer than C. I'm amazed 
that it's only about twice as slow. The fact that Perl can almost keep 
up with C means that Perl is ultra-efficient with character processing  :-D

However, your time of 2.77 seconds stretches my belief muscles too far. 
What kind of machine are you running on?

PS.
I was using the ext3 filesystem during the test. I can probably get much 
better results by using ext2 if I'm willing to forgo filesystem 
journalizing--which I'm not willing to do.


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

Date: Tue, 17 Jul 2007 12:49:28 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Handling Large files (a few Gb) in Perl
Message-Id: <sV2ni.7837$rR.1320@newsread2.news.pas.earthlink.net>

On 07/17/2007 07:27 AM, Mumia W. wrote:
> On 07/17/2007 03:47 AM, sydches@gmail.com wrote:
>> Hi, [ program snipped ]
>>
> 
> However, your time of 2.77 seconds stretches my belief muscles too far. 
> What kind of machine are you running on?
> [...]

Sorry about that. Of course your data is not my data, and of course some 
people will have machines that are 100 times faster than mine.




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

Date: Tue, 17 Jul 2007 13:11:50 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Handling Large files (a few Gb) in Perl
Message-Id: <qe3ni.8520$Od7.7757@newsread1.news.pas.earthlink.net>

On 07/17/2007 07:19 AM, Mirco Wahab wrote:
> sydches@gmail.com wrote:
>> Hi,
>>
>> I think it's only fair that we do this on the same file.
>> open(F1, ">c:/perl/testout/HugeFile.txt");
>>
>> for ($index = 0; $index <= 1000000; $index++)
>>    {
>>       print F1 "This line is 32 characters long  \n";
>>       print F1 "This line
>> is
>> 101 characters long \n";
>>    }
>> close F1;
> 
> Your file size will be
> 
>   1000000 * (32 + 101) ==> 133000000
> 
> which is almost 128 MB or 0.128 GB
> 
> Try:
> 
> ==>
> 
> use strict;
> use warnings;
> 
> my $count = 10_000_000;
> 
> open my $fh, '>', 'del.txt' or die "can't write $!";
> 
> print $fh (
> 'This line is 32 characters long
> ..................................... This line is 101 characters long 
> ..............................
> ' ) while $count--;
> 
> close $fh;
> 
> <==
> 
> This will result in a file of 128GB. Post your C results then.
> 
> Regards
> 
> M.

My timing for the C program is similar to yours (same data with a 
different program).

> $ (cd ~/tmp/junk ; ls -ln del.txt)
> -rw-r--r--  1 **** **** 1340000000 2007-07-17 07:55 del.txt
> $
> $ ./count-lines ~/tmp/junk/del.txt
> 2 is the longest line with 102 characters
> 26 seconds elapsed
> $
> $ ./count-lines.pl ~/tmp/junk/del.txt
> 2 is the longest line with 102 characters
> 38 seconds elapsed
> $

"Count-lines" is the C program's binary, and count-lines.pl is, 
obviously, the Perl program.

I'm still impressed by Perl's speed.

Yes, I know the wording of my program's output needs work. Line 2 is 
only one of the 10 million longest lines in the file ;-)



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

Date: Tue, 17 Jul 2007 07:03:28 -0700
From:  "sydches@gmail.com" <sydches@gmail.com>
Subject: Re: Handling Large files (a few Gb) in Perl
Message-Id: <1184681008.738859.39540@z28g2000prd.googlegroups.com>

Hi,

Using the Perl code that Mirco gave, I created a file which is 1.27 GB
in size.

Ran the C++ code and the times are:
The current time is: 19:18:52.21
The current time is: 19:23:09.65

I am on a Windows XP system (1.7 GHz processor with 1 Gb of RAM), and
using ActivePerl.

Thanks!
Syd



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

Date: Tue, 17 Jul 2007 16:36:47 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Handling Large files (a few Gb) in Perl
Message-Id: <f7ik5v$v73$1@nserver.hrz.tu-freiberg.de>

sydches@gmail.com wrote:
> Using the Perl code that Mirco gave, I created a file which is 1.27 GB
> in size.
> Ran the C++ code and the times are:
> The current time is: 19:18:52.21
> The current time is: 19:23:09.65

OK, this is 256 seconds which is what
one may expect from a loaded win-xp
machine of 1,7GHz.

I did again another test with the very file
(1,2GB) on an old unix machine (Athlon XP/2500+,
running from a WD3200JB-ext3).

After compiling (gcc 4.1) your C++-Programm (commenting out
non-unixish stuff) with: g++ -O3 -o sydches sydches.cxx

I see the following results:
$> time ./sydches del.txt

 ...

real    1m1.888s
user    0m54.270s
sys     0m3.070s

(the whole process takes ~62sec) - whereas the short Perl
script provided in another post shows the following:
$> time perl longest.pl

 ...

real    0m28.218s
user    0m21.140s
sys     0m3.330s

(which is more than twice as fast). Some Perl program:

   ...
   open my $fh, '<', 'del.txt' or die "can't do anything $!";
   while( <$fh> ) {
      ($l, $n) = (length, $.) if $l < length
   }
   close $fh;
   ...

may be therefore, as one can see, much
much faster than a 'non-optimally' written
C/C++ program.

Regards

Mirco


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

Date: Tue, 17 Jul 2007 12:13:50 +0200
From: Giacomo Cerrai <gcerrai@etnoteam.it>
Subject: Re: how do i print/report my class hierarchy
Message-Id: <469c9658@news.x-privat.org>

 anon24u@gmail.com wrote:

> Hi,
> 
> I would like to generate a report of the class hierarchy of my
> application.  What is the easiest way?  Are there any utilities for
> this in CPAN?  I don't need anything fancy.
> 

Try Devel::SymDump:

use MyModule;
use MyOtherModule;
 ...

use Devel::Symdump;
print Devel::Symdump->isa_tree,
      "-----\n",
      Devel::Symdump->inh_tree;

g.



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

Date: Tue, 17 Jul 2007 14:28:46 -0000
From:  Buck <BuckTheManTurgidson@gmail.com>
Subject: Recursively Removing Embedded Quotes
Message-Id: <1184682526.536317.191160@i13g2000prf.googlegroups.com>

I have a routine that recursively removes embedded parentheses and it
works just fine.  But when I adapt that regex to do the same thing
with single quotes, it doesn't work.  It matches two quoted strings,
not the inner one.

E.g. the regex below

'[^'']*'

should match inner, but it matches left and right.

what am I doing wrong?

'  left  '  inner  ' right '



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

Date: Tue, 17 Jul 2007 17:03:08 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Recursively Removing Embedded Quotes
Message-Id: <f7ilnc$vh2$1@nserver.hrz.tu-freiberg.de>

Buck wrote:
> I have a routine that recursively removes embedded parentheses and it
> works just fine.  

I didn't find one in your posting.

> But when I adapt that regex to do the same thing
> with single quotes, it doesn't work.  It matches 
> two quoted strings, not the inner one.
> E.g. the regex below
> '[^'']*'
> should match inner, but it matches left and right.
> what am I doing wrong?
> '  left  '  inner  ' right '

The regex causes the engine to 'eat up' the
quotes around inner, to extract all quoted
phrases, you could use zero-with assertions:

   ...
   my $text = q{ '  left  '  inner  ' right ' };

   my @matches = $text =~ /(?<=')[^']+(?=')/g;
   ...

Regards

Mirco





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

Date: Tue, 17 Jul 2007 10:27:27 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Use UTF-8 in Log::StdLog?
Message-Id: <jQ0ni.9064$zA4.8809@newsread3.news.pas.earthlink.net>

On 07/16/2007 05:27 PM, jerry@ieee.org wrote:
> I've been using Log::StdLog for logging, but find that when I tell it
> to log a utf-8 string containing non-ASCII characters, I get the ol'
> warning:
> 
>     Wide character in print at....
> 
> Now, when writing to a file, the fix for this is
> 
>     binmode (FILE, ":utf8") ;
> 
> But is there a way to fix Log::StdLog without going in and hacking the
> source code?
> 
> Log::StdLog is initialized like this:
> 
>     use Log::StdLog { level => 'all', file => "PerlRun.log"} ;
> 
> and then when you want to log a message, you do
> 
>     print {*STDLOG} info => "This is a message.\n" ;
> 
> So, I probably need to do something like
> 
>     binmode (STDLOG, ":utf8") ;
> 
> but I can't get any such syntax to work.  I've looked at the
> Log::StdLog source code but it's way over my head.  I don't understand
> what the asterisk does prefixing STDLOG.  I thought that perl did not
> have an asterisk dereferencing operator.
> 
> Thanks,
> 
> Jerry Krinock
> 

Perl does not have an asterisk dereferencing operator, and the symbol 
isn't needed here (but doesn't hurt).

You can solve the problem three ways: (1) Reach deep into the internals 
of the tied object and set binmode on the handle :-( . (2) Create your 
own file handle to receive logging information and specify the "handle" 
option when you "use Log::StdLog". (3) Shove an extra BINMODE method 
into the author's Log::StdLog package :-( :-(

Here is code to demonstrate the various methods:
(1)
> use strict;
> use warnings;
> use Log::StdLog { level => 'warn', file => 'here.log' };
> 
> print {*STDLOG} warn => 'First logging line';
> binmode((tied *STDLOG)->{handle}, 'utf8');
> 
> print {*STDLOG} warn => "Hey, this (\x{263a}) is here.";
> 

(2)
> use strict;
> use warnings;
> 
> my $logfh;
> BEGIN {
>     open ($logfh, '>:utf8', 'here2.log') or die("Stopped: $!");
> }
> use Log::StdLog { level => 'warn', handle => $logfh };
> 
> print {*STDLOG} "The smiley <\x{263a}> is here.";
> 
> close $logfh;

(3)
> use strict;
> use warnings;
> 
> use Log::StdLog { level => 'warn', file => 'here.log' };
> 
> print {*STDLOG} warn => 'initializer';
> binmode(STDLOG, 'utf8');
> print {*STDLOG} warn => "The smiley <\x{263a}> is here.";
> print STDLOG warn => 'More logging...';
> print $Log::StdLog::VERSION, "\n";
> 
> sub Log::StdLog::BINMODE {
>     my ($self, $mode) = @_;
>     binmode($self->{handle}, $mode);
>     $self;
> }
> 

Note that, for (1) and (3) to work, some data must have already been 
written to the file. You might make a feature request of the author for 
binmode() support.




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

Date: Tue, 17 Jul 2007 10:58:48 GMT
From: "Simon" <shmh@bigpond.net.au>
Subject: Using the split function
Message-Id: <Ih1ni.8443$4A1.1652@news-server.bigpond.net.au>

Hi guys.
Would appreciate very much your help on this one.
What I want to do is:
Create a perl script that:
a) Reads a computer list (done)
b) Connects to each one (done)
c) Uses reg.exe to query a registry value (done)
d) Pipe the computer with its BuildVersion number to the appropriate text 
file according to Buildverson number retrieved (having problems). Im having 
problems with the split function. Please see below..


================================================================= go.pl

sub RunRegQuery {
open (REGQUERY, "reg query \"\\\\$System\\HKLM\\Software\\test\" /v 
BuildVersion|");
            while (<REGQUERY>) {
            @lines = <REGQUERY>;
                        foreach $line (@lines)      {
                        chomp $line;
                        print "$line\n";
                        }
            }
}

#================================================= Create files for logging.
open U,">unknown.txt" or die "unknown.txt $!";
open H,">6.11.txt" or die "6.11.txt $!";
open S,">6.7.txt" or die "6.7.txt $!";
open L,">6.5.txt" or die "6.5.txt $!";
open C,">6.2.txt" or die "6.2.txt $!";

#================================================= Read a Computer List.
open (Store, "< systems.txt") or die "can't open systems.txt: $!";
            foreach $line (<Store>) {
            chomp($line);
            $System = $line;
            $result = system ("net use \\\\$System\\ipc\$ \"password\" 
/user:$System\\administrator");
            if ($result !=0) {   #if not successful
            print U "$System: Unreachable\n";
            }
            else {
            print "$System: Successful.\n";
            sleep 3;
                        RunRegQuery();
                        system ("net use \\\\$System\\ipc\$ /delete /y > 
2NUL > NUL"); # Delete previous connection
                        }
            }
close (Store);
exit;
--------------------------------------------------------- EOF
===================================================================== 
Output:
C:\@>go.pl
The command completed successfully.

predator: Successful.
! REG.EXE VERSION 3.0

HKEY_LOCAL_MACHINE\Software\test
    BuildVersion        REG_SZ  6.11


C:\@>
================================================================= Comments:

Ive deliberately left out the split function to make this easier to read, as 
this is where
Im having problems.

What Im trying to do is grab the following line in the above output:

    BuildVersion        REG_SZ  6.11

and then, write

$System:  6.11

to the appropriate filehandle.

For example, if the value is 6.11, write  "$System   6.11" to the 6.11.txt 
file, then continue through the computer list.
I know I have to use a split function (I believe), but having big issues 
with it.
In the above, I printed the $line, just so you guys could see what is 
returned.




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

Date: 17 Jul 2007 11:47:13 GMT
From: Lars Eighner <usenet@larseighner.com>
Subject: Re: Using the split function
Message-Id: <slrnf9pb0h.ek7.usenet@goodwill.larseighner.com>

In our last episode, 
<Ih1ni.8443$4A1.1652@news-server.bigpond.net.au>, 
the lovely and talented Simon 
broadcast on comp.lang.perl.misc:

> Hi guys.
> Would appreciate very much your help on this one.
> What I want to do is:
> Create a perl script that:
> a) Reads a computer list (done)
> b) Connects to each one (done)
> c) Uses reg.exe to query a registry value (done)
> d) Pipe the computer with its BuildVersion number to the appropriate text 
> file according to Buildverson number retrieved (having problems). Im having 
> problems with the split function. Please see below..

Sounds suspiciously like homework.

> Ive deliberately left out the split function to make this easier to read, as 
> this is where Im having problems.

Other than just doing you homework for you, how can we help you if we don't
see what you are trying?


> What Im trying to do is grab the following line in the above output:

>     BuildVersion        REG_SZ  6.11

> and then, write

> $System:  6.11

> to the appropriate filehandle.

> For example, if the value is 6.11, write  "$System   6.11" to the 6.11.txt 
> file, then continue through the computer list.
> I know I have to use a split function (I believe),

Why do you believe that?  From what I've seen, I'd try matching.

> but having big issues with it.

What issues?  Let's see what you have tried that suggests you have even
looked up split for yourself.

> In the above, I printed the $line, just so you guys could see what is 
> returned.


-- 
Lars Eighner     <http://larseighner.com/>     <http://myspace.com/larseighner>
                         Countdown: 553 days to go.
Owing to massive spam from googlegroups, I do not see most posts from there.


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

Date: Tue, 17 Jul 2007 15:00:26 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Using the split function
Message-Id: <65fp9355ja4fm6jncunniu0ue4mifmt85h@4ax.com>

On Tue, 17 Jul 2007 10:58:48 GMT, "Simon" <shmh@bigpond.net.au> wrote:

>What Im trying to do is grab the following line in the above output:
>
>    BuildVersion        REG_SZ  6.11
>
>and then, write
>
>$System:  6.11

Is $System literal or a variable? I'm assuming the latter in what
follows. (I may also read the rest of your post but you made it too
verbose for the actual issue being discussed.)

>to the appropriate filehandle.

  print $fh "$System:  ", (split)[2];

>For example, if the value is 6.11, write  "$System   6.11" to the 6.11.txt 
>file, then continue through the computer list.

>I know I have to use a split function (I believe), but having big issues 
>with it.

I would help if you could explain which ones...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Tue, 17 Jul 2007 15:04:00 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Using the split function
Message-Id: <hffp93tafohfa30j2h5p66s0vln2vccpr5@4ax.com>

On 17 Jul 2007 11:47:13 GMT, Lars Eighner <usenet@larseighner.com>
wrote:

>> What Im trying to do is grab the following line in the above output:
>
>>     BuildVersion        REG_SZ  6.11
>
>> and then, write
>
>> $System:  6.11
>
>> to the appropriate filehandle.
>
>> For example, if the value is 6.11, write  "$System   6.11" to the 6.11.txt 
>> file, then continue through the computer list.
>> I know I have to use a split function (I believe),
>
>Why do you believe that?  From what I've seen, I'd try matching.

Well, no: if lines can be trusted to be in that "format", then split()
is probably the best way to go.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Tue, 17 Jul 2007 13:16:22 GMT
From: "Simon" <shmh@bigpond.net.au>
Subject: Re: Using the split function
Message-Id: <Gi3ni.8517$4A1.4224@news-server.bigpond.net.au>

Thanks Lars for your help.
Most appreciated!
Eighner sounds suspiciously like "a.....s"

"Lars Eighner" <usenet@larseighner.com> wrote in message 
news:slrnf9pb0h.ek7.usenet@goodwill.larseighner.com...
> In our last episode,
> <Ih1ni.8443$4A1.1652@news-server.bigpond.net.au>,
> the lovely and talented Simon
> broadcast on comp.lang.perl.misc:
>
>> Hi guys.
>> Would appreciate very much your help on this one.
>> What I want to do is:
>> Create a perl script that:
>> a) Reads a computer list (done)
>> b) Connects to each one (done)
>> c) Uses reg.exe to query a registry value (done)
>> d) Pipe the computer with its BuildVersion number to the appropriate text
>> file according to Buildverson number retrieved (having problems). Im 
>> having
>> problems with the split function. Please see below..
>
> Sounds suspiciously like homework.
>
>> Ive deliberately left out the split function to make this easier to read, 
>> as
>> this is where Im having problems.
>
> Other than just doing you homework for you, how can we help you if we 
> don't
> see what you are trying?
>
>
>> What Im trying to do is grab the following line in the above output:
>
>>     BuildVersion        REG_SZ  6.11
>
>> and then, write
>
>> $System:  6.11
>
>> to the appropriate filehandle.
>
>> For example, if the value is 6.11, write  "$System   6.11" to the 
>> 6.11.txt
>> file, then continue through the computer list.
>> I know I have to use a split function (I believe),
>
> Why do you believe that?  From what I've seen, I'd try matching.
>
>> but having big issues with it.
>
> What issues?  Let's see what you have tried that suggests you have even
> looked up split for yourself.
>
>> In the above, I printed the $line, just so you guys could see what is
>> returned.
>
>
> -- 
> Lars Eighner     <http://larseighner.com/> 
> <http://myspace.com/larseighner>
>                         Countdown: 553 days to go.
> Owing to massive spam from googlegroups, I do not see most posts from 
> there. 




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 656
**************************************


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