[22380] in Perl-Users-Digest
Perl-Users Digest, Issue: 4601 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 21 14:05:44 2003
Date: Fri, 21 Feb 2003 11:05:07 -0800 (PST)
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, 21 Feb 2003 Volume: 10 Number: 4601
Today's topics:
Re: Check for occurrence of element in Array <REMOVEsdnCAPS@comcast.net>
Re: Compare two strings (Andrew Perrin (CLists))
Re: Compare two strings (Tad McClellan)
Re: having PERL respond to a key press <usenet@dwall.fastmail.fm>
How do I get path to .java scripts (Sherman Willden)
Re: How do I get path to .java scripts <nobull@mail.com>
How to simulate real modem connection speed on local ap <beromko@yahoo.com>
Re: How to simulate real modem connection speed on loca <bill.kemp@wire2.com>
Re: join or .= -- which is faster? <crgutierNO@SPAMdcc.uchile.cl>
Re: Perl Compiler? <usenet@dwall.fastmail.fm>
Re: Perl Compiler? <REMOVEsdnCAPS@comcast.net>
Re: Religious question: commenting <erutiurf@web.de>
Re: Religious question: commenting (Anno Siegel)
Setting Environment Variables on Linux (lynto)
Re: Setting Environment Variables on Linux <sfandino@yahoo.com>
Re: Setting Environment Variables on Linux <nobull@mail.com>
Re: storing regex vars into array and not $1 $2 etc <nobull@mail.com>
Re: Switch order of sprintf conversions <nospam1202@joesbox.cjb.net>
Re: Switch order of sprintf conversions (Anno Siegel)
Re: Switch order of sprintf conversions (Jay Tilton)
Re: sysread and length <perl-dvd@darklaser.com>
Re: sysread and length <nobull@mail.com>
Win32API: How to write protect a device? (Sig Murphy)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 21 Feb 2003 11:40:15 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Check for occurrence of element in Array
Message-Id: <Xns932980D6A3B6Asdn.comcast@216.166.71.239>
Barry Kimelman <barryk2@SPAM-KILLER.mts.net> wrote in
news:MPG.18be9f34f5e01dd7989705@news.mts.net:
>
> @array = ( "de", "en", "fr" );
> $value = <STDIN>; # read a value from user
> chomp $value;
> if ( 0 < grep /${value}/,@array ) {
> print "Found it.\n";
> }
> else {
> print "No match.\n";
> }
What if the user just hits <enter>? :-)
--
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
------------------------------
Date: 21 Feb 2003 09:23:47 -0500
From: clists@perrin.socsci.unc.edu (Andrew Perrin (CLists))
Subject: Re: Compare two strings
Message-Id: <84n0kpk8zw.fsf@perrin.socsci.unc.edu>
rob@tevreden.nl (Rob Boerman) writes:
> Hello,
>
> Say I have two strings: 'this question is too simple' and 'is this
> question too simple'
>
> Is there a way to compare these strings lexically and get a 'match
> percentage' or something?
This depends entirely on your conceptual definition of "match".
String::Approx is one approach, but fundamentally you need to figure out what
constitutes "similarity" for your text domain. An example: how similar are
these two sentences?
1.) "I don't know, man, George Bush is just an idiot."
2.) "I don't know if that man, George Bush, is just an idiot."
A word-freqency, and even word-order, approach will tend to classify
these as very similar. A human coder is likely to see them as
significantly different. Depends what you're looking for....
ap
--
----------------------------------------------------------------------
Andrew J Perrin - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
clists@perrin.socsci.unc.edu * andrew_perrin (at) unc.edu
------------------------------
Date: Fri, 21 Feb 2003 07:35:12 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Compare two strings
Message-Id: <slrnb5caog.6t1.tadmc@magna.augustmail.com>
Rob Boerman <rob@tevreden.nl> wrote:
> Is there a way to compare these strings lexically and get a 'match
> percentage' or something?
perldoc -q match
"How can I do approximate matching?"
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 21 Feb 2003 16:20:33 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: having PERL respond to a key press
Message-Id: <Xns93297361F58ACdkwwashere@216.168.3.30>
[TOFU rearranged; please don't top-post. And please don't quote
signatures.]
<tyrannous@o-space.com> wrote on 21 Feb 2003:
> "Helgi Briem" <helgi@decode.is> wrote in message
> news:3e5623bb.1214086494@news.cis.dfn.de...
>> On Thu, 20 Feb 2003 21:14:18 -0000, <tyrannous@o-space.com>
>> wrote:
>>
>> >I want to have perl exit from a WHILE loop when the user
>> >presses a certain key on the keyboard
>>
>> Why are you re-posting this question?
>>
>> Were you not satisfied with the answers you got last time?
>>
>> If not, what was your problem with them?
> none of the ideas worked.
>
> is there any simple way to do this?
Since you're posting with LookOut, it looks like you're using
Windows. The suggestion in the FAQ (Term::ReadKey) works fine for me
with Windows 2000. Did you try it?
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: 21 Feb 2003 09:48:11 -0800
From: sherman.willden@hp.com (Sherman Willden)
Subject: How do I get path to .java scripts
Message-Id: <3a80d8d6.0302210948.28d07266@posting.google.com>
Thanks to everyone who provided assistance with the SourceSafe history
script. Now that I have that working they are going to convert to
ClearCase.
I will use jikes to build the .class files from the .java files and I
want to get the path to each .java file. I do the below but I get the
list output to stdout:
find(sub { /\.java/ && print "$File::Find::name\n" }, $path);
If I do:
my @files = find(sub { /\.java/ && print "$File::Find::name\n" },
$path);
I just get the 0 return code.
How can I get a hash or array of files with the file path? Do I want a
hash or array?
I can get a list of files only by doing:
sub DotJava {
/^\.java/ && print"$_\n";
}
find(\&DotJava,'C:\\dir1\\dir2');
But I still need the path to the file(s).
Thanks;
Sherman
------------------------------
Date: 21 Feb 2003 18:30:46 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How do I get path to .java scripts
Message-Id: <u9n0kpcwq1.fsf@wcl-l.bham.ac.uk>
sherman.willden@hp.com (Sherman Willden) writes:
> Subject: How do I get path to .java scripts
Please put the subject of your post in the Subject of your post. If
in doubt try this simple test. Imagine you could have been bothered
to have done a search before you posted. Next imagine you found a
thread with your subject line. Would you have been able to recognise
it as the same subject?
You Perl question has nothing to do with Java scripts. Your Perl
question has to do with finding files with a given suffix. Surely you
can see that the solution would be identical for finding .zip files!
Your question has nothing to do with getting the paths. You've
already done that bit. Your question has to do with having got the
paths putting them into an array.
I think your real problem is in your ability to partition yout
problem.
> I will use jikes to build the .class files from the .java files and I
> want to get the path to each .java file. I do the below but I get the
> list output to stdout:
>
> find(sub { /\.java/ && print "$File::Find::name\n" }, $path);
BTW you probably meant /\.java$/ not /\.java/
> If I do:
>
> my @files = find(sub { /\.java/ && print "$File::Find::name\n" },
> $path);
>
> I just get the 0 return code.
That is to be expected - see the documentation of find().
> How can I get a hash or array of files with the file path?
That question is pretty much self answering.
The question is how do you get the paths into an array or hash rather
then printing then to stdout?
The answer therefore is that rather than printing the paths to stdout
you should put them into an array or hash.
Could you really not have worked that out for yourself?
Almost certainly your problem is that you tried to look at the problem
as a whole rather than breaking it into parts. If you'd broken your
problem down you'd have realised your question was really "how do I
append something to an array?". This is covered in even the most
basic Perl tutorials so if you really don't know the answer you should
go and work through a couple of very basic tutorials.
<FISH>
Replace:
print "$File::Find::name\n"
with a statement that puts the contents $File::Find::name into an
array or hash. Something like:
push @some_array, $File::Find::name;
</FISH>
> Do I want a hash or array?
Dunno, you tell me. You seem to be claiming you do. (Is this a trick question?)
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 21 Feb 2003 16:43:23 +0200
From: "Roman Khutkyy" <beromko@yahoo.com>
Subject: How to simulate real modem connection speed on local apache server?
Message-Id: <b35dui$12n$1@news.uar.net>
There is a problem in debugging JS script that preloads images
for animated menu on local Apsche server (win32). Id like to see how
this loading going as it was real modem connection. So, is there any module
that can do such things?
------------------------------
Date: Fri, 21 Feb 2003 15:24:13 -0000
From: "W K" <bill.kemp@wire2.com>
Subject: Re: How to simulate real modem connection speed on local apache server?
Message-Id: <uxr5a.77$K7.485@news.uk.colt.net>
"Roman Khutkyy" <beromko@yahoo.com> wrote in message
news:b35dui$12n$1@news.uar.net...
> There is a problem in debugging JS script that preloads images
> for animated menu on local Apsche server (win32). Id like to see how
> this loading going as it was real modem connection. So, is there any
module
> that can do such things?
How about getting a cgi script to read the html file and spit it out bit by
bit.
To make this perl relevant - I'd suggest using "select" instead of "sleep"
and remember to put in $|=1;
------------------------------
Date: Fri, 21 Feb 2003 16:47:45 +0000 (UTC)
From: Cristian Gutierrez <crgutierNO@SPAMdcc.uchile.cl>
Subject: Re: join or .= -- which is faster?
Message-Id: <b35l7h$739$2@helcaraxe.dcc.uchile.cl>
Malte Ubl posteo' asi':
> As far as I know C<$var += 3> is faster than C<$var = $var + 3> because,
> the first is operating on existing memory while the second is doing an
> extra copy. This is of course for numbers where no extra memory has to
> be allocated, but I could still imagine the same to be true for strings.
> I would think that while C<$var = $var."something" > probably compiles
> to a join, that C<$var .= "something"> compiles to some kind of string
> append function.
Premature optimization... yadda yadda..
:)
--
Cristian Gutierrez Linux user #298162
crgutier[@]dcc.uchile.cl http://www.dcc.uchile.cl/~crgutier
A computer without a Microsoft operating system is like a dog without
bricks tied to its head.
------------------------------
Date: Fri, 21 Feb 2003 15:58:47 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perl Compiler?
Message-Id: <Xns93296FB122A36dkwwashere@216.168.3.30>
Joe Creaney <mail@annuna.com> wrote on 20 Feb 2003:
> Is there a perl compilier and linker if so can I get an address.
http://www.cpan.org/ports/
Perl documentation is included when you install Perl, but you can
browse it online as well: http://www.perldoc.com/
The documentation that comes with Perl is what you should use, as the
web documentation may be for a different version than what you have
installed. (For example, perldoc.com has docs for 5.8, but I still
have 5.6 on one machine.) For general purposes it usually doesn't
make much difference.
Re compiling and linking:
"... Perl is frequently (but not always, and certainly not by
definition) an interpreted language, you can write your programs and
test them without an intermediate compilation step, allowing you to
experiment and test/debug quickly and easily."
I seem to recall reading a more explicit answer to "Is Perl compiled
or interpreted", but I don't know where it is now.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Fri, 21 Feb 2003 12:02:54 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Perl Compiler?
Message-Id: <Xns932984ADF2FD9sdn.comcast@216.166.71.239>
Joe Creaney <mail@annuna.com> wrote in news:3E556836.4030509@annuna.com:
> Is there a perl compilier and linker if so can I get an address.
>
It's rude to post questions to technical usenet groups without first
checking the group's FAQ.
--
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
------------------------------
Date: Fri, 21 Feb 2003 16:14:19 +0100
From: Richard Voss <erutiurf@web.de>
Subject: Re: Religious question: commenting
Message-Id: <b35fta$7ch$04$1@news.t-online.com>
Sandman wrote:
> I asked the same question in the PHP group, and those guys all came back with
> some examples on how they comment code. And while there were some guy there
> aswell that focused on the code in the example instead, most of them understodd
> what I wwas asking and answered accordingly.
>
People in PHP groups are used to seeing ugly code, most of them write just such
crap.
> It's not that hard. How do you comment stuff?
I try to write good code and perhaps add a note here and there. It's not that
hard to understand that ;)
--
sub{*O=*Time::HiRes::usleep;require Time::HiRes;unshift@_,(45)x 24,split q=8=
=>55.52.56.49.49.55.56.49.49.53;do{print map(chr,@_[0..(@_/2-1)])=>"\b"x(@_/2
);O(0xA**6/6)=>push@_=>shift}for@_,++$|}->(map{$_+=$_%2?-1:1}map ord,split//,
'u!`onuids!Qdsm!i`bjds')#my email-address is reversed! http://fruiture.de
------------------------------
Date: 21 Feb 2003 17:39:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Religious question: commenting
Message-Id: <b35o83$jvt$1@mamenchi.zrz.TU-Berlin.DE>
Sandman <mr@sandman.net> wrote in comp.lang.perl.misc:
> In article <pan.2003.02.20.16.34.28.738834@aursand.no>,
> "Tore Aursand" <tore@aursand.no> wrote:
>
> > > I disagree. If I ask you where you usually put captions to pictures and
> > > give you a picture and a "blablabla" caption and ask you to place them
> > > together, would you go "Hey, this caption is AQLL wwrong for this
> > > picture! I can't give any general comments on this at all!"?
> >
> > Ofcourse. Why shouldn't he? If it's _obvious_ that the caption doesn't
> > go with the picture, why should he let you commit that foul?
>
> I am not interested in the caption, I am interested in how he, generally,
> places them with pictures.
>
> > It seems to be that you're trying to separate comments from code and vice
> > versa. To me that seems wrong, because sloppy commenting can obfuscate
> > the most elegant code, the same way great commenting can't make up for bad
> > code.
>
> And I am interested in how commenting is done, in general, not with specific
> examples.
>
> > Or - to use the picture/caption relevance; It doesn't matter if the
> > caption says 'George W. Bush' when it's a picture of Saddam Hussein. It's
> > just wrong.
>
> So it would be impossible for you to use that captioning and that picture to
> show me how you generally place captions? Odd.
You appear to claim this thread as some virtual classroom, and for
yourself the role of a teacher. Welcome to Usenet. We are going to
comment on any aspects of your posts that strike our fancy. Posting
deplorable Perl code to a Perl group was a bad move to set off a discussion
about commenting in general.
Anno
------------------------------
Date: 21 Feb 2003 08:45:33 -0800
From: lynch@agere.com (lynto)
Subject: Setting Environment Variables on Linux
Message-Id: <503469eb.0302210845.58255fc6@posting.google.com>
Gettings:
I'm setting $ENV{LD_LIBRARY_PATH} in a script and then do a system
call for a tool called "ddd" (gdb debugger). Like so:
$ENV{'LD_LIBRARY_PATH'} =
"$ENV{'PWD'}/obj:/usr/local/TestBuilder/lib:/usr/local/twb/arch/lib:/usr/local/lib";
system "ddd --command=gdbCMD ncsimC";
The problem is the LD_LIBRARY_PATH isn't getting picked up by "ddd"
and complains about a missing library. I'm running tcsh on linux
redhat 7.2.
Any ideas why this isn't getting passed?
I can do:
print "$ENV{'LD_LIBRARY_PATH'}\n";
this works fine.
but:
system "echo $LD_LIBRARY_PATH";
gets:
Use of uninitialized value in concatenation (.) or string at
/usr/local/perl/llsim line 478.
Thanks for any help in advanced!
Tom
------------------------------
Date: Fri, 21 Feb 2003 18:06:52 +0000
From: =?ISO-8859-1?Q?Salvador_Fandi=F1o_Garc=EDa?= <sfandino@yahoo.com>
Subject: Re: Setting Environment Variables on Linux
Message-Id: <3E566ABC.1060701@yahoo.com>
lynto wrote:
> Gettings:
>
> I'm setting $ENV{LD_LIBRARY_PATH} in a script and then do a system
> call for a tool called "ddd" (gdb debugger). Like so:
>
> $ENV{'LD_LIBRARY_PATH'} =
> "$ENV{'PWD'}/obj:/usr/local/TestBuilder/lib:/usr/local/twb/arch/lib:/usr/local/lib";
>
> system "ddd --command=gdbCMD ncsimC";
>
> The problem is the LD_LIBRARY_PATH isn't getting picked up by "ddd"
> and complains about a missing library. I'm running tcsh on linux
> redhat 7.2.
>
> Any ideas why this isn't getting passed?
>
> I can do:
>
> print "$ENV{'LD_LIBRARY_PATH'}\n";
>
> this works fine.
>
> but:
>
> system "echo $LD_LIBRARY_PATH";
your code is equivalent to
system "echo ".$LD_LIBRARY_PATH;
that is not what you want, try
system 'echo $LD_LIBRARY_PATH';
instead
Bye,
- Salva
------------------------------
Date: 21 Feb 2003 17:05:25 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Setting Environment Variables on Linux
Message-Id: <u98yw9ef8q.fsf@wcl-l.bham.ac.uk>
lynch@agere.com (lynto) writes:
> I'm setting $ENV{LD_LIBRARY_PATH} in a script and then do a system
> call for a tool called "ddd" (gdb debugger). Like so:
>
> $ENV{'LD_LIBRARY_PATH'} =
> "$ENV{'PWD'}/obj:/usr/local/TestBuilder/lib:/usr/local/twb/arch/lib:/usr/local/lib";
>
> system "ddd --command=gdbCMD ncsimC";
>
> The problem is the LD_LIBRARY_PATH isn't getting picked up by "ddd"
> and complains about a missing library.
Does ddd usually pick up LD_LIBRARY_PATH?
> I'm running tcsh on linux redhat 7.2.
What do you mean by that? The Perl system() command uses /bin/sh.
> Any ideas why this isn't getting passed?
> system "echo $LD_LIBRARY_PATH";
>
> Use of uninitialized value in concatenation (.) or string at
> /usr/local/perl/llsim line 478.
And if you use the right quotes...?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 21 Feb 2003 17:18:38 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: storing regex vars into array and not $1 $2 etc
Message-Id: <u94r6xeemp.fsf@wcl-l.bham.ac.uk>
Abigail <abigail@abigail.nl> writes:
> Brian McCauley (nobull@mail.com) wrote on MMMCDLX September MCMXCIII in
> <URL:news:u9r8a2etpm.fsf@wcl-l.bham.ac.uk>:
> ||
> || Never pass $1 et al to functions. They interact in a most unfortunate
> || way with the @_ mechanism.
>
>
> And so do literals.
Not to nearly the same extent.
> One should be aware of the limitations one has when passing
> read-only stuff to functions.
It's not the fact that they are readonly that's significant. It's the
fact that they are global.
> Giving the advice to people not to pass $1 and friend to functions
> is silly.
No. Considering the number of times people have come here with
obscure bugs as a result of doing so I'd say it was quite sensible
advice.
Consider the behaviour of:
sub foo {
for my $wibble ( @_ ) {
print "$wibble\n" if $wibble =~ /X/;
}
}
'1X 2X' =~ /(.+) (.+)/;
foo ( $1 , "$2" );
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 21 Feb 2003 17:58:47 GMT
From: Josef Drexler <nospam1202@joesbox.cjb.net>
Subject: Re: Switch order of sprintf conversions
Message-Id: <b35pcn$7h9$1@panther.uwo.ca>
Anno Siegel wrote:
> I'm amazed the need to rearrange arguments hasn't come up earlier.
>
> To be completely general, you may want to allow any permutation, not
> only reversal. You could store a list of small integers in a hash
> and use a list slice to do the actual rearrangement:
>
> if ( exists $permute{$lang} ) {
> printf( $string, ($one, $more)[ @{ $permute{ $lang}}]);
> }
That's a good idea, but I think it would be more useful to have this
permutation specified as part of the format string, because it will be
necessary in only some instances, and a different permutation may be
necessary for each string.
It would probably be worthwhile to write a substitute for sprintf that
supports the "%2$d" notation of the C sprintf.
Something like
sub sprintfex {
my ($format,@args) = @_;
return sprintf $format, @args unless $format =~ /%\d+\$/;
# rebuild permuted argument list and format
return sprintf $newformat, @newargs;
}
Putting that in a module would be very useful. You'd probably have to
write a parser for the format string though instead of using just a simple
regex...
--
Josef Drexler | http://publish.uwo.ca/~jdrexler/
---------------------------------+----------------------------------------
Please help Conserve Gravity | Email address is *valid*.
Boycott multistory buildings. | Don't remove the "nospam" part.
------------------------------
Date: 21 Feb 2003 18:29:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Switch order of sprintf conversions
Message-Id: <b35r5k$jvt$3@mamenchi.zrz.TU-Berlin.DE>
Josef Drexler <nospam1202@joesbox.cjb.net> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > I'm amazed the need to rearrange arguments hasn't come up earlier.
> >
> > To be completely general, you may want to allow any permutation, not
> > only reversal. You could store a list of small integers in a hash
> > and use a list slice to do the actual rearrangement:
> >
> > if ( exists $permute{$lang} ) {
> > printf( $string, ($one, $more)[ @{ $permute{ $lang}}]);
> > }
>
> That's a good idea, but I think it would be more useful to have this
> permutation specified as part of the format string, because it will be
> necessary in only some instances, and a different permutation may be
> necessary for each string.
>
> It would probably be worthwhile to write a substitute for sprintf that
> supports the "%2$d" notation of the C sprintf.
Yes, I thought of that too.
> Something like
>
> sub sprintfex {
> my ($format,@args) = @_;
> return sprintf $format, @args unless $format =~ /%\d+\$/;
> # rebuild permuted argument list and format
> return sprintf $newformat, @newargs;
> }
>
> Putting that in a module would be very useful. You'd probably have to
> write a parser for the format string though instead of using just a simple
> regex...
Quite. Having to parse a sprintf format made me refrain from suggesting
such a thing. For the moment it looks easier to allow for an optional
permutation to be stored along with each format.
Anno
------------------------------
Date: Fri, 21 Feb 2003 18:56:13 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Switch order of sprintf conversions
Message-Id: <3e56763a.130143636@news.erols.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
: Jay Tilton wrote:
: > : I understand from the gettext documentation that if it had been a
: > : C program, $string could have been assigned (the equivalent of) "There
: > : Is %2$s Than %1$s Way To Do It".
: > :
: > : Is there a way in Perl to achieve the same thing?
: >
: > Yup.
: > Do the same thing you would in C.
:
: Can you please expand on that, Jay? I have tried it, but when using the
: above string, the sprintf function just returns:
:
: "There Is %2 Than %1 Way To Do It"
:
: It would be much appreciated if you could give me some additional guidance.
Sorry for the content-free reply there. This is evidently a new
ability of sprintf, introduced with Perl 5.8.
printf '%3$s %2$s %1$s', qw/one two three/;
outputs:
three two one
------------------------------
Date: Fri, 21 Feb 2003 17:31:30 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: sysread and length
Message-Id: <Snt5a.69$F6.13359@news-west.eli.net>
"George C. Demetros" <demetros@edamail.fishkill.ibm.com> wrote in
message news:3E4D38C6.801F774F@edamail.fishkill.ibm.com...
> Hi.
>
> How does one determine the right LENGTH to specify on sysread:
>
> sysread(FILEHANDLE, SCALAR, LENGTH, OFFSET)
>
> I have file handles that are a socket, a fifo file, and file
descriptor 3 handle
> on a pipe. The data I will be reading can vary in length from a few
bytes to a
> whole lot of bytes. Is there an optimum length to select for each
type of
> handle if the data is not fixed in length?
I have always just used the whole length with read:
read(STDIN, $input, $ENV{'CONTENT_LENGTH'}, 0);
With this, I have read in as much as 30 MB of data in one chunk and
never had a problem.
Regards,
David
------------------------------
Date: 21 Feb 2003 17:39:10 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: sysread and length
Message-Id: <u9vfzdcz41.fsf@wcl-l.bham.ac.uk>
"David" <perl-dvd@darklaser.com> writes:
> "George C. Demetros" <demetros@edamail.fishkill.ibm.com> wrote in
> message news:3E4D38C6.801F774F@edamail.fishkill.ibm.com...
> > How does one determine the right LENGTH to specify on sysread:
> >
> > sysread(FILEHANDLE, SCALAR, LENGTH, OFFSET)
> >
> I have always just used the whole length with read:
But maybe the OP has a real reson to want to use sysread() not read().
> > I have file handles that are a socket, a fifo file, and file
> > descriptor 3 handle on a pipe. The data I will be reading can
> > vary in length from a few bytes to a whole lot of bytes. Is there
> > an optimum length to select for each type of handle if the data is
> > not fixed in length?
Quite possibly - but this is likely to be an OS issue not a Perl one.
I'd choose a largish power of 2. Like maybe 32K.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 21 Feb 2003 06:26:52 -0800
From: daimon_junk@hotmail.com (Sig Murphy)
Subject: Win32API: How to write protect a device?
Message-Id: <a854e7e.0302210626.5008dd75@posting.google.com>
Hello All!
First and foremost... Thank you to everyone who is helping to make
Perl not only a kick butt language but also a valuable community. I
am truly hooked on it.
On to the question:
I need to write protect a device (a hard disk) in Windows, but can't
figure out how to do it. I know that it has to do with the constant
IOCTL_DISK_IS_WRITABLE, but don't know how to work with Constants in
WIN32API. Can anyone help? Or at least point me in the right
direction?
Thanks!
-Sig
------------------------------
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 4601
***************************************