@@ -1046,7 +1046,9 @@ sub import_ascii_delimited {
1046
1046
1047
1047
my $realfile ;
1048
1048
if ($options -> {PRELOAD }) {
1049
- if (-f $infile and $options -> {PRELOAD_EMPTY_ONLY }) {
1049
+ # do not preload if $infile is a scalar reference
1050
+ if ($options -> {scalar_ref } or
1051
+ (-f $infile and $options -> {PRELOAD_EMPTY_ONLY })) {
1050
1052
# Do nothing, no preload
1051
1053
}
1052
1054
else {
@@ -1058,10 +1060,18 @@ sub import_ascii_delimited {
1058
1060
}
1059
1061
1060
1062
if (! defined $realfile ) {
1061
- open (IN, " +<$infile " )
1062
- or die errmsg(" %s %s : %s \n " , errmsg(" open read/write" ), $infile , $! );
1063
- lockfile(\*IN, 1, 1)
1064
- or die errmsg(" %s %s : %s \n " , errmsg(" lock" ), $infile , $! );
1063
+ if ($options -> {scalar_ref }){
1064
+ open (IN, ' +<' , $infile )
1065
+ or die errmsg(" %s %s : %s \n " , errmsg(" open scalar reference" ), *$infile , $! );
1066
+ # locking of scalar reference filehandles in unsupported
1067
+ }
1068
+ else {
1069
+ open (IN, " +<$infile " )
1070
+ or die errmsg(" %s %s : %s \n " , errmsg(" open read/write" ), $infile , $! );
1071
+ lockfile(\*IN, 1, 1)
1072
+ or die errmsg(" %s %s : %s \n " , errmsg(" lock" ), $infile , $! );
1073
+ }
1074
+
1065
1075
}
1066
1076
else {
1067
1077
open (IN, " <$infile " )
@@ -1474,7 +1484,9 @@ EndOfRoutine
1474
1484
}
1475
1485
delete $out -> [$CONFIG ]{Clean_start };
1476
1486
delete $out -> [$CONFIG ]{_Dirty };
1477
- unlockfile(\*IN) or die " unlock\n " ;
1487
+ unless ($options -> {scalar_ref }){
1488
+ unlockfile(\*IN) or die " unlock\n " ;
1489
+ }
1478
1490
close (IN);
1479
1491
my $dot = $out -> [$CONFIG ]{HIDE_AUTO_FILES } ? ' .' : ' ' ;
1480
1492
if ($numeric_guess ) {
0 commit comments