[32070] in Perl-Users-Digest
Perl-Users Digest, Issue: 3334 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 25 18:09:31 2011
Date: Fri, 25 Mar 2011 15:09:14 -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 Fri, 25 Mar 2011 Volume: 11 Number: 3334
Today's topics:
Re: Clarification: Perl drops first argv[0] parameter w <nospam-abuse@ilyaz.org>
Re: Clarification: Perl drops first argv[0] parameter w <clint.olsen@gmail.com>
Re: Clarification: Perl drops first argv[0] parameter w <hjp-usenet2@hjp.at>
Re: Clarification: Perl drops first argv[0] parameter w <clint.olsen@gmail.com>
Re: Clarification: Perl drops first argv[0] parameter w <derykus@gmail.com>
Re: How to avoid searching this folder? geoff@invalid.invalid
Re: How to avoid searching this folder? <josef.moellers@ts.fujitsu.com>
Re: How to avoid searching this folder? <jimsgibson@gmail.com>
Re: How to avoid searching this folder? geoff@invalid.invalid
Re: How to avoid searching this folder? geoff@invalid.invalid
Re: How to avoid searching this folder? geoff@invalid.invalid
Re: Parsing some pdf files failed <ldolan@thinkinghatbigpond.net.au>
Re: Perl drops first argv[0] parameter when being calle <clint.olsen@gmail.com>
Re: Perl drops first argv[0] parameter when being calle (Randal L. Schwartz)
Re: Perl drops first argv[0] parameter when being calle <clint.olsen@gmail.com>
Problem <misio867@gmail.com>
Re: using File::Find <ralph@happydays.com>
Re: writing to different offsets of a file in parallel <hjp-usenet2@hjp.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 25 Mar 2011 15:16:39 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Clarification: Perl drops first argv[0] parameter when being called via execv()
Message-Id: <slrniopcen.gc0.nospam-abuse@powdermilk.math.berkeley.edu>
On 2011-03-25, Clint O <clint.olsen@gmail.com> wrote:
> Even though Perl offers the exec { path } @args call, I notice it drops the first parameter in @args: It's not captured in $0 nor is it available in @ARGV. Is this value available anywhere? I also checked $^X, but this usually is the interpreter at the top of the Perl script (#!/path/to/interpreter).
I noticed that your question is so badly formulated that people who do
not read your code carefully misinterpret it.
So the question is: suppose that
/bin/perl myscript.pl
is CALLED with C's argv[0] being "baz". The question is not about how
to implement this call in Perl. It is: How can myscript.pl find the
value of "baz"?
My conjectural answer: if it is not in $^X, tough luck...
Ilya
------------------------------
Date: Fri, 25 Mar 2011 09:06:15 -0700 (PDT)
From: Clint O <clint.olsen@gmail.com>
Subject: Re: Clarification: Perl drops first argv[0] parameter when being called via execv()
Message-Id: <e21d65bf-49c3-4b79-a3b9-7b9f0ffba70c@glegroupsg2000goo.googlegroups.com>
On Friday, March 25, 2011 8:16:39 AM UTC-7, Ilya Zakharevich wrote:
> So the question is: suppose that
>
> /bin/perl myscript.pl
>
> is CALLED with C's argv[0] being "baz". The question is not about how
> to implement this call in Perl. It is: How can myscript.pl find the
> value of "baz"?
>
> My conjectural answer: if it is not in $^X, tough luck...
Frankly I don't see how your explanation is oh so much clearer. I posted the scripts intentionally so that I could demonstrate the behavior I am seeing. Rather than blather about, I posted an example.
-Clint
------------------------------
Date: Fri, 25 Mar 2011 17:35:26 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Clarification: Perl drops first argv[0] parameter when being called via execv()
Message-Id: <slrnioph2e.nct.hjp-usenet2@hrunkner.hjp.at>
On 2011-03-25 15:16, Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> On 2011-03-25, Clint O <clint.olsen@gmail.com> wrote:
>> Even though Perl offers the exec { path } @args call, I notice it
>> drops the first parameter in @args: It's not captured in $0 nor is it
>> available in @ARGV. Is this value available anywhere? I also
>> checked $^X, but this usually is the interpreter at the top of the
>> Perl script (#!/path/to/interpreter).
>
> I noticed that your question is so badly formulated that people who do
> not read your code carefully misinterpret it.
>
> So the question is: suppose that
>
> /bin/perl myscript.pl
>
> is CALLED with C's argv[0] being "baz". The question is not about how
> to implement this call in Perl. It is: How can myscript.pl find the
> value of "baz"?
I think this is impossible. If the C program calls
execl("myscript.pl", "baz", "arg1", "arg2", NULL);
the kernel will notice the shebang in "myscript.pl" and invoke
execl("/bin/perl", "myscript.pl", "arg1", "arg2", NULL);
instead (well, execve actually, but you get the point).
So the information that argv[0] was "baz" originally is lost and there
is no way to restore it.
If myscript.pl is invoked by a shell, you may find the original argv[0]
in the environment variable "_", but that's a convention of some shells,
not something enforced by the OS.
hp
------------------------------
Date: Fri, 25 Mar 2011 10:04:00 -0700 (PDT)
From: Clint O <clint.olsen@gmail.com>
Subject: Re: Clarification: Perl drops first argv[0] parameter when being called via execv()
Message-Id: <133996d9-efe1-4fe2-8b0a-d050956f9187@glegroupsg2000goo.googlegroups.com>
On Friday, March 25, 2011 9:35:26 AM UTC-7, Peter J. Holzer wrote:
> I think this is impossible. If the C program calls
>
> execl("myscript.pl", "baz", "arg1", "arg2", NULL);
>
> the kernel will notice the shebang in "myscript.pl" and invoke
>
> execl("/bin/perl", "myscript.pl", "arg1", "arg2", NULL);
>
> instead (well, execve actually, but you get the point).
>
> So the information that argv[0] was "baz" originally is lost and there
> is no way to restore it.
>
> If myscript.pl is invoked by a shell, you may find the original argv[0]
> in the environment variable "_", but that's a convention of some shells,
> not something enforced by the OS.
Your suggestion did give me an idea, however. If I chose to select the interpreter myself, then perhaps I can recover the argument:
% cat /tmp/foo
#!/home/utils/perl-5.10/5.10.1-nothreads-64/bin/perl
#exec { "$ARGV[0]" } @ARGV[1..$#ARGV];
exec { "/home/utils/perl-5.10/5.10.1-nothreads-64/bin/perl" } "perl", @ARGV;
print "$!\n";
% /tmp/foo /tmp/args.pl hoohah boohah
I am /tmp/args.pl hoohahboohah
So, it would be possible for me to recover "hoohah" from @ARGV in this calling style.
Thanks,
-Clint
------------------------------
Date: Fri, 25 Mar 2011 12:29:19 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Clarification: Perl drops first argv[0] parameter when being called via execv()
Message-Id: <00bb65eb-3bce-4a5a-b8d0-87542e2e0785@y31g2000prd.googlegroups.com>
On Mar 25, 10:04=A0am, Clint O <clint.ol...@gmail.com> wrote:
> On Friday, March 25, 2011 9:35:26 AM UTC-7, Peter J. Holzer wrote:
> > I think this is impossible. If the C program calls
>
> > execl("myscript.pl", "baz", "arg1", "arg2", NULL);
>
> > the kernel will notice the shebang in =A0"myscript.pl" and invoke
>
> > execl("/bin/perl", "myscript.pl", "arg1", "arg2", NULL);
>
> > instead (well, execve actually, but you get the point).
>
> > So the information that argv[0] was "baz" originally is lost and there
> > is no way to restore it.
>
> > If myscript.pl is invoked by a shell, you may find the original argv[0]
> > in the environment variable "_", but that's a convention of some shells=
,
> > not something enforced by the OS.
>
> Your suggestion did give me an idea, however. =A0If I chose to select the=
interpreter myself, then perhaps I can recover the argument:
>
> % cat /tmp/foo
> #!/home/utils/perl-5.10/5.10.1-nothreads-64/bin/perl
>
> #exec { "$ARGV[0]" } @ARGV[1..$#ARGV];
> exec { "/home/utils/perl-5.10/5.10.1-nothreads-64/bin/perl" } "perl", @AR=
GV;
>
> print "$!\n";
>
> % /tmp/foo /tmp/args.pl hoohah boohah
> I am /tmp/args.pl hoohahboohah
>
> So, it would be possible for me to recover "hoohah" from @ARGV in this ca=
lling style.
>
The earlier, original argument list is available
with exec's indirect object format too. You just
need an initial "name I'm running as" argument:
exec { "$ARGV[0]" } 'XXXX',@ARGV[1..$#ARGV];
--
Charles DeRykus
------------------------------
Date: Fri, 25 Mar 2011 13:12:15 +0000
From: geoff@invalid.invalid
Subject: Re: How to avoid searching this folder?
Message-Id: <e25po69kuv98u0l32ljc5su9lj3c4cnop8@4ax.com>
On Fri, 25 Mar 2011 07:51:44 -0500, Tad McClellan
<tadmc@seesig.invalid> wrote:
>geoff@invalid.invalid <geoff@invalid.invalid> wrote:
>
>> if (($entry != "archives") && (-d "$path/$entry")) {
> ^^^^^^^^^^^^^^^^^^^^
>
>You are comparing them as numbers, so each string is converted
>into a number before the comparison is tested.
Thanks tad. I changed to ne but still produces an empty file.
I have tried
unless (($entry !~ /members/i) && (-d "$path/$entry")) {
&update("$path/$entry", "$webpath/$entry");
next;
}
but still no go! I guess my logic is wrong?
Cheers
Geoff
>
>You end up testing
>
> 0 != 0
>
>which will *always* be false.
>
>The "ne" operator is for comparing strings.
>
>The "!=" operator is for comparing numbers.
------------------------------
Date: Fri, 25 Mar 2011 15:11:58 +0100
From: Josef Moellers <josef.moellers@ts.fujitsu.com>
Subject: Re: How to avoid searching this folder?
Message-Id: <imi7re$3jh$1@nntp.fujitsu-siemens.com>
Am 25.3.2011 schrub geoff:
> On Fri, 25 Mar 2011 11:17:13 +0100, Josef Moellers
> <josef.moellers@ts.fujitsu.com> wrote:
>
>> Am 25.3.2011 schrub geoff:
>>
>>> Hello
>>>
>>> I am using Tom Boutell's simple search engine on my website but would
>>> like it to not index the files in a particular folder called archives.
>>>
>>> How would I modify the code for this? I have tried and so far failed.
>>
>> You're usually expected to explain/show what you've tried so far ...
>
> Joseph
>
> I have tried this too
>
> #if (-d "$path/$entry") {
> #&update("$path/$entry", "$webpath/$entry");
> #next;
> #}
>
> if (($entry != "archives") && (-d "$path/$entry")) {
> &update("$path/$entry", "$webpath/$entry");
> next;
> }
>
> thinking that so long as the $entry is not a directory called archives
> the code will continue ... still no go.
Tad commented about the "!=" vs "ne".
What about case? Maybe the name isn't spelled "archives" but "ARCHIVES"?
Try "if ((lc($entry) ne "archives") && (-d "$path/$entry"))"
Also: have a look at File::Find. You may be re-inventing the wheel.
NB you can drop the "&" in front of the function call.
Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html
------------------------------
Date: Fri, 25 Mar 2011 08:36:43 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: How to avoid searching this folder?
Message-Id: <250320110836434642%jimsgibson@gmail.com>
In article <kgtoo6hfo0sdu6cua98cdk6opalei2ud99@4ax.com>,
<geoff@invalid.invalid> wrote:
> On Fri, 25 Mar 2011 11:17:13 +0100, Josef Moellers
> <josef.moellers@ts.fujitsu.com> wrote:
>
> I have tried this too
>
> if (($entry != "archives") && (-d "$path/$entry")) {
> &update("$path/$entry", "$webpath/$entry");
> next;
> }
>
> thinking that so long as the $entry is not a directory called archives
> the code will continue ... still no go.
Try this:
if ( -d "$path/$entry")) {
next if $entry =~ /archive/i;
update("$path/$entry", "$webpath/$entry");
next;
}
--
Jim Gibson
------------------------------
Date: Fri, 25 Mar 2011 15:44:14 +0000
From: geoff@invalid.invalid
Subject: Re: How to avoid searching this folder?
Message-Id: <5sdpo65edmdmqsugd956r91dmb1h7vnej5@4ax.com>
On Fri, 25 Mar 2011 15:11:58 +0100, Josef Moellers
<josef.moellers@ts.fujitsu.com> wrote:
>Tad commented about the "!=" vs "ne".
>
>What about case? Maybe the name isn't spelled "archives" but "ARCHIVES"?
>Try "if ((lc($entry) ne "archives") && (-d "$path/$entry"))"
Joseph,
I tried the above but the code does not work - it produces an empty
searchindex.txt file.
Maybe I have got the wrong approach - could you please look at this
part of the code again and suggest how it should be changed to avoid
indexing the archives folder?
sub update {
my($path, $webpath) = @_;
my($dd) = $nextFd++;
print "Updating in $path\n";
if (!opendir($dd, $path)) {
print STDERR "Warning: can't open $path\n";
return;
}
while ($entry = readdir($dd)) {
if ($entry =~ /^\.$/) {
next;
}
if ($entry =~ /^\.\.$/) {
next;
}
if (-d "$path/$entry") {
&update("$path/$entry", "$webpath/$entry");
next;
}
if (($entry !~ /.html$/i) && ($entry !~ /.htm$/i)) {
next;
}
my($fd) = $nextFd++;
if (!open($fd, "$path/$entry")) {
print STDERR "Warning: can't open
$path/$entry\n";
next;
}
my(%words) = ( );
my($line);
while ($line = <$fd>) {
>
>Also: have a look at File::Find. You may be re-inventing the wheel.
I don't think I would dare do this at the moment!
Cheers
Geoff
>
>NB you can drop the "&" in front of the function call.
>Josef
------------------------------
Date: Fri, 25 Mar 2011 15:56:02 +0000
From: geoff@invalid.invalid
Subject: Re: How to avoid searching this folder?
Message-Id: <hkepo61opeh4it8kehvi1ouace1pccu4cn@4ax.com>
On Fri, 25 Mar 2011 15:11:58 +0100, Josef Moellers
<josef.moellers@ts.fujitsu.com> wrote:
Joseph,
I seem to have got this now!
if ($entry ne "archives" ) {
if (-d "$path/$entry") {
&update("$path/$entry", "$webpath/$entry");
next;
}
}
The above now avoids the archives folder.
Cheers
Geoff
------------------------------
Date: Fri, 25 Mar 2011 16:17:20 +0000
From: geoff@invalid.invalid
Subject: Re: How to avoid searching this folder?
Message-Id: <bvfpo6tqlgkuk0j6g2asdejmhfbvb1sbf2@4ax.com>
On Fri, 25 Mar 2011 08:36:43 -0700, Jim Gibson <jimsgibson@gmail.com>
wrote:
>In article <kgtoo6hfo0sdu6cua98cdk6opalei2ud99@4ax.com>,
><geoff@invalid.invalid> wrote:
>
>> On Fri, 25 Mar 2011 11:17:13 +0100, Josef Moellers
>> <josef.moellers@ts.fujitsu.com> wrote:
>>
>> I have tried this too
>>
>> if (($entry != "archives") && (-d "$path/$entry")) {
>> &update("$path/$entry", "$webpath/$entry");
>> next;
>> }
>>
>> thinking that so long as the $entry is not a directory called archives
>> the code will continue ... still no go.
>
>Try this:
>
> if ( -d "$path/$entry")) {
> next if $entry =~ /archive/i;
> update("$path/$entry", "$webpath/$entry");
> next;
> }
Thanks Jim - yours is much neater than my
if ($entry ne "archives" ) {
if (-d "$path/$entry") {
&update("$path/$entry", "$webpath/$entry");
next;
}
}
!
Cheers
Geoff
------------------------------
Date: Sat, 26 Mar 2011 05:55:47 +1100
From: "Peter Jamieson" <ldolan@thinkinghatbigpond.net.au>
Subject: Re: Parsing some pdf files failed
Message-Id: <Py5jp.14131$gM3.11943@viwinnwfe01.internal.bigpond.com>
"Eli the Bearded" <*@eli.users.panix.com> wrote in message
news:eli$1103221605@qz.little-neck.ny.us...
> In comp.lang.perl.misc,
> Peter Jamieson <ldolan@thinkinghatbigpond.net.au> wrote:
>> I am using the following script to parse a collection of
>> supplied pdf files. Most of the files parsed as expected but
>> with some the script fell over, no output was produced,
>> as though the file was invisible. The files are only
>> alpha-numeric text, no images or graphics.
>
> Looks like a CAM:PDF problem.
>
> I modified you script to look like this:
>
> #!/usr/bin/perl -w
> use strict;
> use warnings;
> use CAM::PDF;
>
> my $file = shift;
> my $pdf = CAM::PDF->new($file);
>
> printf "%s: %d pages\n", $file, ($pdf->numPages());
>
> for my $page (1 .. $pdf->numPages()) {
> my $text = $pdf->getPageText($page);
>
> my @lines = split (/\n/, $text);
>
> foreach my $line (@lines) {
> print $line;
> }
> }
> __END__
>
> And plugged in various PDFs I have lying around. One called "Hektor.pdf"
> produces copious non-text output with that script, but pdftotext gives
> me lots of clean text output.
>
> $ perl /tmp/campdfprint Hektor.pdf | strings | wc
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> Use of uninitialized value $text in split at /tmp/campdfprint line 14.
> 1 3 21
> $ pdftotext Hektor.pdf ; strings Hektor.txt |wc
> 161 4023 23930
> $ strings Hektor.pdf |head -1
> %PDF-1.4
> $
>
> Elijah
> ------
> [1] <URL:http://www.hektor.ch/Book/Hektor.pdf/>
> Yes, it has a trailing slash in the link.
> [2] pdftotext version 3.02
> Copyright 1996-2007 Glyph & Cog, LLC
Hi Eli!
Thank you for your comments and assistance.
I had a look at the pdftotext prog but it was
unsuitable as my pdf's had tables and they were
being mangled in the conversion process.
I tried the shareware prog "PDF to Excel" and
it is promising but still needs a bit of cleaning
of the data and the files to be eyeballed, tedious
as I have many files each of many pages.
The pdf files seem to have been created originally
from .xls files so it should be possible to programmitically
reverse them maybe but beyond me.
On an unrelated matter I noticed the links to your
Hektor site: fascinating work! My daughter is a performance
artist and film maker so I will pass your site address to her!
Cheers, Peter
------------------------------
Date: Fri, 25 Mar 2011 09:08:08 -0700 (PDT)
From: Clint O <clint.olsen@gmail.com>
Subject: Re: Perl drops first argv[0] parameter when being called via execv()
Message-Id: <6bcf7aa6-a837-4265-b295-6549db3cfd1e@glegroupsg2000goo.googlegroups.com>
On Friday, March 25, 2011 5:48:11 AM UTC-7, C.DeRykus wrote:
> So, the exec'ed program $ARGV[0] below is being told
> it's a 'dummy' via the first argument:
>
>
> exec { $ARGV[0] } 'dummy', @ARGV[1..$#ARGV];
>
> In your case, your first argument "hoohah" became
> 'dummy'.
Ok, so show me in the exec'd script ($ARGV[0]) where I can recover the string 'dummy'.
Thanks,
-Clint
------------------------------
Date: Fri, 25 Mar 2011 09:37:11 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl drops first argv[0] parameter when being called via execv()
Message-Id: <86wrjnp360.fsf@red.stonehenge.com>
>>>>> "Clint" == Clint O <clint.olsen@gmail.com> writes:
Clint> Ok, so show me in the exec'd script ($ARGV[0]) where I can
Clint> recover the string 'dummy'.
It's the first arg in the execve() call. What your other scripting
language does with that, we may never know.
If that's Perl, it's in $0. Perl maps the incoming argv[] array
to ($0, @ARGV).
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion
------------------------------
Date: Fri, 25 Mar 2011 10:47:01 -0700 (PDT)
From: Clint O <clint.olsen@gmail.com>
Subject: Re: Perl drops first argv[0] parameter when being called via execv()
Message-Id: <fd089932-d5f4-4953-99aa-b77f5255818c@glegroupsg2000goo.googlegroups.com>
On Friday, March 25, 2011 9:37:11 AM UTC-7, Randal L. Schwartz wrote:
>
> It's the first arg in the execve() call. What your other scripting
> language does with that, we may never know.
>
> If that's Perl, it's in $0. Perl maps the incoming argv[] array
> to ($0, @ARGV).
What my example demonstrated was that in a calling convention like:
exec { "/path/to/script.pl" } "first", "second", "third", "fourth";
Inside script.pl, $0 will be "/path/to/script.pl" and @ARGV will contain ( "second", "third", "fourth");
-Clint
------------------------------
Date: Fri, 25 Mar 2011 08:35:21 -0700 (PDT)
From: Buntownik <misio867@gmail.com>
Subject: Problem
Message-Id: <90941d8a-d01f-4688-b3ec-96470cef880d@x1g2000yqb.googlegroups.com>
How to detect file upload abort using an upload hook in perl. When
client aborts the upload i need to remove the info about the file from
the db. I can't do it size base, because before upload ends i only
have an approximate file size (request + file). I'm tryin to use
mod_perl Apache2::Connection->aborted() but so far to no effect.
------------------------------
Date: Fri, 25 Mar 2011 10:59:54 -0400
From: Ralph Malph <ralph@happydays.com>
Subject: Re: using File::Find
Message-Id: <f2bf0$4d8cade5$ce534406$1031@news.eurofeeds.com>
On 3/24/2011 2:18 AM, Uri Guttman wrote:
>>>>>> "U" == Uno<Uno@example.invalid> writes:
>
> U> I have a lot of misconceptions, as I'm even newer to unix than I am
> U> perl, and I don't mind when you take a tone with me, as you also help
> U> as you castigate. That's not true of everyone on usenet.
>
> so if you have misconceptions, shouldn't you learn the culture before
> you go barging in? did you read the posted guidelines here?
ha ha ha. You fucking idiot. Nobody reads that shit.
------------------------------
Date: Fri, 25 Mar 2011 17:16:01 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: writing to different offsets of a file in parallel
Message-Id: <slrniopfu1.nct.hjp-usenet2@hrunkner.hjp.at>
On 2011-03-24 20:17, Ironhide <gourabbaksi@gmail.com> wrote:
>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=generate_pattern($file_block_number);
>
> for($i=0;$i<=(total_blocks-1);$i++) {
> system("/iotool seek=(512*$i) bs=512 pattern=$hell filename SIZE");
> }
Are you invoking an external tool for every 512-byte block here?
If you are then you can probably speed this up by two or three orders of
magnitude by just writing directory to the file.
hp
------------------------------
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 3334
***************************************