I've been staring at this for hours. I must be doing something really stupid,
because this behavior seems impossible.
I have an HTML file, "site_menu.html", that persistent-includes a text file,
"Navigation Bar-html5", that persistent-includes a Perl script, "Generate
Navigation Bar-html5".
In site_menu.html
<!-- #bbinclude "Navigation Bar-html5" #MODE#="standalone" -->
Navigation Bar-html5:
<!-- #bbinclude "Generate Navigation Bar-html5.pl" #MENUMODE#="#MODE#"
#PAGES#=", Home, The ZBA Home Page
notices, Notices, Application deadlines and notices of future meetings
about_zoning, About Zoning, All about Zoning and the ZBA
members, Members, The members of the Zoning Board
how_to_apply, How to apply, How to apply to the ZBA
abutters, Abutters, Abutter lists and how to create them
ordinance/, Ordinance, The Wilton Zoning Ordinance
bylaws, Bylaws, The Zoning Board Rules of Procedure
cases/, Cases, Decisions and other records from individual Zoning Board cases
minutes/, Minutes, Minutes of past meetings
links, Links, State laws and more zoning information"
-->
<!-- end bbinclude -->
Generate Navigation Bar-html5.pl:
#! /usr/bin/perl -w
use strict;
use Data::Dumper;
print join("\n", @ARGV). "\n";
my ($file, %args) = @ARGV;
$file =~ s/\\ / /g;
my $root = $ENV{BBEditRootDirectory};
print Dumper(\%args);
my $s = $args{"MENUMODE"};
print $s . "\n";
print length($s) . "\n";
foreach (0..length($s)) {
print substr($s, $_, 1) . "\n";
}
So, the intermediate include file gets the parameter #MODE#="standalone" and
passes it on to the Perl script as #MENUMODE#="#MODE#".
In the Perl script I print the incoming arg vector
print join("\n", @ARGV). "\n";
and as expected, in the expanded bbinclude I see
/Users/neil/Library/Mobile\ Documents/com~apple~CloudDocs/zba/zba/site_menu.html
MENUMODE
standalone
PAGES
, Home, The ZBA Home Page
notices, Notices, Application deadlines and notices of future meetings
about_zoning, About Zoning, All about Zoning and the ZBA
members, Members, The members of the Zoning Board
how_to_apply, How to apply, How to apply to the ZBA
abutters, Abutters, Abutter lists and how to create them
ordinance/, Ordinance, The Wilton Zoning Ordinance
bylaws, Bylaws, The Zoning Board Rules of Procedure
cases/, Cases, Decisions and other records from individual Zoning Board cases
minutes/, Minutes, Minutes of past meetings
links, Links, State laws and more zoning information
Then the Perl script converts the argument vector, less the initial file path
argument, to a hash:
my ($file, %args) = @ARGV;
$file =~ s/\\ / /g;
my $root = $ENV{BBEditRootDirectory};
print Dumper(\%args);
which is again what I expect:
$VAR1 = {
'MENUMODE' => 'standalone',
'PAGES' => ', Home, The ZBA Home Page
notices, Notices, Application deadlines and notices of future meetings
about_zoning, About Zoning, All about Zoning and the ZBA
members, Members, The members of the Zoning Board
how_to_apply, How to apply, How to apply to the ZBA
abutters, Abutters, Abutter lists and how to create them
ordinance/, Ordinance, The Wilton Zoning Ordinance
bylaws, Bylaws, The Zoning Board Rules of Procedure
cases/, Cases, Decisions and other records from individual Zoning Board cases
minutes/, Minutes, Minutes of past meetings
links, Links, State laws and more zoning information'
};
I assign the MENUMODE entry from the $args hash to a scalar variable:
my $s = $args{"MENUMODE"};
print $s . "\n";
and print it, and it is still what I expect:
standalone
Then everything goes pear-shaped. Remember, I've just printed $s, and gotten
"standalone" as I expected. But now I print the length of $s and its individual
characters:
print length($s) . "\n";
foreach (0..length($s)) {
print substr($s, $_, 1) . "\n";
}
And this is the output!
6
#
M
O
D
E
#
What the ???
Again, to put it all together, here is the expanded bbeinclude:
<!-- #bbinclude "Navigation Bar-html5" #MODE#="standalone" -->
/Users/neil/Library/Mobile\ Documents/com~apple~CloudDocs/zba/zba/site_menu.html
MENUMODE
standalone
PAGES
, Home, The ZBA Home Page
notices, Notices, Application deadlines and notices of future meetings
about_zoning, About Zoning, All about Zoning and the ZBA
members, Members, The members of the Zoning Board
how_to_apply, How to apply, How to apply to the ZBA
abutters, Abutters, Abutter lists and how to create them
ordinance/, Ordinance, The Wilton Zoning Ordinance
bylaws, Bylaws, The Zoning Board Rules of Procedure
cases/, Cases, Decisions and other records from individual Zoning Board cases
minutes/, Minutes, Minutes of past meetings
links, Links, State laws and more zoning information
$VAR1 = {
'MENUMODE' => 'standalone',
'PAGES' => ', Home, The ZBA Home Page
notices, Notices, Application deadlines and notices of future meetings
about_zoning, About Zoning, All about Zoning and the ZBA
members, Members, The members of the Zoning Board
how_to_apply, How to apply, How to apply to the ZBA
abutters, Abutters, Abutter lists and how to create them
ordinance/, Ordinance, The Wilton Zoning Ordinance
bylaws, Bylaws, The Zoning Board Rules of Procedure
cases/, Cases, Decisions and other records from individual Zoning Board cases
minutes/, Minutes, Minutes of past meetings
links, Links, State laws and more zoning information'
};
standalone
6
#
M
O
D
E
#
<!-- end bbinclude -->
I mean, if the argument vector entry had been "MENUMODE", "#MENU#", I just
would have said, "OK, BBEdit doesn't substitute an incoming parameter value
into an outgoing parameter, sighed, and solved my problem some other way. But
it does substitute it! The parameter value in the Perl script is clearly
"standalone" ... until it isn't.
I can't even.
Can anybody make sense of this?
Thanks,
Neil
--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/B5E03CD6-64EE-4084-967C-7FE18621F19C%40faiman.org.