[29047] in Perl-Users-Digest
Perl-Users Digest, Issue: 291 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 2 09:09:44 2007
Date: Mon, 2 Apr 2007 06:09:06 -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 Mon, 2 Apr 2007 Volume: 11 Number: 291
Today's topics:
Re: Any "consumer review generators" available? <null@null.null>
Re: Any "consumer review generators" available? <octomancer@blueyonder.co.uk>
Re: Any good Perl coders out there? (Jamie)
Re: Any good Perl coders out there? <wahab-mail@gmx.de>
Re: Any good Perl coders out there? <bik.mido@tiscalinet.it>
Re: Any good Perl coders out there? <spamtrap@dot-app.org>
Re: Any good Perl coders out there? (Jamie)
Re: Any good Perl coders out there? <tadmc@augustmail.com>
Re: Any good Perl coders out there? <cwilbur@chromatico.net>
Catching print errors himanshu.garg@gmail.com
Re: Catching print errors <hjp-usenet2@hjp.at>
Re: Catching print errors himanshu.garg@gmail.com
Re: Catching print errors <hjp-usenet2@hjp.at>
Re: Catching print errors (Jamie)
Re: Catching print errors <hjp-usenet2@hjp.at>
Re: How to put the command ls -l| awk '{print $1" "$5" <bik.mido@tiscalinet.it>
Re: How to put the command ls -l| awk '{print $1" "$5" <hjp-usenet2@hjp.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 02 Apr 2007 11:58:44 GMT
From: nullified <null@null.null>
Subject: Re: Any "consumer review generators" available?
Message-Id: <lsr1139kuvfujb4vdujodb69qlrpga7fv6@4ax.com>
On 2 Apr 2007 04:48:10 -0700, "Octo" <octomancer@blueyonder.co.uk>
wrote:
>On 29 Mar, 20:00, Uri Guttman <u...@stemsystems.com> wrote:
>> >>>>> "a" == aralsky <aral...@aol.com> writes:
>>
>> a> I am looking for a fake consumer review generator that could
>> a> generate realistic looking reviews for any products, kind of like
>> a> on amazon.com but generated by Artificial Intelligence. Is there a
>> a> package available in your favorite programing language... thx alan
>>
>> it's called a human being. and hope you find some with ethics which you
>> don't seem to have.
>
>People don't have ethics, they have morals. Ethics are characteristics
>of collectives, not individuals.
>
I dont think the OP has either...
Wish I knew his domain, to put it in my block list :o)
------------------------------
Date: 2 Apr 2007 04:48:10 -0700
From: "Octo" <octomancer@blueyonder.co.uk>
Subject: Re: Any "consumer review generators" available?
Message-Id: <1175514490.263622.138320@y80g2000hsf.googlegroups.com>
On 29 Mar, 20:00, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "a" == aralsky <aral...@aol.com> writes:
>
> a> I am looking for a fake consumer review generator that could
> a> generate realistic looking reviews for any products, kind of like
> a> on amazon.com but generated by Artificial Intelligence. Is there a
> a> package available in your favorite programing language... thx alan
>
> it's called a human being. and hope you find some with ethics which you
> don't seem to have.
People don't have ethics, they have morals. Ethics are characteristics
of collectives, not individuals.
R
------------------------------
Date: Mon, 02 Apr 2007 07:40:10 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: Any good Perl coders out there?
Message-Id: <Lc1175476133312260x8c2ae9c@pong.podro.com>
In <x74pnzv3ea.fsf@mail.sysarch.com>,
Uri Guttman <uri@stemsystems.com> mentions:
>>>>>> "f" == fishfry <BLOCKSPAMfishfry@your-mailbox.com> writes:
>perl isn't in any decline. just that more kiddies who can't code are
>using php. fine with us. perl is used for much more outside the web
>anyhow. ever heard php called the ducttape of the internet?
I'd still say perl *is* in decline, certainly in regards to small
business use. Definately in regards to the jobs I run across these days.
Seems pretty obvious to me.
In the past, perl was used a lot by smaller businesses (and even hobby websites)
I know this, because I took on a lot of perl projects in those days. Nowadays,
those jobs are all but gone, replaced with PHP.
Webmasters and people who used to hire "perl monkeys" now look to PHP, I've
spoken with them about doing stuff in perl, they often tell me it would be a
"step backwards".
Now, you and I know perl is /NOT/ a step backwards! but it doesn't matter, we're
not the customer. It's all about perception.
This is a big deal for anyone looking for smaller contracts.
> f> A PHP programmer comes here with a request for a how-to on the
> f> standard db connection/retrieval syntax; and he gets a hearty FUCK
> f> YOU from several different people. It's really sad.
>
>well, did you try to help him? no. the bitching types are always the
>ones who never offer help. 100% of the time this is the case. so you
I'm "bitching" about the overall attitude... and I did offer to help the original
poster. Hope you understand my motive though, I like perl.. a lot.. I want
it to be used everywhere.
I know people who will not use perl because the perception is that perl
programmers are jerks. (same with apple, unix and particularly linux)
> everyone comes to the perl group as they claim we are
>smarter. hmmm, smarter coders use perl but perl is losing ground. sounds
>like the kiddies are learning that php is not as good as they hoped and
>they will never learn more from their fellow php kiddies. too bad.
I don't believe anyone claims perl coders are "smarter" except maybe the
perl coders themselves.
Although... I'd agree with the perl coders :-)
That aside, let them ask, don't assume they're stupid, could be they're just
seeking out a little human connection, could be they are overwhelmed by
all the available documentation.
Whats more, there's no law saying anyone has to answer something they don't
feel like answering.
Bottom line, if you're someone who likes perl and wants more perl
opportunities for everyone... be nice to people.
BTW, uri, I heard you on perlcast, good job!
Jamie
--
http://www.geniegate.com Custom web programming
Perl * Java * UNIX User Management Solutions
------------------------------
Date: Mon, 02 Apr 2007 10:01:12 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Any good Perl coders out there?
Message-Id: <euqdil$dc$1@mlucom4.urz.uni-halle.de>
Jamie wrote:
> In <x74pnzv3ea.fsf@mail.sysarch.com>, Uri Guttman <uri@stemsystems.com> mentions:
>> perl isn't in any decline. just that more kiddies who can't code are
>> using php. fine with us. perl is used for much more outside the web
>> anyhow. ever heard php called the ducttape of the internet?
>
> I'd still say perl *is* in decline, certainly in regards to small
> business use. Definately in regards to the jobs I run across these days.
No, Perl surely isn't in any decline. It's acceptance is.
The "BAF" (beginners acceptance factor) of Perl is quite low.
> Webmasters and people who used to hire "perl monkeys" now look to PHP, I've
> spoken with them about doing stuff in perl, they often tell me it would be a
> "step backwards".
They'd probably "decide" somehow to avoid any technology
which doesn't have any hype at all. That technology wouldn't
(predictably) attract a lot of new soldiers, so its possibly
doomed. Wouldn't you feel that way too (If you weren't you?) ...
Regards
Mirco
------------------------------
Date: Mon, 02 Apr 2007 10:07:04 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Any good Perl coders out there?
Message-Id: <iae113hjmbqph89t5q5arulfbrnn7cdnja@4ax.com>
On Mon, 02 Apr 2007 07:40:10 GMT, nospam@geniegate.com (Jamie) wrote:
>In the past, perl was used a lot by smaller businesses (and even hobby websites)
>I know this, because I took on a lot of perl projects in those days. Nowadays,
>those jobs are all but gone, replaced with PHP.
>
>Webmasters and people who used to hire "perl monkeys" now look to PHP, I've
>spoken with them about doing stuff in perl, they often tell me it would be a
>"step backwards".
What is so hard to understand in the sentence "If you think that all
Perl is good for is CGI, then you have a lot to learn," which someone
wrote in another reply?
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: Mon, 02 Apr 2007 05:36:58 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Any good Perl coders out there?
Message-Id: <m2fy7jqfr9.fsf@local.wv-www.com>
nospam@geniegate.com (Jamie) writes:
> That aside, let them ask, don't assume they're stupid
When they're asking a question that's answered inside of five minutes by
reading the available docs, it's not an assumption.
> Bottom line, if you're someone who likes perl and wants more perl
> opportunities for everyone... be nice to people.
You reap what you sow here. I'm nice to people who are nice to me. Someone
who asks me, as part of this group, to spoon-feed him docs he's too lazy
to read them for himself is not being nice to me.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Mon, 02 Apr 2007 10:19:43 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: Any good Perl coders out there?
Message-Id: <Lc1175487876312260x8ccf218@pong.podro.com>
In <euqdil$dc$1@mlucom4.urz.uni-halle.de>,
Mirco Wahab <wahab-mail@gmx.de> mentions:
>Jamie wrote:
>> In <x74pnzv3ea.fsf@mail.sysarch.com>, Uri Guttman <uri@stemsystems.com> mentions:
>>> perl isn't in any decline. just that more kiddies who can't code are
>>> using php. fine with us. perl is used for much more outside the web
>>> anyhow. ever heard php called the ducttape of the internet?
>>
>> I'd still say perl *is* in decline, certainly in regards to small
>> business use. Definately in regards to the jobs I run across these days.
>
>No, Perl surely isn't in any decline. It's acceptance is.
>The "BAF" (beginners acceptance factor) of Perl is quite low.
How can acceptance be low without perl itself being in decline? Please
don't misunderstand, I actually want to agree with you.
In case anyone wonders.. I'm not suggesting perl will ever go away, it's used
in so many other places that it'll always be around.
>> Webmasters and people who used to hire "perl monkeys" now look to PHP, I've
>> spoken with them about doing stuff in perl, they often tell me it would be a
>> "step backwards".
>
>They'd probably "decide" somehow to avoid any technology
>which doesn't have any hype at all. That technology wouldn't
>(predictably) attract a lot of new soldiers, so its possibly
>doomed. Wouldn't you feel that way too (If you weren't you?) ...
Well, that is basically my point. It's all about perception.
Your point is well taken, which explains why some of them are starting
to get a little loopy about "ruby" (I haven't messed with it yet, but have
read a bit of the docs for it, it definately reads like they've had
some serious PR folk working in the ruby trenches)
One thing I've run into with some people is that perl is "old" php is "new"
and the thing to do is "upgrade" to PHP. Newer is better. (regardless of
whether or not it actually is)
While it's pretty easy to debate a point like that, one doesn't score any
sales points by aggressively pounding facts into a potential client. Much as
one doesn't gain new users by insulting them. A person who does this may
be "right" but they'll still loose. (and in this case, we all loose)
Jamie
--
http://www.geniegate.com Custom web programming
Perl * Java * UNIX User Management Solutions
------------------------------
Date: Mon, 2 Apr 2007 07:18:10 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Any good Perl coders out there?
Message-Id: <slrnf11t42.673.tadmc@tadmc30.august.net>
fishfry <BLOCKSPAMfishfry@your-mailbox.com> wrote:
> In article <Lc117449434296880x8c0e7c4@pong.podro.com>,
> nospam@geniegate.com (Jamie) wrote:
>
>> In <GMhMh.21970$Uk6.15371@reader1.news.saunalahti.fi>,
>> Timo Jokinen <jokinentimo@kolumbus.fi.invalid> mentions:
>> >Michael Vilain wrote:
>> >> In article <1174493670.753360.57970@n76g2000hsh.googlegroups.com>,
>> >> "amerar@iwc.net" <amerar@iwc.net> wrote:
>> >>> I need to convert a PHP script into Perl.
>> >Sorry but if you doesn't want to help him/her don't bother to
>> >write your sarcastic's answer's.
>> Here we have a perfectly good opportunity to introduce someone to the wonders
>> of perl and we've thrown it away. The original poster will probably walk away
>> from all this thinking
>>
>> "Perl? phew! no thanks!"
>>
>>
>
> I'm happy to add a hearty Me Too to this thread.
I agree that this OP was treated poorly.
> This newsgroup has had
> an attitude problem from day one.
You mean since 1995?
Or do you mean since _your_ day one here?
Or was that just a figure of speech?
clp.misc used to be a much nicer place than it is now.
> I don't know if the newsgroup's
> attitude correlates with the decline of Perl as a development language;
It has an *inverse* correlation to the popularity of Perl as a
development language.
Before "Perl = CGI" it was a bunch of like-minded programmers helping
each other.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 02 Apr 2007 08:37:14 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Any good Perl coders out there?
Message-Id: <87mz1rgdfp.fsf@mithril.chromatico.net>
>>>>> "J" == Jamie <nospam@geniegate.com> writes:
J> In the past, perl was used a lot by smaller businesses (and
J> even hobby websites) I know this, because I took on a lot of
J> perl projects in those days. Nowadays, those jobs are all but
J> gone, replaced with PHP.
Yes, PHP is easier to write toy websites in. This has a lot to do
with mod_php being installed by default on most cut-rate web hosts,
and a lot to do with the false economy of PHP.
J> Webmasters and people who used to hire "perl monkeys" now look
J> to PHP, I've spoken with them about doing stuff in perl, they
J> often tell me it would be a "step backwards".
Unfortunate; if they're not willing to listen to technically skilled
people I don't think they're the kind of people I want to work for.
J> I know people who will not use perl because the perception is
J> that perl programmers are jerks. (same with apple, unix and
J> particularly linux)
If they don't want to use a superior product because their feelings
get hurt, it's really their loss. If they want to show up here and
write code for the gimme-gimme posters, they're more than welcome to.
In other words: you have the ability to post to this newsgroup too.
If you don't like what other people are posting, post more of what you
want to see. Put up or shut up.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: 2 Apr 2007 00:52:28 -0700
From: himanshu.garg@gmail.com
Subject: Catching print errors
Message-Id: <1175500348.132608.280620@n59g2000hsh.googlegroups.com>
Hello,
I have written the following script to simulate write failure
conditions in a real application.
open(FILE, ">test.txt");
#
# rm test.txt or chmod 000 test.txt, before the user gives input
#
my $input = <STDIN>;
print FILE "Hello, World!\n" or die "Couldn't write to file: $!\n";
close (FILE);
The problem is if I delete the file the program doesn't show any
error msg and the file remains deleted.
If I change the permissions to 000 the program is still able to
write to file even though the permissions remain 000.
Could you suggest, what it is that I am missing?
Thank You,
HG
------------------------------
Date: Mon, 2 Apr 2007 10:26:57 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Catching print errors
Message-Id: <slrnf11fih.m2n.hjp-usenet2@yoyo.hjp.at>
On 2007-04-02 07:52, himanshu.garg@gmail.com <himanshu.garg@gmail.com> wrote:
> Hello,
>
> I have written the following script to simulate write failure
> conditions in a real application.
>
> open(FILE, ">test.txt");
>
> #
> # rm test.txt or chmod 000 test.txt, before the user gives input
> #
> my $input = <STDIN>;
>
> print FILE "Hello, World!\n" or die "Couldn't write to file: $!\n";
>
> close (FILE);
close(FILE) or die "Couldn't close file: $!";
Won't make any difference in this case (there is no error), but in
general the last few kB will be written only when the file is closed so
you can get an error on close (and for very short short files you will
get an error *only* on close, not on print).
> The problem is if I delete the file the program doesn't show any
> error msg and the file remains deleted.
>
> If I change the permissions to 000 the program is still able to
> write to file even though the permissions remain 000.
>
> Could you suggest, what it is that I am missing?
Since you mentioned "rm" I assume you are using some kind of Unix.
So you are missing 2 things:
1) in Unix a file exists independently of its directory entries. The
unlink system call (used by rm) removes only the directory entry, but
not the file. So you can still write to and read the file. Only when
the last reference to a file (either a directory entry or an open
file handle) is removed, the file itself is removed. In fact,
unlinking a file immediately after creating them is a common trick to
create private temporary files (no other process can open them since
they don't have a directory entry and they will be automatically
removed when closed).
2) In Unix permissions are checked only when a file is opened. Changing
permissions doesn't have any effect on open file handles.
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: 2 Apr 2007 01:44:37 -0700
From: himanshu.garg@gmail.com
Subject: Re: Catching print errors
Message-Id: <1175503477.155649.61540@n59g2000hsh.googlegroups.com>
On Apr 2, 1:26 pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> On 2007-04-02 07:52, himanshu.g...@gmail.com <himanshu.g...@gmail.com> wrote:
>
> > Hello,
>
> > I have written the following script to simulate write failure
> > conditions in a real application.
>
> > open(FILE, ">test.txt");
>
> > #
> > # rm test.txt or chmod 000 test.txt, before the user gives input
> > #
> > my $input = <STDIN>;
>
> > print FILE "Hello, World!\n" or die "Couldn't write to file: $!\n";
>
> > close (FILE);
>
> close(FILE) or die "Couldn't close file: $!";
>
> Won't make any difference in this case (there is no error), but in
> general the last few kB will be written only when the file is closed so
> you can get an error on close (and for very short short files you will
> get an error *only* on close, not on print).
use strict;
open(FILE, ">test.txt");
my $input = <STDIN>;
print FILE "Hello, World!\n" or die "Couldn't write to file: $!\n";
close (FILE) or die "Couldn't close: $!\n";
The above doesn't show the error message either since as you said
there is no error. Any suggestions as to how I can test my script to
check if it dies gracefully on disk full?
Thank You,
HG
------------------------------
Date: Mon, 2 Apr 2007 11:17:28 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Catching print errors
Message-Id: <slrnf11ih8.mrs.hjp-usenet2@yoyo.hjp.at>
On 2007-04-02 08:44, himanshu.garg@gmail.com <himanshu.garg@gmail.com> wrote:
> The above doesn't show the error message either since as you said
> there is no error. Any suggestions as to how I can test my script to
> check if it dies gracefully on disk full?
I'm not sure if I understand you correctly. If you want to distinguish
between a write error because of a full disk and a write error because
of a different reason, you can use the %! hash (see perldoc perlvar):
if ($!{ENOSPC}) {
# disk is full
} else {
# some other error
}
In practice, if you start doing this, you will probably have to check
for all possible error conditions and decide what you want to do with
them (e.g., you may also want to handle EDQUOT (Disk quota exceeded)
specially) and the set of possible error conditions is somewhat system
dependent.
You may also want to look at eval BLOCK to catch and handle errors in a
central place.
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: Mon, 02 Apr 2007 10:37:37 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: Catching print errors
Message-Id: <Lc1175489449312260x8ccfb3c@pong.podro.com>
In <1175500348.132608.280620@n59g2000hsh.googlegroups.com>,
himanshu.garg@gmail.com mentions:
>Hello,
>
> I have written the following script to simulate write failure
>conditions in a real application.
>
>open(FILE, ">test.txt");
>
>#
># rm test.txt or chmod 000 test.txt, before the user gives input
>#
>my $input = <STDIN>;
>
>print FILE "Hello, World!\n" or die "Couldn't write to file: $!\n";
>
>close (FILE);
>
> The problem is if I delete the file the program doesn't show any
>error msg and the file remains deleted.
>
> If I change the permissions to 000 the program is still able to
>write to file even though the permissions remain 000.
>
> Could you suggest, what it is that I am missing?
As others pointed out, the file handle and permissions check are done on the
open call. (even if you unlink it, the handle is valid) also, data is buffered.
If your platform supports it.... you might create a small filesystem on a disk
(with linux it's the loop device) fill it up and then run your checks.
Kind of drastic measures, normally there isn't anything you can do about a full
disk. (which is why I would generally just ignore a problem like that, what
can I do about it?)
If this is a serious system, you might write all output to a temp file and use
rename() so that the update is atomic.
There is absolutely no way to "test" for a kill -9 and you could be stuck with
1/2 a file written to disk, if you're updating a file, this can have
consequences.
Jamie
--
http://www.geniegate.com Custom web programming
Perl * Java * UNIX User Management Solutions
------------------------------
Date: Mon, 2 Apr 2007 13:22:04 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Catching print errors
Message-Id: <slrnf11pqs.q5a.hjp-usenet2@yoyo.hjp.at>
On 2007-04-02 10:37, Jamie <nospam@geniegate.com> wrote:
> Kind of drastic measures, normally there isn't anything you can do about a full
> disk. (which is why I would generally just ignore a problem like that, what
> can I do about it?)
At least you can stop and exit with error message, alerting the user or
sysadmin that something is wrong, instead of blindly ploughing on and
possibly damaging other data.
Also, before exiting, you can maybe remove temporary files, thereby
freeing up space again. (So at least the other programs can continue to
work).
> If this is a serious system, you might write all output to a temp file and use
> rename() so that the update is atomic.
But that also only works if you detect that writing failed.
Consider:
my ($fh, '>', "$file.$$") or die;
while ($data = whatever()) {
print $fh $data;
}
close($fh);
rename("$file.$$", $file) or die;
If the disk fills up while you are writing to $fh, you will clobber
$file with an imcomplete new version. OTOH:
my ($fh, '>', "$file.$$") or die;
while ($data = whatever()) {
print $fh $data or die;
}
close($fh) or die;
rename("$file.$$", $file) or die;
Here the rename will only be reached if all the print calls and the
close call were successful. But it will leave a temporary file lying
around. So something like this would be better:
my ($fh, '>', "$file.$$") or die;
eval {
while ($data = whatever()) {
print $fh $data or die;
}
close($fh) or die;
rename("$file.$$", $file) or die;
};
if ($@) {
unlink("$file.$$");
die $@;
}
Note that in these examples I didn't actually test for the reason of the
failure. The disk might be full, or the user may have exceeded his
quota, or there might be an I/O error on the disk, etc. It doesn't
matter for the program, because in any case it cannot continue. It may
matter for the user, because he needs to do different things to remedy
the problem before starting the program again.
> There is absolutely no way to "test" for a kill -9 and you could be stuck with
> 1/2 a file written to disk, if you're updating a file, this can have
> consequences.
Yep, but the person who needs to consider these consequences is the
person who issues the kill -9, not the person who writes the script.
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: Mon, 02 Apr 2007 10:15:30 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How to put the command ls -l| awk '{print $1" "$5" "$9}' in a perl script?
Message-Id: <2he11395fqaprhdac4oifqjb0fg9tr49r3@4ax.com>
On 1 Apr 2007 19:59:47 -0700, "robertchen117@gmail.com"
<robertchen117@gmail.com> wrote:
>#`ls -l| awk '{print $1" "$5" "$9}' > /tmp/ls.out`; #This does not
>work!
It does work. It may not do what you expect it to.
>#system("ls -l| awk '{print $1" "$5" "$9}' > /tmp/ls.out");
>#compilation error
Obvious: ever considered that perl may consider the opening double
quote closed by the after $1?
>system("ls -l| awk '{print $1\" \"$5\" \"$9}' > /tmp/ls.out"); #The
>File is generated but with empty lines.
Hint: double quoted string interpolate scalar variables. And $1, $5
and $9 are Perl scalar variables.
system q!ls -l| awk '{print $1" "$5" "$9}' > /tmp/ls.out!;
should do the job.
>I tried the above 3 commands all failed.
>How to put the command ls -l| awk '{print $1" "$5" "$9}' in a perl
>script?
Better than everything else would be not to use perl as a shell
script, in which case a shell script would probably better suited, and
instead do in Perl what Perl can perfectly do itself.
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: Mon, 2 Apr 2007 10:11:28 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: How to put the command ls -l| awk '{print $1" "$5" "$9}' in a perl script?
Message-Id: <slrnf11elg.lc1.hjp-usenet2@yoyo.hjp.at>
On 2007-04-02 04:56, John W. Krahn <someone@example.com> wrote:
> robertchen117@gmail.com wrote:
>> In a Unix server,
>> #cd /tmp
>> # ls -l| awk '{print $1" "$5" "$9}'
>> total
>> -rw------- 159045 1IUPKPnHDb
>> -rw------- 1287908 1Mbi68lSf3
>> -rw------- 1475 1o3Bj5Dc1G
>> ...
[...]
>> How to put the command ls -l| awk '{print $1" "$5" "$9}' in a perl
>> script?
>
> use Fcntl ':mode';
>
> for my $file ( <*> ) {
> my ( $mode, $size ) = ( stat $file )[ 2, 7 ];
> print +
> ($mode & S_IFDIR) ? 'd' : '-',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unix knows more file types than directories and regular files.
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
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 291
**************************************