Re: This is not a pipe
by hardburn (Abbot) on Mar 11, 2005 at 19:26 UTC
|
! $this->isa("pipe")
Syntax is correct, though it will die in runtime because $this is not declared.
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
| [reply] [d/l] [select] |
|
|
If you're worried about errors, I recommend instead:
! UNIVERSAL::isa($this, 'pipe')
Just in case there's a possibility that $this might be undef, or an unblessed scalar.
| [reply] [d/l] [select] |
|
|
| [reply] [d/l] |
|
|
I think an easier way to prevent it from die-ing, would be to change that to:
!this->isa('pipe'); or this->isa(!'pipe'); is another possibility. I agree the Universal:: just add clutter.
| [reply] [d/l] [select] |
Re: This is not a pipe
by pijll (Beadle) on Mar 11, 2005 at 23:26 UTC
|
-p '|'
| [reply] [d/l] |
|
|
!-p _
| [reply] [d/l] |
|
|
-p is a test operator, so your expression is more or less equivalent to a question: "Is _ (=this) not a pipe?".
At least in Unix, '|' is not a valid filename, so -p '|' will always be false: "Is '|' a pipe? No.". So the ASCII representation of a pipe, '|', is never a pipe itself, which is exactly what Magritte meant with his painting.
| [reply] |
|
|
|
|
|
|
Or, taking "this" to be $_ as we do,
-p and print, print q m n'est pas une pipem, $/;
(yes, I mean that ;-)
| [reply] [d/l] |
|
|
It's too late now, but if perl had added a special syntax of
m!! to indicate a negated match we could use m!\|!. As it is
we have a modified form of one of sfink's suggestions: $_ !~ m/\|/.
Also, what about?
pipe(STDIN, STDOUT);
#Optional:
$|--, print STDOUT "This is not a pipe\n" ne <STDIN>;
| [reply] [d/l] [select] |
Re: This is not a pipe
by Tanktalus (Canon) on Mar 11, 2005 at 22:38 UTC
|
ref($this) ne 'Pipe';
ref($_) ne 'Pipe'; # $_ is a topicaliser, so is "this" - thus, "th
+is" == "$_"
! UNIVERSAL::can($this, 'smoke');
$_->can('smoke');
Perl 6 ok?
!.isa('Pipe');
Just wondering.
Update: Missed the ! on the perl6 code. | [reply] [d/l] [select] |
Re: This is not a pipe
by idsfa (Vicar) on Mar 11, 2005 at 22:31 UTC
|
$this = ! pipe $|,$|;
The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. -- Cyrus H. Gordon
| [reply] [d/l] |
Re: This is not a pipe
by kscaldef (Pilgrim) on Mar 13, 2005 at 01:05 UTC
|
| [reply] [d/l] |
Re: This is not a pipe
by Hero Zzyzzx (Curate) on Mar 11, 2005 at 20:10 UTC
|
++ to you and your wife for referencing one of my absolute favorite paintings. There's another DaDa painting of a coffin sitting (literally sitting, posed like a person) on a fence or something that cracks me up everytime I see it.
-Any sufficiently advanced technology is indistinguishable from doubletalk.
My Biz
| [reply] |
Re: This is not a pipe
by sfink (Deacon) on Mar 12, 2005 at 08:10 UTC
|
! /^\|$/;
$this !~ /^\|$/;
ord($this) != 124;
ord($this) != 0x7c;
ord($this) != 0174;
seek(THIS, 2, 0);
`ls -l $this` !~ /^p/;
! -p _;
return ! -p _;
-p _ && die;
die if -p _;
return 1 unless -p _;
use Test::More; isnt($this, 'pipe', 'Magritte check');
$this ne 'a|';
next unless /^(\w)\|$/; next if $1 eq 'a';
open(my $fh, "a|"); while(<$fh>) { die if /\Q$this\E/; }
| [reply] [d/l] |
Re: This is not a pipe
by thor (Priest) on Mar 11, 2005 at 19:36 UTC
|
Wouldn't /^|$/ match a single pipe on a line with nothing else, answering the question "is this a pipe only?"
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come
| [reply] [d/l] |
|
|
Yep, you are right, I can't type!
I meant:
/^[^|]$/;
| [reply] [d/l] |
|
|
| [reply] |
|
|
Right you are. I was supposing that this was one of those situations where the regex characters were taken literally, like if you were to do m/^{/;.
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come
| [reply] [d/l] |
Re: This is not a pipe
by johndageek (Hermit) on Mar 14, 2005 at 16:48 UTC
|
$pipe = "3.14159 + pe";
print "this is not a $pipe\n";
Eh! Why not?
| [reply] [d/l] |
Re: This is not a pipe
by Adrade (Pilgrim) on May 09, 2005 at 07:56 UTC
|
('|'?0:1)==0
die if '|'
$SIG{PIPE}={$p++};END{$p==0}
| [reply] [d/l] |
Re: This is not a pipe
by gmpassos (Priest) on Mar 13, 2005 at 23:27 UTC
|
if ( $this ne '|' ) {...}
Graciliano M. P.
"Creativity is the expression of liberty".
| [reply] [d/l] |