Skip to content

Piped opening from command line? #6937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
p5pRT opened this issue Nov 18, 2003 · 4 comments
Closed

Piped opening from command line? #6937

p5pRT opened this issue Nov 18, 2003 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 18, 2003

Migrated from rt.perl.org#24519 (status was 'resolved')

Searchable as RT24519$

@p5pRT
Copy link
Author

p5pRT commented Nov 18, 2003

From [email protected]

Is there a way to read files given on the commandline which begin or end
with '|' (pipe) using <>, -p, or -n? It doesn't seem to be possible.
It seems strange that perl would trust the user to open arbitrary pipes.

--
Leah

@p5pRT
Copy link
Author

p5pRT commented Nov 19, 2003

From [email protected]

On Nov 18, Leah said​:

Is there a way to read files given on the commandline which begin or end
with '|' (pipe) using <>, -p, or -n? It doesn't seem to be possible.
It seems strange that perl would trust the user to open arbitrary pipes.

It works for me​:

  perl -lne 'print scalar reverse' -- 'date |'

--
Jeff "japhy" Pinyan japhy@​pobox.com http​://www.pobox.com/~japhy/
RPI Acacia brother #734 http​://www.perlmonks.org/ http​://www.cpan.org/
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]

@p5pRT
Copy link
Author

p5pRT commented Nov 19, 2003

From [email protected]

Leah <perl5-porters@​perl.org> writes​:

# New Ticket Created by Leah
# Please include the string​: [perl #24519]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org/rt2/Ticket/Display.html?id=24519 >

Is there a way to read files given on the commandline which begin or end
with '|' (pipe) using <>, -p, or -n? It doesn't seem to be possible.

You can use the 3-arg form of open​:

open(my $fh,'<',$ARGV[$N]);

or sysopen

use Fcntl;
sysopen(my $fh,$ARGV[N],O_RDONLY);

both avoid the magic.

It seems strange that perl would trust the user to open arbitrary pipes.

@p5pRT p5pRT closed this as completed Feb 29, 2004
@p5pRT
Copy link
Author

p5pRT commented Feb 29, 2004

@iabyn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant