Sponsored Content
Full Discussion: Basic Perl - pass by ref
Top Forums Shell Programming and Scripting Basic Perl - pass by ref Post 302537451 by chrisjones on Friday 8th of July 2011 08:48:11 AM
Old 07-08-2011
Basic Perl - pass by ref

Code:
 
#!/usr/bin/perl
 
sub addToHash{
  my(%hash) = @_;
 $hash{ 'A' } = 'value';
 $hash{ 'B' } = 'value';
 $hash{ 'C' } = 'value';
 print("Hashmap size is " .keys(%hash) . "\n");
}
 
my %myhash = ();
addToHash(\%myhash);
print("Hashmap size is " .keys(%myhash) . "\n");


I want this to print out "Hashmap size is 4" twice but it doesnt seem to be passing by refrence. What am I doing wrong?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

basic perl question

Hi, I was jus goin through a ebook on perl....it says u get binary installation for both unix and windows.....doesnt perl come already bundeled with unix ?cause i never installed any perl from binary........but i am able to execute perl programs...... Thanks and Regards Vivek.S (1 Reply)
Discussion started by: vivekshankar
1 Replies

2. Shell Programming and Scripting

Perl - pass shell-vars into perl for input loop

I need to process a file line-by-line using some value from a shell variable Something like:perl -p -e 's/$shell_srch/$shell_replace/g' input.txt I can't make the '-s' work in the '-p' or '-n' input loop (or couldn't find a syntaxis.) I have searched and found... (4 Replies)
Discussion started by: alex_5161
4 Replies

3. Shell Programming and Scripting

perl basic multiple pattern matching

Hi everyone, and thank you for your help with this. I am VERY new with perl so all of your help is appreciated. I have tried google but as I don't know the proper terms to search for and could be daunting for a newbie scripter... I know this is very easy for most of you! Thanks! I have a... (4 Replies)
Discussion started by: sinusoid
4 Replies

4. Programming

Basic perl code

hi, can anybody explain me the below code. i am new to perl ========================================== $o_dups{$1} = 1 if /^\w+\t.{19}\t(+),/; ========================================== regards, priyanka (2 Replies)
Discussion started by: pspriyanka
2 Replies

5. Programming

Basic perl code- Date format

Hi friends, Please see the below code carefully. ======================================================= # Get batch date and Ord range open OR,$ARGV; while (<OR>) { # find the batch date next if length $_ < 3; # BLANK LINE # last if $. > 120; # sample should be good enough... (2 Replies)
Discussion started by: pspriyanka
2 Replies

6. Shell Programming and Scripting

perl basic code

Hi, can anybody explain me below code $cats{$category}++ Thanks (2 Replies)
Discussion started by: pspriyanka
2 Replies

7. Shell Programming and Scripting

perl basic code

Hi, foreach $cat (sort{$cats{$b} <=> $cats{$a}} keys %cats) can anyone explain me above code?? i am new to perl Thanks (1 Reply)
Discussion started by: pspriyanka
1 Replies

8. Shell Programming and Scripting

perl ref to hash with refs in it (how to get what's being referenced).

I have a reference to a hash that contains some references. I was just wondering if there was a more simplistic Way of dereferencing the contained references without having to assign them to another reference like this: my $href = shift; #some hash my $temp = $href->{element}; print... (3 Replies)
Discussion started by: mrwatkin
3 Replies

9. Shell Programming and Scripting

Perl basic code 3

Hi , I am having csv contains data 2011-08-23 11:11:00.074+0000: Info: Duplicate Order is not processed,Original Order Tuple ($category, $type) = split(',', $_ , 2); what is the split function work here?? Thanks Please start using code tags, thanks. (5 Replies)
Discussion started by: pspriyanka
5 Replies

10. UNIX for Dummies Questions & Answers

Basic Question on perl use POSIX [SOLVED]

Hi guys, I think this is a basic question. I'm not very familiar with this. I'm trying to round a number up and round a number down. From what I have read this can be done using POSIX. I have tried to to use this, but i'm getting errors: sub findGridBounds($$$%) { use POSIX; ... (0 Replies)
Discussion started by: WongSifu
0 Replies
RE-PCR(1)						      General Commands Manual							 RE-PCR(1)

NAME
re-PCR -- Find sequence tagged sites (STS) in DNA sequences SYNOPSIS
re-PCR [-hV] -p hash-file [-g gaps] [-n mism] [-lq] [primer ...] re-PCR [-hV] -P hash-file [-g gaps] [-n mism] [-l] [-m margin] [-O+|-] [-C batchcnt] [-o outfile] [-r+|-] [primers-file ...] re-PCR [-hV] -s hash-file [-g gaps] [-n mism] [-lq] [-m margin] [-o outfile] [-r+|-] [left right lo[-hi] [...]] re-PCR [-hV] -S hash-file [-g gaps] [-n mism] [-lq] [-m margin] [-O+|-] [-C batchcnt] [-o outfile] [-r+|-] [stsfile ...] DESCRIPTION
Implements reverse searching (called Reverse e-PCR) to make it feasible to search the human genome sequence and other large genomes by per- forming STS and primer searches. OPTIONS
-p=hash-file Perform primer lookup using hash-file -P=hash-file Perform primer lookup using hash-file -s=hash-file Perform STS lookup using hash-file -S=hash-file Perform STS lookup using hash-file -n=mism Set max allowed mismatches per primer for lookup -g=gaps Set max allowed indels per primer for lookup -m=margin Set variability for STS size for lookup -l Use presize alignments (only if gaps>0) -G Print alignments in comments -d=min-max Set default STS size -r=+|- Enable/disable reverse STS lookup -O=+|- Enable/disable syscall optimisation -C=batchcnt Set number of STSes per batch -o=outfile Set output file name -q Quiet (no progress indicator) EXAMPLE
famap -tN -b genome.famap org/chr_*.fa fahash -b genome.hash -w 12 -f3 ${PWD}/genome.famap re-PCR -s genome.hash -n1 -g1 ACTATTGATGATGA AGGTAGATGTTTTT 120-200 See famap(1) and fahash(1) SEE ALSO
/usr/share/doc/ncbi-epcr/README.txt bioperl(1), e-pcr(1), famap(1) and fahash(1) AUTHORS
This manual page was written by Andreas Tille <tille@debian.org> for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. April 2008 RE-PCR(1)
All times are GMT -4. The time now is 10:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy