prompt not appearing after running `perl` [duplicate] - perl

This question already has answers here:
How can I start an interactive console for Perl?
(24 answers)
Closed 1 year ago.
I have asked a similar question elsewhere but it eventually evolved into a series of comments. So once again, what package should I install to see the following prompt > after running perl but now not raku (all under Cygwin)?
EDIT
-l doesn't work either.
EDIT 2
Perl -d -e1 doesn't work for me either (Answer in comments as this question is closed):

You didn't provide the name of a program, and you didn't provide a program via the -e or -E command line options, so it's reading the program from STDIN.
perl does have a builtin debugger that you access by passing -d, but you still need to provide a program. (You can provide a trivial one using -e1.)
See How can I start an interactive console for Perl? for alternatives.

Related

Reading user's PS1 from Swift command-line tool

Is it possible to extract the user's PS1 from the environment in a Swift script, so that I can replicate their prompt?
I left a note for myself a few years ago saying that it "disappears from the environment in the context of the script", but I figured it would be useful to ask.
(I'm aware that this question won't necessarily work between shells, but assume that I only care about bash. Furthermore, I know I can't necessarily interpret everything in a user's prompt, but I would like to get it).
Try this in Swift script :
bash -i -c 'echo "$PS1"'

What is the difference in using ! and % before a python command? [duplicate]

This question already has an answer here:
In Jupyter Notebooks on Google Colab, what's the difference between using % and ! to run a shell command?
(1 answer)
Closed 1 year ago.
I know that using ! before a command in python runs the command using the terminal.
For example:
!ls
!unzip zippedfile.zip
However, I noticed that using % also works for some bash commands but not for others.
So
%ls
will work, but
%unzip
will NOT work.
What is the difference between these two prefixes?
The ! escape runs an external shell command, like ping -c 3 www.google.com, not a Python command. Python or ipython has no idea what ping does, it just passes over control to it, and displays its output.
The % escape runs an ipython built-in command or extension, i.e. something that ipython itself understands.
To quote the documentation,
User-extensible ‘magic’ commands. A set of commands prefixed with % or %% is available for controlling IPython itself and provides directory control, namespace information and many aliases to common system shell commands.
The source of confusion here is probably that e.g. ls is also available as a "magic" command for portability and convenience. (It's portable in that it works even on platforms where there is no system ls command, like Windows.)

cant execute perl script - Strange error [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have written a perl script which running fine in my system but not working in some other system.
It is showing error "can't execute ...... at line 1".
everything is set up. I have tested in version 5.8.2 and working fine. But in 5.8.6 it is not working. While compile this code I got that Archive/Tar.pm is missing.
I have checked in my system perl lib folder there is no such Folder/module. Also I didnt get any result for perldoc -lm Archive::Tar in my system but still it is running fine.
Can you let me know what might be the possible problem ?
First line :: #! C:\system\Perl
This program is for windows
Try running dos2unix on your script. It probably has Carriage Returns in the first line.
dos2unix yourscript
You can check with
cat -vet yourscript
CR shows up as ^M.
Also, try running:
which perl
and make sure that your first line matches the answer.
Try running the script using:
perl yourscript
rather than
./yourscript
Are you sure the first line is terminated correctly for your OS (for example, Linux hates CR+LF line terminators... :-)
If Perl is saying that Archive::Tar is missing then it is probably right. Don't argue with it - just install the module.

Perl - Cannot get command line arguments in without explicitly putting "perl" before script call [duplicate]

This question already has answers here:
#ARGV is empty using ActivePerl in Windows 7
(4 answers)
Closed 9 months ago.
I'm running ActivePerl 5.8.8 build 822 on Win7 x64. We're working on a project that is about 60% C++, 15% perl, etc. The Perl is heavily used to link bits and pieces and various small utility applications together to create and pack our final data. So, for example, our VS2005 solution has post build events to create hard links to DLL's using a post build perl script which lives at some location on our development drive (it is part of PATH env var).
I found out quickly, that without explicitly putting "perl" to call the interpreter in-front of the postbuild.pl script call, it wouldn't accept command line arguments. I tested this further simply by going to the cmd window and doing the same with a "hello world" style perl script. No command line arguments were passed in when I say "bleh.pl arg1 arg2". But when I say "perl bleh.pl arg1 arg2" I get command line arguments.
When this failure occurs, perl reads zero command line arguments, and the #ARGV variable empty or null (whatever this crazy language does). So they're simply not passed in.
This is an issue because there are hundreds if not thousands of calls to perl scripts which I fear are not behaving correctly, and it is unreasonable to think I should have to prefix every .pl script invocation with perl explicitly, not to mention we're using version control and I don't want to commit all these garbage changes nor manage them in my stash.
PERL env var exists and points at the folder where the perl binary lives. As well as PATHEXT has .PL in it for perl scripts. Likewise, my PATH contains the folder entries to get to the scripts and to perl also.
Any help on how to figure this out would be immensely appreciated! Also, when I installed ActivePerl (I've done so many times now trying to figure this out). I allowed it to change my Path and associate file extensions in windows, which you would think would be the solution.
Thank you!
Your association is broken (incomplete). First, open a console and execute
assoc .pl
You'll get something like
.pl=SOMETHING
Then, execute
ftype SOMETHING
You should get something like
SOMETHING="C:\SOMEWHERE\bin\perl.exe" "%1" %*
but you'll get something like the following instead:
SOMETHING="C:\SOMEWHERE\bin\perl.exe" "%1"
To fix it, execute
ftype SOMETHING="C:\SOMEWHERE\bin\perl.exe" "%1" %*

"sh -x" equivalent for Perl and Python scripts [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How can I make Perl and Python print each line of the program being executed?
I'm looking for an equivalent of sh -x for Perl and Python.
(Excerpted from Programming Perl’s chapter on the debugger.)
If your .perldb file contains:
parse_options("NonStop=1 LineInfo=tperl.out AutoTrace");
then your program will run without human intervention, putting trace
information into the file tperl.out. (If you interrupt it, you’d better
reset LineInfo to /dev/tty if you expect to see anything.)
Install Devel::Trace and perl -d:Trace.