Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Doubt in one of the examples in "Programming Perl" book - About references

Expand Messages
  • Nikhil Mulley
    That would simply print.. @a has more than @b, Sreeram, I suggest you to try the perl debugger and see what the values are before going to func and after
    Message 1 of 5 , Aug 26, 2005
    • 0 Attachment
      That would simply print..

      @a has more than @b,

      Sreeram, I suggest you to try the perl debugger and see what the values are
      before going to func and after returning from func. try copy-pasting the
      program and run it ,which you sent in the mail

      C:\Docs\txt>perl
      @c=(1,2,3,2,4);
      @b=(2,3,4,5);
      (*a, *b) = func( \@c, \@b );
      print "@a has more than @b\n";
      sub func {
      local(*arr, *sec) = @_;
      if ( @arr > @sec ) {
      return( \@arr, \@sec );
      } else {
      return( \@sec, \@arr );
      }
      }
      ^D
      1 2 3 2 4 has more than 2 3 4 5


      On 8/26/05, Kishore Balla <kishore.balla@...> wrote:
      >
      > rewrite this line print "@a has more than @b\n"; as
      >
      > print "\@a has more than \@b\n";
      >
      > On 8/26/05, Sreeram B S <sreeramabsc@...> wrote:
      > >
      > > Hi Friends,
      > > I am learning about references and typeglobs in Perl and so, I was
      > trying
      > > out few examples quoted in the "Programming Perl" book. I am using the
      > > second edition of this book. In this book, on page 117, the example
      > given is
      > > as follows:
      > >
      > > (*a, *b) = func( \@c, \@b );
      > > print "@a has more than @b\n";
      > > sub func {
      > > local(*arr, *sec) = @_;
      > > if ( @arr > @sec ) {
      > > return( \@arr, \@sec );
      > > } else {
      > > return( \@sec, \@arr );
      > > }
      > > }
      > >
      > > When I execute this program, I am getting the following error:
      > > In string, @a now must be written as \@a at test.p line 6, near "@a"
      > > In string, @b now must be written as \@b at test.p line 6, near "@a has
      > > greater elements than @b"
      > > Execution of test.p aborted due to compilation errors.
      > >
      > > How do I overcome this error?
      > > I made few attempts like removing the slash(\), add paranthesis to the
      > > function name, omitting and adding ampersand etc.
      > >
      > > Kindly suggest.
      > >
      > > Thanks,
      > > Sreeram
      > >
      > >
      > >
      > > __________________________________________________
      > > Do You Yahoo!?
      > > Tired of spam? Yahoo! Mail has the best spam protection around
      > > http://mail.yahoo.com
      > >
      > > [Non-text portions of this message have been removed]
      > >
      > >
      > >
      > > Unsubscribing info is here:
      > > http://help.yahoo.com/help/us/groups/groups-32.html
      > >
      > >
      > >
      > > SPONSORED LINKS
      > > C programming language<
      > http://groups.yahoo.com/gads?t=ms&k=C+programming+language&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=uAODdjBuPf2AFmZC4D7SEA>
      > Computer
      > > programming languages<
      > http://groups.yahoo.com/gads?t=ms&k=Computer+programming+languages&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=y_P2xIdODNaACD_DIso--g>
      > The
      > > c programming language<
      > http://groups.yahoo.com/gads?t=ms&k=The+c+programming+language&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=LYwwGQcbg4iMgXAcxGNaUQ>
      > C
      > > programming language<
      > http://groups.yahoo.com/gads?t=ms&k=C+++programming+language&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=vc-tNFvVPlU95RrPUEEQWw>
      > List
      > > of programming languages<
      > http://groups.yahoo.com/gads?t=ms&k=List+of+programming+languages&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=N4t1_rAV70WeS0TXNSIuwg>
      > Programming
      > > languages<
      > http://groups.yahoo.com/gads?t=ms&k=Programming+languages&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=VzaKrIWH0EAAnzSwDNT1XQ>
      >
      > > ------------------------------
      > > YAHOO! GROUPS LINKS
      > >
      > >
      > > - Visit your group "perl-beginner<
      > http://groups.yahoo.com/group/perl-beginner>"
      > > on the web.
      > > - To unsubscribe from this group, send an email to:
      > > perl-beginner-unsubscribe@yahoogroups.com<
      > perl-beginner-unsubscribe@yahoogroups.com?subject=Unsubscribe<http://perl-beginner-unsubscribe@yahoogroups.com?subject=Unsubscribe>
      > >
      > > - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      > > Service <http://docs.yahoo.com/info/terms/>.
      > >
      > >
      > > ------------------------------
      > >
      >
      >
      >
      > --
      > KISHORE
      >
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >
      > Unsubscribing info is here:
      > http://help.yahoo.com/help/us/groups/groups-32.html
      >
      >
      >
      > SPONSORED LINKS
      > C programming language<http://groups.yahoo.com/gads?t=ms&k=C+programming+language&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=uAODdjBuPf2AFmZC4D7SEA> Computer
      > programming languages<http://groups.yahoo.com/gads?t=ms&k=Computer+programming+languages&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=y_P2xIdODNaACD_DIso--g> The
      > c programming language<http://groups.yahoo.com/gads?t=ms&k=The+c+programming+language&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=LYwwGQcbg4iMgXAcxGNaUQ> C
      > programming language<http://groups.yahoo.com/gads?t=ms&k=C+++programming+language&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=vc-tNFvVPlU95RrPUEEQWw> List
      > of programming languages<http://groups.yahoo.com/gads?t=ms&k=List+of+programming+languages&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=N4t1_rAV70WeS0TXNSIuwg> Programming
      > languages<http://groups.yahoo.com/gads?t=ms&k=Programming+languages&w1=C+programming+language&w2=Computer+programming+languages&w3=The+c+programming+language&w4=C+++programming+language&w5=List+of+programming+languages&w6=Programming+languages&c=6&s=188&.sig=VzaKrIWH0EAAnzSwDNT1XQ>
      > ------------------------------
      > YAHOO! GROUPS LINKS
      >
      >
      > - Visit your group "perl-beginner<http://groups.yahoo.com/group/perl-beginner>"
      > on the web.
      > - To unsubscribe from this group, send an email to:
      > perl-beginner-unsubscribe@yahoogroups.com<perl-beginner-unsubscribe@yahoogroups.com?subject=Unsubscribe>
      > - Your use of Yahoo! Groups is subject to the Yahoo! Terms of
      > Service <http://docs.yahoo.com/info/terms/>.
      >
      >
      > ------------------------------
      >



      --
      Nikhil

      Google is Great !


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.