C:\chas_sandbox\pwgen> copy con randfromtwo.pl my @array1=('1', '2', '3'); my @array2=('a', 'b', 'c'); print $array1[rand(@array1)]; print $array2[rand(@array2)]; print $oneElementOfTheseTwoArrays = (@array1, @array2)[int(rand($#array1+$#array 2))]; ^Z 1 file(s) copied. C:\chas_sandbox\pwgen> randfromtwo.pl 2ba C:\chas_sandbox\pwgen> randfromtwo.pl 1ba C:\chas_sandbox\pwgen> randfromtwo.pl 1c3 C:\chas_sandbox\pwgen> randfromtwo.pl 3b1 C:\chas_sandbox\pwgen> randfromtwo.pl 3c2 C:\chas_sandbox\pwgen> #### C:\chas_sandbox> perl -Mdiagnostics -le "sub doit{$ref=$_;${$ref} = 'nope'};$str='cwh';print $str ;doit(\$str);print$str" cwh cwh C:\chas_sandbox> perl -Mdiagnostics -le "sub doit{$ref=$_;${$ref} = 'nope'};$str='cwh';print $str ;doit(\\$str);print$str" cwh cwh C:\chas_sandbox> perl -Mdiagnostics -le "sub doit{$ref=$_;$$ref = 'nope'};$str='cwh';print $str;d oit(\\$str);print$str" cwh cwh C:\chas_sandbox> perl -Mdiagnostics -le "sub doit{$ref=$_;$$ref = 'nope'};$str='cwh';print $str;d oit(\$str);print$str" cwh cwh C:\chas_sandbox> #### C:\chas_sandbox> perl -Mdiagnostics -le "sub doit{$ref=$_;\\$ref = 'nope'};$str='cwh';print $str;doit($str);print$str" Can't modify single ref constructor in scalar assignment at -e line 1, near "'nope'}" Execution of -e aborted due to compilation errors (#1) (F) You aren't allowed to assign to the item indicated, or otherwise try to change it, such as with an auto-increment. Uncaught exception from user code: Can't modify single ref constructor in scalar assignment at -e line 1, near "'nope'}" Execution of -e aborted due to compilation errors. at -e line 1 C:\chas_sandbox> #### #/usr/bin/perl -Wl use strict; use warnings; use Parse::RecDescent; use Data::Dumper; use Data::Serializer; my $grammar; my $grammarfile = $ARGV[0]; open my $gf,'<',$grammarfile or die 'bad grammarfile'; while (<$gf>) { $grammar.=$_; } close $gf; print '$grammar is ',"\n",$grammar; $::RD_HINT++; #$::RD_TRACE++; my $parser = new Parse::RecDescent ($grammar) or die 'bad grammar'; my $stringtoparsefile = $ARGV[1]; open my $sf,'<',$stringtoparsefile or die 'bad stringstoparse file'; my $result; my $reresult; my $serializer = Data::Serializer->new(portable => '0',serializer => 'Data::Dumper'); my $outfilebasename = 'data'; my $outfileext = 'out'; my $outfileindex = 10; while (<$sf>) { print 'parsing $_: ',$_; if (defined $parser->startrule($_)){ $result = $parser->startrule($_); print Dumper($result); $serializer->store( $result, $outfilebasename.$outfileindex.'.'.$outfileext, '>>' ); $reresult = $serializer->retrieve( $outfilebasename.$outfileindex++.'.'.$outfileext, ); print Dumper($reresult); }else{ print " badstring\n"} } #### startrule: commandline{$item{commandline}} commandline: command options {[$item {command},$item{options}]} command: packagecommand {$item{packagecommand}} packagecommand: /(hap)/ | /(hccmrg)/ | /(hup)/ | /(hspp)/ | /(hpp)/ | /(hpg)/ | /(hdp)/ | /(hdlp)/ | /(hcp)/ options: option(s?) option: optionflag optionvalue { [$item{optionflag}, $item{optionvalue}?$item{optionvalue}:1] } optionflag: /(-\w+)/ { $1 } optionvalue: /(\w*)/ { $1 } #### hap -b hap -b sknxharvest01 hap -b sknxharvest01 -enc testfile.dfo hap -b sknxharvest01 -usr cgowing -pass chaspass hap -badflag hap -prompt hap -b sknxharvest01 -prompt hap -prompt -b sknxharvest01