msh210 has asked for the wisdom of the Perl Monks concerning the following question:
Perl objects to my use of $introsh{$intro} in the print statement: Scalar found where operator expected at foo.pl line baz, near "} $line" (Missing operator before $line?). What can I do instead?#!/usr/bin/perl use strict; use warnings; my %intros = (); open my $fh, '<', 'big_pipe_delimited_file' or die $!; while (<$fh>) { my ($intro) = /^(.*?)\|/; $intros{$intro} = 1; } my %introsh = (); for (keys %intros) { open $introsh{$_}, '>', 'big_pipe_delimited_file_' . $_ or die $!; } seek($fh, 0, 0) or die $!; while (my $line = <$fh>) { my ($intro) = $line =~ /^(.*?)\|/; print $introsh{$intro} $line; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using a variable name for a filehandle
by poj (Abbot) on Sep 18, 2015 at 15:11 UTC | |
|
Re: using a variable name for a filehandle
by ateague (Monk) on Sep 18, 2015 at 15:37 UTC | |
|
Re: using a variable name for a filehandle
by msh210 (Monk) on Sep 18, 2015 at 15:40 UTC |