The easy (and wrong solution) is to use a regex on that.
use strict; use warnings; my %scalars; # This is the long and wordy version of the line that follows this whi +le loop. while ( my $line = <> ) { my @scalars_on_this_line = ( $line =~ /(\$\w+)/g ); foreach my $scalar ( @scalars_on_this_line ) { $scalars{ $scalar } = 1; } } # This is the faster (because of the hash slice )and smaller (undef va +lues instead of lots of '1' values) method. I'd write it this way. @scalars{ /(\$\w+)/g } = () while <>; $\ = $, = "\n"; print sort keys %scalars;
The harder method would be to use something like B::Xref on your data. Try doing perl -MB::Xref somescript.pl and seeing how that works for you.
In reply to Re: Extract variables from file (split? regex? backflip?)
by diotalevi
in thread Extract variables from file (split? regex? backflip?)
by Lori713
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |