[32068] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3332 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 24 18:09:28 2011

Date: Thu, 24 Mar 2011 15:09:10 -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           Thu, 24 Mar 2011     Volume: 11 Number: 3332

Today's topics:
        hash of hashes <g.ricioppo@gmail.com>
    Re: hash of hashes <wolf@runs.after.the.signature.invalid>
    Re: hash of hashes <rwv0115@gmail.com>
    Re: hash of hashes <justin.1102@purestblue.com>
    Re: hash of hashes <rwv0115@gmail.com>
    Re: hash of hashes <g.ricioppo@gmail.com>
    Re: hash of hashes <nospam.gravitalsun@hotmail.com.nospam>
    Re: hash of hashes <rwv0115@gmail.com>
    Re: hash of hashes <justin.1102@purestblue.com>
        Netiquette (was: using File::Find) <hjp-usenet2@hjp.at>
    Re: Perl script running external command <cartercc@gmail.com>
    Re: using File::Find <hjp-usenet2@hjp.at>
    Re: using File::Find <tadmc@seesig.invalid>
    Re: using File::Find <tadmc@seesig.invalid>
    Re: using File::Find (Alan Curry)
        writing to different offsets of a file in parallel <gourabbaksi@gmail.com>
    Re: writing to different offsets of a file in parallel <uri@StemSystems.com>
    Re: writing to different offsets of a file in parallel <gourabbaksi@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Mar 2011 04:30:30 -0700 (PDT)
From: Kill Joy <g.ricioppo@gmail.com>
Subject: hash of hashes
Message-Id: <d2e70377-d140-4684-94f4-4a8eebb384a2@k9g2000yqi.googlegroups.com>

Hi all..

Excuse since I'm a newbie...
I have an hash of hashes but there is something wrong in my code.


  # If an item is found for the second time
  if (exists  $hash{ $codart }) {

          #  increase the quantity of the article $codart
	  $hash{ $codart }{ q }++;
	  print "\n$codart $qq EXISTS\n";

  } else {

# insert the product
   $hash{ $codart } = {
    desc  => $desc,
    q    => $quant,
    price => $price };

   }


How to do it?

Thanks.

Regards.

G.


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

Date: Thu, 24 Mar 2011 13:11:44 +0100
From: Wolf <wolf@runs.after.the.signature.invalid>
Subject: Re: hash of hashes
Message-Id: <imfcg4$ia7$01$1@news.t-online.com>

Am 24.03.2011 12:30, schrieb Kill Joy:

> # insert the product
>     $hash{ $codart } = {
>      desc  =>  $desc,
>      q    =>  $quant,
>      price =>  $price }; <---- REMOVE ;
>
>     } <----APPEND ;

cheers, wolf

-- 
foreach (
     reverse split(
         /\d/, "m1o2c3.4p5e6e7h8s9a0l9l8i7r6e5u4g3\@2f1l0o1w"
     )) { print; }


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

Date: Thu, 24 Mar 2011 06:00:21 -0700 (PDT)
From: bobbi <rwv0115@gmail.com>
Subject: Re: hash of hashes
Message-Id: <edd6038d-fecd-4e88-a55b-48671d7d9e16@o30g2000pra.googlegroups.com>

On Mar 24, 7:30=A0am, Kill Joy <g.ricio...@gmail.com> wrote:
> Hi all..
>
> Excuse since I'm a newbie...
> I have an hash of hashes but there is something wrong in my code.
>
> =A0 # If an item is found for the second time
> =A0 if (exists =A0$hash{ $codart }) {
>
> =A0 =A0 =A0 =A0 =A0 # =A0increase the quantity of the article $codart
> =A0 =A0 =A0 =A0 =A0 $hash{ $codart }{ q }++;
> =A0 =A0 =A0 =A0 =A0 print "\n$codart $qq EXISTS\n";
>
> =A0 } else {
>
> # insert the product
> =A0 =A0$hash{ $codart } =3D {
> =A0 =A0 desc =A0=3D> $desc,
> =A0 =A0 q =A0 =A0=3D> $quant,
> =A0 =A0 price =3D> $price };
>
> =A0 =A0}
>
> How to do it?

"Something wrong" is not a useful problem description.

Add:
use warnings;
use strict;
use Data::Dumper;

Report the output of:

print Dumper \%hash;

after doing some operations and explain why it is different from what
you expect.



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

Date: Thu, 24 Mar 2011 12:59:02 +0000
From: Justin C <justin.1102@purestblue.com>
Subject: Re: hash of hashes
Message-Id: <mprr58-1mj.ln1@zem.masonsmusic.co.uk>

On 2011-03-24, Kill Joy <g.ricioppo@gmail.com> wrote:
> Hi all..
>
> Excuse since I'm a newbie...
> I have an hash of hashes but there is something wrong in my code.
>
>
>   # If an item is found for the second time
>   if (exists  $hash{ $codart }) {
>
>           #  increase the quantity of the article $codart
> 	  $hash{ $codart }{ q }++;
> 	  print "\n$codart $qq EXISTS\n";
>
>   } else {
>
> # insert the product
>    $hash{ $codart } = {
>     desc  => $desc,
>     q    => $quant,
>     price => $price };
>
>    }

"Global symbol $qq requires explicit package name at...

Have you tried:
use warnings;
use strict;

That will probably help you get your code to run, then you can ask what
it is you want.

   Justin.

-- 
Justin C, by the sea.


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

Date: Thu, 24 Mar 2011 06:20:38 -0700 (PDT)
From: bobbi <rwv0115@gmail.com>
Subject: Re: hash of hashes
Message-Id: <2274622a-6934-458c-a54f-2b7eef607550@r3g2000yqh.googlegroups.com>

On Mar 24, 9:00=A0am, bobbi <rwv0...@gmail.com> wrote:
> On Mar 24, 7:30=A0am, Kill Joy <g.ricio...@gmail.com> wrote:
>
>
>
> > Hi all..
>
> > Excuse since I'm a newbie...
> > I have an hash of hashes but there is something wrong in my code.
>
> > =A0 # If an item is found for the second time
> > =A0 if (exists =A0$hash{ $codart }) {
>
> > =A0 =A0 =A0 =A0 =A0 # =A0increase the quantity of the article $codart
> > =A0 =A0 =A0 =A0 =A0 $hash{ $codart }{ q }++;
> > =A0 =A0 =A0 =A0 =A0 print "\n$codart $qq EXISTS\n";
>
> > =A0 } else {
>
> > # insert the product
> > =A0 =A0$hash{ $codart } =3D {
> > =A0 =A0 desc =A0=3D> $desc,
> > =A0 =A0 q =A0 =A0=3D> $quant,
> > =A0 =A0 price =3D> $price };
>
> > =A0 =A0}
>
> > How to do it?
>
> "Something wrong" is not a useful problem description.
>
> Add:
> use warnings;
> use strict;
> use Data::Dumper;
>
> Report the output of:
>
> print Dumper \%hash;
>
> after doing some operations and explain why it is different from what
> you expect.

Also, based on a wild guess at your code, don't you
want:
           $hash{ $codart }{ q } +=3D $quant;

instead of ++


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

Date: Thu, 24 Mar 2011 08:53:24 -0700 (PDT)
From: Kill Joy <g.ricioppo@gmail.com>
Subject: Re: hash of hashes
Message-Id: <274bc5b3-cf37-43f6-8604-8c459f040dc5@l18g2000yqm.googlegroups.com>

Hi all.

Many thanks for your previous replies.

I heva an Excel (XLS) file with this structure:

A          C  D E F G         H         I       L           M
N      O
03/01/2011 CO 1 1 S 501.01902 CLIENT 100000	Prod A      PZ	  1
33,3300
03/01/2011 CO 1 2 S 501.01902 CLIENT 099000	Prod C      PZ	  1
12,5000
03/01/2011 CO 1 3 S 501.01902 CLIENT 088004	Prod B      PZ	  1
20,8300
03/01/2011 CO 1 4 S 501.01902 CLIENT 087003	Prod C      PZ	  1
12,5000
03/01/2011 CO 1 5 S 501.01902 CLIENT 088004	Prod B      PZ	  1
20,8300
03/01/2011 CO 1 6 S 501.01902 CLIENT 100000	Prod A      PZ	  1
33,3300
03/01/2011 CO 1 7 S 501.01902 CLIENT 099000	Prod C      PZ	  1
12,5000

I read it with
my $Excel = Win32::OLE->GetActiveObject('Excel.Application') ||
Win32::OLE->new('Excel.Application', 'Quit');

And I loop through it.

foreach my $row (1..4000)
{
 foreach my $col (1..12)
 {
  # skip empty cells
  next unless defined $Sheet->Cells($row,$col)->{'Value'};

   # I need fields I, N, L and O
  if ($col == 8) {

   $codart =  $Sheet->Cells($row,$col)->{'Formula'};

   } elsif ($col == 9) {

   $desc =  $Sheet->Cells($row,$col)->{'Formula'};

   } elsif ($col == 10) {

   $quant =  $Sheet->Cells($row,$col)->{'Formula'};

   } elsif ($col == 11) {

   $price =  $Sheet->Cells($row,$col)->{'Formula'};
   }


my $qq;

  if (exists  $hash{ $codart }) {
          # I want to count the occurrences of $hash{ $codart }
          $hash{ $codart }{ q } += $quant; # increment the quantity of
this article
	  print "\n$codart: $hash{ $codart }{ q } EXISTS\n";
  } else {

     # creare the new article
   $hash{ $codart } = {
    desc  => $desc,
    quant    => $quant,
    price => $price
    };

  }

 } # col for
} # row for


I want a data structure
like this

