Not quite true. Here is an experiment I did:
Given a file to be sourced in like this:
Here is how I sourced it in:VAR1="FOO" VAR2="FEE" VAR3="FUM" export VAR1 export VAR2 export VAR3
It ain't pretty but it works. Here is a truncated version of the results:#!/usr/bin/perl -w use strict; use Data::Dumper; my %envstuff=source_in("source.sh"); print Dumper(\%envstuff); sub source_in { my $fname=shift; my @vars=(); open RIPIT,sprintf("(. $fname ; env) | ",$fname) or die $fname . $ +!; while(my $line=<RIPIT>){ chomp $line; my ($key,$val)=split("=",$line); push @vars,$key,$val; } close RIPIT; return @vars; }
I'm sure there is more than one way to get this done and I'll be some of them are quite elegant, but sometimes I like to just pull a hammer out of the toolbox and whack nails that stick out.$VAR1 = { 'VAR1' => 'FOO', 'VAR2' => 'FEE', 'VAR3' => 'FUM',
In reply to Re^2: Need help to convert short c shell script to perl
by blue_cowdawg
in thread Need help to convert short c shell script to perl
by kobiee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |