Debian Codegraph @

pdl2

raw
1 #!/usr/bin/perl
2
3 BEGIN {
4 $ENV{DEVEL_REPL_PROFILE} = 'PDL::Perldl2::Profile::Perldl2';
5
6 # This should be based on
7 $HOME = $ENV{HOME}; # Useful in shell
8 if ($^O =~ /win32/i and
9 (! defined($HOME)) or
10 (defined($HOME) and $HOME eq "")) {
11 $HOME = $ENV{USERPROFILE};
12 $HOME =~ s/\\/\//g;
13 }
14
15 $ENV{PERLREPL_HISTFILE} = "$HOME/.perldl_hist";
16 $ENV{PERLREPL_HISTLEN} = 500;
17 }
18
19 use Devel::REPL 1.003011;
20
21 use PDL::Perldl2::Script 'run';
22
23 __END__
24
25 =head1 NAME
26
27 pdl2 - Simple shell (version 2) for PDL
28
29 =head1 SYNOPSIS
30
31 Use PDL interactively:
32
33 %> pdl2
34
35 pdl> $x = sequence(10) # or any other perl or PDL command
36
37 pdl> print "\$x = $x\n";
38 $x = [0 1 2 3 4 5 6 7 8 9]
39
40 pdl> with_time { print +($A->matmult($B))->info, "\n" } for 1..5;
41
42 =head1 DESCRIPTION
43
44 The C<pdl2> program, also known as the Perldl2 shell, is a second
45 generation version of the original C<perldl> interactive PDL shell.
46 It attempts to be backward compatible in usage while providing
47 improved features, better support for Perl syntax, and an more
48 easily extended framework based on the L<Devel::REPL> shell.
49
50 If you have L<Devel::REPL> version 1.003011 or later, then C<pdl2>
51 will start with full functionality. If L<Devel::REPL> is not
52 installed or found then C<pdl2> will print a warning and run
53 the legacy C<perldl> shell command instead.
54
55 By default, command lines beginning with the default prompt
56 of either C<pdl2> or C<perldl> (one of 'pdl> ', 'PDL> ', or
57 'perldl> ') will have the prefix string and surrounding
58 whitespace stripped. This allows for easy cut-and-paste
59 from sample PDL shell sessions or other examples into another
60 PDL shell session.
61
62 For shell-like C<Ctrl-C> handling, you need L<Sys::SigAction> installed.
63
64 =head1 FUNCTIONS
65
66 =head2 do_print
67
68 =for ref
69
70 Toggle print-by-default on and off (default value: off)
71
72 By default, C<pdl2> does not print the results of operations
73 since the results can be very large (e.g., a small 640x480
74 RGBA image is still more than 1_000_000 elements). However,
75 for experimenting and debugging more complex structures,
76 it helps to see the results of I<every> operation. The
77 C<do_print> routine allows you to toggle between the default
78 "quiet" operation and a full Read, Evaluate, Loop style.
79
80 =for example
81
82 pdl> $x = pdl(3,2)
83
84 pdl> do_print
85 1
86 pdl> $x = pdl(3,2)
87 $PDL1 = [3 2];
88 pdl> do_print
89
90 pdl> $x = pdl(3,2)
91
92 =head1 VARIABLES
93
94 =over 4
95
96 =item $PDL::toolongtoprint
97
98 The maximal size pdls to print (defaults to 10000 elements).
99 This is not just a C<perldl> or C<pdl2> variable but it is
100 something that is usually needed in an interactive debugging
101 session.
102
103 =back
104
105 =head1 SEE ALSO
106
107 L<perldl>, L<Devel::REPL>
108
109 =cut