$VAR1 = {
          '100000' => {
            'price' => '33.3',
            'quant' => 2,
            'desc' => 'Prod A'},

{
          '088004' => {
            'price' => '20.83',
            'quant' => 2,
            'desc' => 'Prod B'},

and so on...

How to do it?

Many thanks.

Regards.

Gius.


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

Date: Thu, 24 Mar 2011 18:28:04 +0200
From: George Mpouras <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: hash of hashes
Message-Id: <imfrel$21vi$1@news.ntua.gr>

Στις 24/3/2011 5:53 μμ, ο/η Kill Joy έγραψε:
> A          C  D E F G         H         I       L           M
> N      O
> 03/01/2011 CO 1 1 S 501.01902 CLIENT 100000	Prod A      PZ	  1
> 33,3300
> 03/01/2011 CO 1 2 S 501.01902 CLIENT 099000	Prod C      PZ	  1
> 12,5000
> 03/01/2011 CO 1 3 S 501.01902 CLIENT 088004	Prod B      PZ	  1
> 20,8300
> 03/01/2011 CO 1 4 S 501.01902 CLIENT 087003	Prod C      PZ	  1
> 12,5000
> 03/01/2011 CO 1 5 S 501.01902 CLIENT 088004	Prod B      PZ	  1
> 20,8300
> 03/01/2011 CO 1 6 S 501.01902 CLIENT 100000	Prod A      PZ	  1
> 33,3300
> 03/01/2011 CO 1 7 S 501.01902 CLIENT 099000	Prod C      PZ	  1
> 12,5000
>









#!/usr/bin/perl
use Data::Dumper;$Data::Dumper::Terse=1;$Data::Dumper::Deepcopy=1;
my %hash;

while(<DATA>) {
chomp;$_=[split /\|/];
$hash{$_->[7]}={
'price' => $_->[11],
'quant' => $_->[2],
'desc'  => $_->[8]};
}

print Dumper(\%hash);

__DATA__
03/01/2011|CO|1|1|S|501.01902|CLIENT|100000|Prod A|PZ|1|33,3300
03/01/2011|CO|1|2|S|501.01902|CLIENT|099000|Prod C|PZ|1|12,5000
03/01/2011|CO|1|3|S|501.01902|CLIENT|088004|Prod B|PZ|1|20,8300
03/01/2011|CO|1|4|S|501.01902|CLIENT|087003|Prod C|PZ|1|12,5000
03/01/2011|CO|1|5|S|501.01902|CLIENT|088004|Prod B|PZ|1|20,8300
03/01/2011|CO|1|6|S|501.01902|CLIENT|100000|Prod A|PZ|1|33,3300
03/01/2011|CO|1|7|S|501.01902|CLIENT|099000|Prod C|PZ|1|12,5000


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

Date: Thu, 24 Mar 2011 10:06:41 -0700 (PDT)
From: bobbi <rwv0115@gmail.com>
Subject: Re: hash of hashes
Message-Id: <f9f17d12-2d1c-4e5e-91d0-cbfc2eceba7f@z27g2000prz.googlegroups.com>

On Mar 24, 11:53=A0am, Kill Joy <g.ricio...@gmail.com> wrote:
> Hi all.
>
> Many thanks for your previous replies.
>
> I heva an Excel (XLS) file with this structure:
>
> A =A0 =A0 =A0 =A0 =A0C =A0D E F G =A0 =A0 =A0 =A0 H =A0 =A0 =A0 =A0 I =A0=
 =A0 =A0 L =A0 =A0 =A0 =A0 =A0 M
> N =A0 =A0 =A0O
> 03/01/2011 CO 1 1 S 501.01902 CLIENT 100000 =A0 =A0 Prod A =A0 =A0 =A0PZ =
=A0 =A01
> 33,3300
> 03/01/2011 CO 1 2 S 501.01902 CLIENT 099000 =A0 =A0 Prod C =A0 =A0 =A0PZ =
=A0 =A01
> 12,5000
> 03/01/2011 CO 1 3 S 501.01902 CLIENT 088004 =A0 =A0 Prod B =A0 =A0 =A0PZ =
=A0 =A01
> 20,8300
> 03/01/2011 CO 1 4 S 501.01902 CLIENT 087003 =A0 =A0 Prod C =A0 =A0 =A0PZ =
=A0 =A01
> 12,5000
> 03/01/2011 CO 1 5 S 501.01902 CLIENT 088004 =A0 =A0 Prod B =A0 =A0 =A0PZ =
=A0 =A01
> 20,8300
> 03/01/2011 CO 1 6 S 501.01902 CLIENT 100000 =A0 =A0 Prod A =A0 =A0 =A0PZ =
=A0 =A01
> 33,3300
> 03/01/2011 CO 1 7 S 501.01902 CLIENT 099000 =A0 =A0 Prod C =A0 =A0 =A0PZ =
=A0 =A01
> 12,5000
>
> I read it with
> my $Excel =3D Win32::OLE->GetActiveObject('Excel.Application') ||
> Win32::OLE->new('Excel.Application', 'Quit');
>
> And I loop through it.
>
> foreach my $row (1..4000)
> {
> =A0foreach my $col (1..12)
> =A0{
> =A0 # skip empty cells
> =A0 next unless defined $Sheet->Cells($row,$col)->{'Value'};
>
> =A0 =A0# I need fields I, N, L and O
> =A0 if ($col =3D=3D 8) {
>
> =A0 =A0$codart =3D =A0$Sheet->Cells($row,$col)->{'Formula'};
>
> =A0 =A0} elsif ($col =3D=3D 9) {
>
> =A0 =A0$desc =3D =A0$Sheet->Cells($row,$col)->{'Formula'};
>
> =A0 =A0} elsif ($col =3D=3D 10) {
>
> =A0 =A0$quant =3D =A0$Sheet->Cells($row,$col)->{'Formula'};
>
> =A0 =A0} elsif ($col =3D=3D 11) {
>
> =A0 =A0$price =3D =A0$Sheet->Cells($row,$col)->{'Formula'};
> =A0 =A0}
>
> my $qq;
>
> =A0 if (exists =A0$hash{ $codart }) {
> =A0 =A0 =A0 =A0 =A0 # I want to count the occurrences of $hash{ $codart }
> =A0 =A0 =A0 =A0 =A0 $hash{ $codart }{ q } +=3D $quant; # increment the qu=
antity of
> this article
> =A0 =A0 =A0 =A0 =A0 print "\n$codart: $hash{ $codart }{ q } EXISTS\n";
> =A0 } else {
>
> =A0 =A0 =A0# creare the new article
> =A0 =A0$hash{ $codart } =3D {
> =A0 =A0 desc =A0=3D> $desc,
> =A0 =A0 quant =A0 =A0=3D> $quant,
> =A0 =A0 price =3D> $price
> =A0 =A0 };
>
> =A0 }
>
> =A0} # col for
>
> } # row for
>
> I want a data structure
> like this
>
> $VAR1 =3D {
> =A0 =A0 =A0 =A0 =A0 '100000' =3D> {
> =A0 =A0 =A0 =A0 =A0 =A0 'price' =3D> '33.3',
> =A0 =A0 =A0 =A0 =A0 =A0 'quant' =3D> 2,
> =A0 =A0 =A0 =A0 =A0 =A0 'desc' =3D> 'Prod A'},
>
> {
> =A0 =A0 =A0 =A0 =A0 '088004' =3D> {
> =A0 =A0 =A0 =A0 =A0 =A0 'price' =3D> '20.83',
> =A0 =A0 =A0 =A0 =A0 =A0 'quant' =3D> 2,
> =A0 =A0 =A0 =A0 =A0 =A0 'desc' =3D> 'Prod B'},
>
> and so on...
>
> How to do it?
>
> Many thanks.
>
> Regards.
>
> Gius.

Still not quite sure what you are doing with quant, qq, q:
# I want to count the occurrences of $hash{ $codart }

Are you adding the number from the spreadsheet or counting
the number of times you see the same codart?
If both you need two hash keys:

exists:
   $hash{ $codart }{ q }++;
   $hash{ $codart }{ quant } +=3D $quant;

1st time:
     # create the new article
   $hash{ $codart } =3D {
    desc  =3D> $desc,
    quant    =3D> $quant,   # total quantity
    q =3D> 1,               # number of occurrences
    price =3D> $price,
    };



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

Date: Thu, 24 Mar 2011 16:38:47 +0000
From: Justin C <justin.1102@purestblue.com>
Subject: Re: hash of hashes
Message-Id: <nl8s58-m7q.ln1@zem.masonsmusic.co.uk>

On 2011-03-24, Kill Joy <g.ricioppo@gmail.com> wrote:
> Hi all.
>
> Many thanks for your previous replies.
>
> I heva an Excel (XLS) file with this structure:

You appear to have something quite close to what you want. What is it
doing that it shouldn't, what isn't it doing that it should?

I've no experience with the module you're using, I've had a lot of
success with Spreadsheet::ParseExcel if the module is not working as
you'd like it to.

   Justin.

-- 
Justin C, by the sea.


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

Date: Thu, 24 Mar 2011 12:29:22 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Netiquette (was: using File::Find)
Message-Id: <slrniomaoi.6jb.hjp-usenet2@hrunkner.hjp.at>

On 2011-03-24 08:23, Uno <Uno@example.invalid> wrote:
> On 03/24/2011 12:18 AM, Uri Guttman wrote:

[a typical Uri-vs-Newbie thread]


> Well I look forward to us spending more quality time with each other.
>
>
> cpan[1]> install News::NNTPClient
[lots of errors]

This doesn't seem to have anything to do with either the original topic
of the thread ("using File::Find" as the subject line still states) or
your quarrel with Uri.

If you start a completely new topic, please start a new thread with a
descriptive subject.

	hp


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

Date: Thu, 24 Mar 2011 07:05:14 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Perl script running external command
Message-Id: <fe223d83-e706-4135-92cc-efc7b199d510@o21g2000prh.googlegroups.com>

On Mar 24, 5:22=A0am, Justin C <justin.1...@purestblue.com> wrote:
> Maybe they've done something with ssh?

According to 'them' (the network guys) they've done nothing to the
server.

> What happens if you, from the command line, "ssh username@[dottedquad]"?
> I would expect a very similar error.

I have three machines, my desktop, the current server, and the new
server. I can hit the remote box with WinSCP on my desktop and the
current server and the current server, but not the new server.

I can't ping the remote site and never have been, but that's never
been a problem.

> Can you still ping that IP?

I can't ping the remote site and never have been, but that's never
been a problem.

> If you can't ssh into the box then you're not going to be able to scp
> either, pscp is just an scp wrapper/clone (PuTTY for anyone not
> familiar). At least you'll have something with which to go to the
> hardware guys, and put the problem back in their court.

This morning, I ran three different test on all three machines,
documented the results, turned it over to the network guys, and washed
my hands of the problem. My code works, and the software works -- it's
the machine that doesn't work.

CC.


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

Date: Thu, 24 Mar 2011 12:20:42 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: using File::Find
Message-Id: <slrnioma8a.6jb.hjp-usenet2@hrunkner.hjp.at>

On 2011-03-24 09:16, Uno <Uno@example.invalid> wrote:
> This recent one might, but again I have trouble seeing the basic control:

[...]

> Do you have a context to see some output for this?

Sorry, I don't understand what you are talking about. You have to be
clearer.

	hp



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

Date: Thu, 24 Mar 2011 07:27:17 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: using File::Find
Message-Id: <slrniomdrq.22q.tadmc@tadbox.sbcglobal.net>

Dave Saville <dave@invalid.invalid> wrote:
> On Wed, 23 Mar 2011 03:07:24 UTC, Tad McClellan <tadmc@seesig.invalid>
> wrote:
>
>> Uno <Uno@example.invalid> wrote:
>> > I just installed perldoc on my machine and wanted to go take a look at 
>> > it, to see where it is and what it looks like.  For example, I wrote:
>> >
>> > $ whereis perlretut
               ^^^^^^^^^
               ^^^^^^^^^
>> 
>> 
>> perldoc will tell you where the docs are if you ask it to...
>> 
>>     perldoc perldoc
>> 
>>     perldoc -l perlretut
>> 
>
> Yeah, *if* you know what you want, what perl calls it, 


We could see that this poster *did* know those things.


> and what 
> switches perldoc needs to find it. :-( 


That's why my followup included "perldoc perldoc".


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Thu, 24 Mar 2011 07:30:13 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: using File::Find
Message-Id: <slrniome1a.22q.tadmc@tadbox.sbcglobal.net>

Uno <Uno@example.invalid> wrote:


> he 
> shouldn't have taken that giant dump on mine.


If you don't want your code to be commented on, then do not
post your code on Usenet.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Thu, 24 Mar 2011 21:20:25 +0000 (UTC)
From: pacman@kosh.dhis.org (Alan Curry)
Subject: Re: using File::Find
Message-Id: <imgcip$muh$1@speranza.aioe.org>

In article <8v00jcFmv7U1@mid.individual.net>, Uno  <Uno@example.invalid> wrote:
>On 03/23/2011 01:18 AM, Alan Curry wrote:
>> In article<8ust1tFaaU1@mid.individual.net>, Uno<Uno@example.invalid>  wrote:
>
>>> It seems to me that $name should be giving me the name of a file in the
>>> directory, not the directory itself.  It also seems to me unlikely that
>>> this directory would be born today, and later than its contents.
>>
>> Wow, the densely packed misconceptions! First of all, in File::Find, just as
>> in find(1), the "directory itself" is a legitimate part of the search output.
>> There's no reason why "/usr/share/man/man1" can't be the answer to "what is
>> the youngest file found under /usr/share/man/man1?"... Directories are files
>> too. If you want to exclude them, put "return if -d" at the top of your
>> filter function.
>
>I can pack them in can't I?  I'm very confused still:
>$ cat find2.pl
>#! usr/bin/perl -w
>use strict;
>use File::Find;
>@ARGV = (".") unless @ARGV;
>my ($age, $name);
>sub youngest {
>     return if -d;
>     $age = (stat(_))[9];
>     $name = $File::Find::name;
>}
>find(\&youngest, @ARGV);
>print "$name " . scalar(localtime($age)) . "\n";

And now we've found my misconception. I thought you had written the original
script. It was nearly functional, with a couple of mistakes, so you'd be able
to finish it once those mistakes were identified. But I was wrong, you're not
trying to fix an almost-working script that you wrote. You're posting code
from a book that you've broken by trying to modify it without understanding
anything about what it was doing in the first place. That's a dumb game. I
don't want to play.

-- 
Alan Curry


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

Date: Thu, 24 Mar 2011 12:57:40 -0700 (PDT)
From: Ironhide <gourabbaksi@gmail.com>
Subject: writing to different offsets of a file in parallel
Message-Id: <1eab91bf-2b35-46a4-88d1-d44d69c88e3f@d26g2000prn.googlegroups.com>

perl-newbie, so please excuse if this is trivial

I need a simple way to write to different offsets of a file in
parallel.
How can I achieve that with perl?

thanks for your help in advance


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

Date: Thu, 24 Mar 2011 16:03:44 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: writing to different offsets of a file in parallel
Message-Id: <8762r8i8v3.fsf@quad.sysarch.com>

>>>>> "I" == Ironhide  <gourabbaksi@gmail.com> writes:

  I> perl-newbie, so please excuse if this is trivial
  I> I need a simple way to write to different offsets of a file in
  I> parallel.

  I> How can I achieve that with perl?

before you code it in any language, please clarify what your goals
are. why do you need or want to do this? what do you mean by parallel?
anything done is parallel is not simple in general. you need to be much
better at explaining your problem (which is usually half the work in
getting it solved).

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Thu, 24 Mar 2011 13:17:32 -0700 (PDT)
From: Ironhide <gourabbaksi@gmail.com>
Subject: Re: writing to different offsets of a file in parallel
Message-Id: <bea26e0a-061e-454b-8a29-a8d4aa28060c@x8g2000prh.googlegroups.com>

On Mar 25, 1:03=A0am, "Uri Guttman" <u...@StemSystems.com> wrote:
> >>>>> "I" =3D=3D Ironhide =A0<gourabba...@gmail.com> writes:
>
> =A0 I> perl-newbie, so please excuse if this is trivial
> =A0 I> I need a simple way to write to different offsets of a file in
> =A0 I> parallel.
>
> =A0 I> How can I achieve that with perl?
>
> before you code it in any language, please clarify what your goals
> are. why do you need or want to do this? what do you mean by parallel?
> anything done is parallel is not simple in general. you need to be much
> better at explaining your problem (which is usually half the work in
> getting it solved).
>
> uri
>
> --
> Uri Guttman =A0------ =A0u...@stemsystems.com =A0-------- =A0http://www.s=
ysarch.com--
> ----- =A0Perl Code Review , Architecture, Development, Training, Support =
------
> --------- =A0Gourmet Hot Cocoa Mix =A0---- =A0http://bestfriendscocoa.com=
---------

Well so here goes
I am trying to write unique pattern to every file block, block size is
512 bytes in this case.

So if do this in perl

my $hell=3Dgenerate_pattern($file_block_number);

for($i=3D0;$i<=3D(total_blocks-1);$i++) {
  system("/iotool seek=3D(512*$i) bs=3D512 pattern=3D$hell filename SIZE");
}
Seems to be taking much more time than if I simply fire the command
from the unix command line,
which is pretty obvious.

So, since I have to coding up the i/o part in a perl script, I was
wondering if I could make
this write thingy happen in parallel since I have the benefit of
writing different offsets.

Hope this explains the problem.

thanks again..

_gourab


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

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:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 3332
***************************************


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