Can i access __DATA__ section in mac os x automator
I am trying to use a section __DATA__
in a perl script that runs inside an automaton.
When run as a shell script everything is fine, but inside the automaton, the data section appears to be empty.
Any idea why and a better workaround than having a giant "here" file?
EDIT
Example script
use strict;
use warnings;
while(<DATA>){
print $_;
}
__DATA__
line1
line2
line3
source to share
Automator.app
runs your script as
/usr/bin/perl -e 'your script here' --
so the descriptor __DATA__
doesn't work.
EDIT how to define
- Automator.app works by definition
/usr/bin/perl
, so: - renamed
/usr/bin/perl
to/usr/bin/perl_ORIG
- added another perl script in its place (another perl), +
chmod 755
#!/opt/local/bin/perl
use strict;
use warnings;
my $n = 0;
print "$0\n";
for my $arg (@ARGV) {
print "$n:[$arg]\n";
$n++;
}
- runs the original script in Automator
- the fake "perl" output shows exactly all arguments up to
--
Not very nice (and not correct), but it helped to find out how Automator runs scripts, for example. it uses -e
(lowercase), script content
+ --
.
Also tell DATA
returns 0
to Automator, in a normal script it returns the real position in the file. (see Borodin's comment)
source to share