CAD-Drawing
view release on metacpan or search on metacpan
lib/CAD/Drawing/IO/Circ.pm view on Meta::CPAN
# does the new .circ file smash the old?
my $suffix = $opts->{suffix};
if(my $inf = $self->pingcirc($directory)) {
$suffix || ($suffix = $inf->{suffix});
}
if($opts{type} =~ m/(\..*)$/) {
$suffix = $1;
}
$suffix || die "need suffix\n";
$opts{suffix} = $suffix;
$self->write_circdata($directory, \%opts);
my ($s, $n) = check_select($opts);
foreach my $layer ($self->getLayerList()) {
$s->{l} && ($s->{l}{$layer} || next);
$n->{l} && ($n->{l}{$layer} && next);
my $outfile = "$directory/$layer$suffix";
# print "out to $outfile\n";
open(CIRCLESOUT, ">$outfile") or
croak "cannot open $outfile for write\n";
foreach my $circ ($self->getAddrByType($layer, "circles")) {
my $obj = $self->getobj($circ);
lib/CAD/Drawing/IO/Circ.pm view on Meta::CPAN
# keys may not contain colons, but values can
# whitespace around first colon is optional
my ($key, $val) = split(/\s*:\s*/, $line, 2);
$info{$key} = $val;
}
close(TAG);
return(\%info);
} # end subroutine pingcirc definition
########################################################################
=head2 write_circdata
$drw->write_circdata($directory, \%options);
=cut
sub write_circdata {
my $self = shift;
my ($directory, $opts) = @_;
my $circfile = "$directory/$circtag";
# maybe load the existing one first and then over-write it?
my $existing = $self->pingcirc($directory);
my %info;
$existing && (%info = %$existing);
if($opts->{info}) {
foreach my $key (%{$opts->{info}}) {
$info{$key} = $opts->{info}{$key};
}
}
$info{suffix} = $opts->{suffix};
open(CDATA, ">$circfile") or croak "cannot open $circfile for write";
foreach my $key (keys(%info)) {
print CDATA "$key:$info{$key}\n";
}
close(CDATA);
} # end subroutine write_circdata definition
########################################################################
1;
( run in 0.553 second using v1.01-cache-2.11-cpan-454fe037f31 )