[28195] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9559 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 4 03:05:50 2006

Date: Fri, 4 Aug 2006 00:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 4 Aug 2006     Volume: 10 Number: 9559

Today's topics:
    Re: 5 uncommonly known things about Perl <mgarrish@gmail.com>
    Re: 5 uncommonly known things about Perl <mgarrish@gmail.com>
    Re: 5 uncommonly known things about Perl <dha@panix.com>
    Re: 5 uncommonly known things about Perl <betterdie@gmail.com>
        How can I call a sub in a dedicated file? <zhushenli@gmail.com>
    Re: How to "convert" a string into a variable name? <jurgenex@hotmail.com>
    Re: How to "convert" a string into a variable name? <betterdie@gmail.com>
    Re: How to pass 2D array to sub function and return 2D  <zhushenli@gmail.com>
    Re: How to pass 2D array to sub function and return 2D  <1usa@llenroc.ude.invalid>
    Re: How to pass 2D array to sub function and return 2D  <zhushenli@gmail.com>
    Re: How to pass 2D array to sub function and return 2D  <uri@stemsystems.com>
    Re: Learning Typeglobs, Symbol Tables and the More Obsc <benmorrow@tiscali.co.uk>
        new CPAN modules on Fri Aug  4 2006 (Randal Schwartz)
        perl to move mail from inbox to a personal folder devaraj.takhellambam@fmr.com
        Printing "" and $iIN vedpsingh@gmail.com
    Re: Printing "" and $iIN <DJStunks@gmail.com>
    Re: Printing "" and $iIN <jurgenex@hotmail.com>
    Re: Prototyping Subs as func expr, list As In map? <benmorrow@tiscali.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 3 Aug 2006 18:35:32 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: 5 uncommonly known things about Perl
Message-Id: <1154655332.187363.317710@i3g2000cwc.googlegroups.com>


usenet@DavidFilmer.com wrote:

> Taher wrote:
> > I was once asked to name some uncommonly known things about Perl
>
> Perl comes with documentation (including a FAQ).  This doesn't seem to
> be commonly known...
>

And isn't spelled PERL (apocryphal folklore and post-facto expansions
notwithstanding, orf course!). The fact that this is explained in the
FAQ which is contained in the documentation that's not commonly known
might be the cause, however.

Matt



------------------------------

Date: 3 Aug 2006 18:42:04 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: 5 uncommonly known things about Perl
Message-Id: <1154655724.320748.266940@75g2000cwc.googlegroups.com>


Matt Garrish wrote:

> usenet@DavidFilmer.com wrote:
>
> > Taher wrote:
> > > I was once asked to name some uncommonly known things about Perl
> >
> > Perl comes with documentation (including a FAQ).  This doesn't seem to
> > be commonly known...
> >
>
> And isn't spelled PERL

And as I think about it that Perl != CGI. Of course, a lot of the
people who think Perl == CGI tend to write Perl as PERL, which leads me
to think they're acronym dyslexic.

Matt



------------------------------

Date: Fri, 4 Aug 2006 04:49:22 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: 5 uncommonly known things about Perl
Message-Id: <slrned5kei.20e.dha@panix2.panix.com>

On 2006-08-04, Matt Garrish <mgarrish@gmail.com> wrote:
>
> Matt Garrish wrote:
>
>> usenet@DavidFilmer.com wrote:
>>
>> > Taher wrote:
>> > > I was once asked to name some uncommonly known things about Perl
>> >
>> > Perl comes with documentation (including a FAQ).  This doesn't seem to
>> > be commonly known...
>> >
>>
>> And isn't spelled PERL
>
> And as I think about it that Perl != CGI. Of course, a lot of the
> people who think Perl == CGI tend to write Perl as PERL, which leads me
> to think they're acronym dyslexic.

I tend to not put it quite that way:

~ 0:48:00% perl -e 'print "yikes!\n" if CGI == Perl;'
yikes!

I'll leave it as an exercise for the reader to figure out why that is.
:-)

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
perl -e '$_ = (join "", (map (chr, (shift =~ /.../g))));print "$_\n"
;' 106117115116032097032110121032112101114108032104097099107101114


------------------------------

Date: 3 Aug 2006 23:40:58 -0700
From: "perlistpaul" <betterdie@gmail.com>
Subject: Re: 5 uncommonly known things about Perl
Message-Id: <1154673658.179925.161500@i3g2000cwc.googlegroups.com>

Actually there are many uncommon things in Perl, as I am not a guru in
Perl, but I can tell you some of it, as follow

eval is dangerous if not in good use, but it is useful if you know how
to use it
sub is similar to function in others.
regular expression inside perl is more then you can imaging
perl tk is more then a simple but fast and easy for GUI
perl  cgi is a flair of your web design

more and more you can see it by yourself in perl.com or in perldoc

spend time with perldoc you will get to know more about what special
perl can provide you, as bad and good. It is depend to you on how you
use it.

Paul
David H. Adler wrote:
> On 2006-08-04, Matt Garrish <mgarrish@gmail.com> wrote:
> >
> > Matt Garrish wrote:
> >
> >> usenet@DavidFilmer.com wrote:
> >>
> >> > Taher wrote:
> >> > > I was once asked to name some uncommonly known things about Perl
> >> >
> >> > Perl comes with documentation (including a FAQ).  This doesn't seem to
> >> > be commonly known...
> >> >
> >>
> >> And isn't spelled PERL
> >
> > And as I think about it that Perl != CGI. Of course, a lot of the
> > people who think Perl == CGI tend to write Perl as PERL, which leads me
> > to think they're acronym dyslexic.
>
> I tend to not put it quite that way:
>
> ~ 0:48:00% perl -e 'print "yikes!\n" if CGI == Perl;'
> yikes!
>
> I'll leave it as an exercise for the reader to figure out why that is.
> :-)
>
> dha
>
> --
> David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
> perl -e '$_ = (join "", (map (chr, (shift =~ /.../g))));print "$_\n"
> ;' 106117115116032097032110121032112101114108032104097099107101114



------------------------------

Date: 3 Aug 2006 19:31:38 -0700
From: "Davy" <zhushenli@gmail.com>
Subject: How can I call a sub in a dedicated file?
Message-Id: <1154658697.970744.14380@s13g2000cwa.googlegroups.com>

Hi all,

If I want to call a sub function in a dedicated file like "my_sub.pl",
how to do that?

Or if I have a lot of Perl file contain sub function, shall I use
something like package?

Please give me some reference, thanks!

Best regards,
Davy



------------------------------

Date: Fri, 04 Aug 2006 01:05:55 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to "convert" a string into a variable name?
Message-Id: <T3xAg.6106$cj7.5013@trnddc01>

thrill5 wrote:
> I think this is what you had in mind:
> print $$name;

Recommending or showing someone how to use symbolic references without 
pointing out the risks at the same time is quite reckless to say the least.

jue 




------------------------------

Date: 4 Aug 2006 00:03:57 -0700
From: "perlistpaul" <betterdie@gmail.com>
Subject: Re: How to "convert" a string into a variable name?
Message-Id: <1154675036.948525.325960@m79g2000cwm.googlegroups.com>

You shouldn't practice the use of symbolic reference, if you use under
'strict' it will complain.

Why not using symbolic reference vs. soft reference.

You check yourself why not the use it or what reason?

Phal

J=FCrgen Exner wrote:
> thrill5 wrote:
> > I think this is what you had in mind:
> > print $$name;
>
> Recommending or showing someone how to use symbolic references without
> pointing out the risks at the same time is quite reckless to say the leas=
t=2E
>=20
> jue



------------------------------

Date: 3 Aug 2006 19:26:19 -0700
From: "Davy" <zhushenli@gmail.com>
Subject: Re: How to pass 2D array to sub function and return 2D array?
Message-Id: <1154658379.900663.289700@i42g2000cwa.googlegroups.com>

Hi Lalli,

I have used your code and passed, thanks!

Davy

Paul Lalli wrote:
> Sisyphus wrote:
> > "Davy" <zhushenli@gmail.com> wrote in message
> > news:1154593889.794457.16810@m79g2000cwm.googlegroups.com...
> >
> >
> > Just as inside the subroutine where you dereferenced the array reference
> > ($array_ref) to an array (@array_temp), you could do the same with $array_r
> > (which is also an array reference - since that is what the subroutine
> > returns).
> >
> > Something like:
> >
> > use strict;
> > use warnings;
> > my @array=([1,2,3],[4,5,6],[7,8,9]);
> > my $array_ref = \@array;
> >
> > my $array_r = increase_array_element($array_ref);
> > my @array_r_r = @{$array_r};
> > print $array_r_r[1][1], "\n";
> >
> > sub increase_array_element {
> >     my @array_tmp = @{$array_ref};
> >     print $array_tmp[2][2], "\n";
> >     return \@array_tmp;
> > }
>
>
> This code contains the same error as the OP's.  You are passing this
> subroutine an argument, but never obtaining that argument from within
> the subroutine.  It will "work" simply because the argument you passed
> was declared within the scope of both the function definition and the
> function call, but that's not what you want to do.
>
> sub increase_array_element {
>    my @array_temp = @{$_[0]};
>    $array_tmp[2][2]++;
>    print $array_tmp[2][2], "\n";
>    return \@array_tmp;
> }
>
> Please note that because of the way multi-dimensional structures work
> in Perl, both the original and modified arrays contain references to
> the *same* arrays, and so you have actually modified both $array_r and
> $array_ref. . . 
> 
> Paul Lalli



------------------------------

Date: Fri, 04 Aug 2006 02:32:55 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to pass 2D array to sub function and return 2D array?
Message-Id: <Xns9814E5796DD6Easu1cornelledu@127.0.0.1>

"Davy" <zhushenli@gmail.com> wrote in
news:1154658379.900663.289700@i42g2000cwa.googlegroups.com: 

> Hi Lalli,
> 
> I have used your code and passed, thanks!
> 
> Davy

So, this was a homework assignment? In that case, I won't be seeing you 
again.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: 3 Aug 2006 21:21:34 -0700
From: "Davy" <zhushenli@gmail.com>
Subject: Re: How to pass 2D array to sub function and return 2D array?
Message-Id: <1154665294.302712.300700@m73g2000cwd.googlegroups.com>

No, I use Perl in my work. And I found reference in Perl is not so
clear as in C.

Anyhow, thanks.
Davy

A. Sinan Unur wrote:
> "Davy" <zhushenli@gmail.com> wrote in
> news:1154658379.900663.289700@i42g2000cwa.googlegroups.com:
>
> > Hi Lalli,
> >
> > I have used your code and passed, thanks!
> >
> > Davy
>
> So, this was a homework assignment? In that case, I won't be seeing you
> again.
>
> Sinan
>
> --
> A. Sinan Unur <1usa@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:
> http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: Fri, 04 Aug 2006 00:40:02 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to pass 2D array to sub function and return 2D array?
Message-Id: <x7ejvxw1ul.fsf@mail.sysarch.com>

>>>>> "D" == Davy  <zhushenli@gmail.com> writes:

  D> No, I use Perl in my work. And I found reference in Perl is not so
  D> clear as in C.

well, considering they are dramatically different, why should they be as
clear? c uses raw address pointers which can be manipulated, cast and
broken in too many ways to count. perl uses intelligent references which
can only be created by perl, can't be directly manipulated by user code
(no segfaults from perl refs) and can only be dereferenced to the
original thing that was referenced. does that sound like they are so
similar that knowing c pointers would make it clear how perl's refs
work? they have almost nothing in common.

and if you think c's pointers are clear and perl's refs are not, you
haven't done much deep data work and coding in either lang. i have done
plenty in both and i much prefer perl's refs. tracking segfaults is not
how i want to spend the rest of my life.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Fri, 4 Aug 2006 01:22:53 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Learning Typeglobs, Symbol Tables and the More Obscure Features?
Message-Id: <tjgaq3-rkf.ln1@osiris.mauzo.dyndns.org>


Quoth anno4000@radom.zrz.tu-berlin.de:
> Ilya Zakharevich  <nospam-abuse@ilyaz.org> wrote in comp.lang.perl.misc:
> > [A complimentary Cc of this posting was sent to
> > <anno4000@radom.zrz.tu-berlin.de>], who wrote in article
> > <4h29vaF1pav9iU1@news.dfncis.de>:
> > > > arrays and hashes, of course, plus formats, I think. But are directory 
> > > > handles yet another kind of "scalar type"? I haven't found the
> > answer in the 
> > > > docs sofar.
> > 
> > > No, dir handles appear as a special case of file handle, both are
> > > accessed through (say) *main::HANDLE{ IO} as the case may be.
> > 
> > This is not so.  Filehandles and dirhandles live in different
> > namespaces.  (I have no idea what *HANDLE{IO} does if both exist.)
> 
> I see.  So "IO" maps to two distinct slots in a glob.  Whoda thunk.

<ObPedant>

perlref:

| All of these are self-explanatory except for *foo{IO}.  It returns the
| IO handle [...] (It still conflates file and directory handles, though.)

:)

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos. |
Musica truces mollit animos, tristesque mentes erigit.|benmorrow@tiscali.co.uk
Musica vel ipsas arbores et horridas movet feras.     |


------------------------------

Date: Fri, 4 Aug 2006 04:42:10 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Fri Aug  4 2006
Message-Id: <J3GIEA.IEF@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

AI-Prolog-0.735_01
http://search.cpan.org/~jjore/AI-Prolog-0.735_01/
Perl extension for logic programming.
----
Apache2-SOAP-0.72
http://search.cpan.org/~rkobes/Apache2-SOAP-0.72/
mod_perl-2 SOAP server
----
Archive-Extract-0.11_02
http://search.cpan.org/~kane/Archive-Extract-0.11_02/
A generic archive extracting mechanism
----
CGI-Application-Plugin-PageBuilder-0.9
http://search.cpan.org/~cmoore/CGI-Application-Plugin-PageBuilder-0.9/
Simplifies building pages with multiple templates.
----
CORBA-Python-0.27
http://search.cpan.org/~perrad/CORBA-Python-0.27/
----
Catalyst-Plugin-CRUD-0.07
http://search.cpan.org/~bayside/Catalyst-Plugin-CRUD-0.07/
CRUD (create/read/update/delete) Plugin Interface
----
DBD-WMI-0.02
http://search.cpan.org/~corion/DBD-WMI-0.02/
interface to the Windows WMI
----
Data-Entropy-0.001
http://search.cpan.org/~zefram/Data-Entropy-0.001/
entropy (randomness) management
----
Data-Float-0.002
http://search.cpan.org/~zefram/Data-Float-0.002/
details of the floating point data type
----
Devel-Cover-0.57
http://search.cpan.org/~pjcj/Devel-Cover-0.57/
Code coverage metrics for Perl
----
GD-Graph-splined-0.021
http://search.cpan.org/~lgoddard/GD-Graph-splined-0.021/
Smooth line graphs with GD::Graph
----
Games-Multiplayer-Manager-1.01
http://search.cpan.org/~kirsle/Games-Multiplayer-Manager-1.01/
Perl extension for easy management of multiplayer games in interactive environments.
----
Games-NES-ROM-0.03
http://search.cpan.org/~bricas/Games-NES-ROM-0.03/
View information about an NES game from a ROM file
----
HTML-BBReverse-0.07
http://search.cpan.org/~yorhel/HTML-BBReverse-0.07/
Perl module to convert HTML to BBCode and back
----
Hardware-Vhdl-Lexer-0.06b
http://search.cpan.org/~mykl/Hardware-Vhdl-Lexer-0.06b/
Split VHDL code into lexical tokens
----
Image-Imlib2-1.11
http://search.cpan.org/~lbrocard/Image-Imlib2-1.11/
Interface to the Imlib2 image library
----
Object-InsideOut-1.48
http://search.cpan.org/~jdhedden/Object-InsideOut-1.48/
Comprehensive inside-out object support module
----
OpenOffice-OODoc-2.027
http://search.cpan.org/~jmgdoc/OpenOffice-OODoc-2.027/
The Perl Open OpenDocument Connector
----
POE-Component-Client-Ping-1.13
http://search.cpan.org/~rcaputo/POE-Component-Client-Ping-1.13/
a non-blocking ICMP ping client
----
PPM-Make-0.78
http://search.cpan.org/~rkobes/PPM-Make-0.78/
Make a ppm package from a CPAN distribution
----
Params-Classify-0.001
http://search.cpan.org/~zefram/Params-Classify-0.001/
argument type classification
----
Pod-PseudoPod-0.13
http://search.cpan.org/~arandal/Pod-PseudoPod-0.13/
A framework for parsing O'Reilly's PseudoPod
----
RT-Client-REST-0.21
http://search.cpan.org/~dmitri/RT-Client-REST-0.21/
talk to RT installation using REST protocol.
----
Religion-Islam-Quran-1.0
http://search.cpan.org/~mewsoft/Religion-Islam-Quran-1.0/
Holy Quran book searchable database multi-lingual in both text and unicode formats
----
SMS-Send-US-SprintPCS-0.01
http://search.cpan.org/~jjore/SMS-Send-US-SprintPCS-0.01/
An SMS::Send driver for the messaging.sprintpcs.com website
----
SVK-Log-Filter-Babelfish-0.0.2
http://search.cpan.org/~mndrix/SVK-Log-Filter-Babelfish-0.0.2/
translate logs to various natural languages
----
SVK-Log-Filter-Mndrix-0.0.1
http://search.cpan.org/~mndrix/SVK-Log-Filter-Mndrix-0.0.1/
my pretty-ish output format
----
SVK-Log-Filter-Stats-0.0.3
http://search.cpan.org/~mndrix/SVK-Log-Filter-Stats-0.0.3/
display cumulative statistics for revisions
----
Sledge-Plugin-RedirectReferer-0.04
http://search.cpan.org/~nekokak/Sledge-Plugin-RedirectReferer-0.04/
referer redirect plugin for Sledge
----
Tee-0.10
http://search.cpan.org/~dagolden/Tee-0.10/
Pure Perl emulation of GNU tee
----
Tee-0.11
http://search.cpan.org/~dagolden/Tee-0.11/
Pure Perl emulation of GNU tee
----
Time-Simple-0.052
http://search.cpan.org/~lgoddard/Time-Simple-0.052/
A simple, light-weight ISO 8601 time object.
----
Time-TAI-0.001
http://search.cpan.org/~zefram/Time-TAI-0.001/
International Atomic Time and realisations
----
Time-TT-0.001
http://search.cpan.org/~zefram/Time-TT-0.001/
Terrestrial Time and its realisations
----
Time-UTC-0.002
http://search.cpan.org/~zefram/Time-UTC-0.002/
manipulation of UTC in terms of TAI
----
WWW-Myspace-0.51
http://search.cpan.org/~grantg/WWW-Myspace-0.51/
Access MySpace.com profile information from Perl
----
WWW-Salesforce-0.08
http://search.cpan.org/~capoeirab/WWW-Salesforce-0.08/
v0.08 - this class provides a simple abstraction layer between SOAP::Lite and Salesforce.com.
----
Yahoo-Marketing-0.02
http://search.cpan.org/~jlavallee/Yahoo-Marketing-0.02/
an interface for Yahoo! Search Marketing's Web Services.
----
o2sms-3.18
http://search.cpan.org/~mackers/o2sms-3.18/
A module to send SMS messages using the website of O2 Ireland


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: 3 Aug 2006 22:03:31 -0700
From: devaraj.takhellambam@fmr.com
Subject: perl to move mail from inbox to a personal folder
Message-Id: <1154667810.969844.57170@i42g2000cwa.googlegroups.com>

Hi,

i am trying to write a perl script to move an email depending on its
attachment filename to another folder from the inbox. I am using
Win32::OLE; to save the attachemnt.i am new to perl and if anybody has
the sample code, please let me know..thanks for your help in advance.



------------------------------

Date: 3 Aug 2006 21:33:08 -0700
From: vedpsingh@gmail.com
Subject: Printing "" and $iIN
Message-Id: <1154665988.872875.202720@i3g2000cwc.googlegroups.com>

Hi,
I want to print the below mentioned text.

 ------------------------------
multved_HQrow0IN := "0000000000000000";
multved_HQrow1IN := "0000000000000000";
multved_HQrow2IN := "0000000000000000";
multved_HQrow3IN := "0000000000000000";
multved_HQrow4IN := "0000000000000000";
----------------------------

For this I have written the code given below:
--------------------------------------------------------

use strict; # important pragma
use warnings; # another important pragma

print "Enter value of instantiations ? "; # print out the question

my $i;        # \declare" the variable
my $j;
$j = <STDIN>; # ask for the username
chomp($j);    # remove \new line"

for ($i = 0; $i<= $j; $i++) {

open (MYFILE, '>>MultRecover.txt');

print MYFILE "

multved_HQrow$iIN := "0000000000000000";

\n ";
}

close (MYFILE);

--------------------------------------------------

I get error in 2 things:
(1) $iIN -----> i.e. I after $i

(2) "  " are special characters. What do I do to print them.

Thanks
Ved



------------------------------

Date: 3 Aug 2006 22:28:07 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Printing "" and $iIN
Message-Id: <1154669287.666358.140300@i3g2000cwc.googlegroups.com>

vedpsingh@gmail.com wrote:
> Hi,
> I want to print the below mentioned text.
>
> ------------------------------
> multved_HQrow0IN := "0000000000000000";
> multved_HQrow1IN := "0000000000000000";
> multved_HQrow2IN := "0000000000000000";
> multved_HQrow3IN := "0000000000000000";
> multved_HQrow4IN := "0000000000000000";
> ----------------------------
>
> For this I have written the code given below:
> --------------------------------------------------------
>
> use strict; # important pragma
> use warnings; # another important pragma

:)  very good!  thank you!

>
> print "Enter value of instantiations ? "; # print out the question
>
> my $i;        # \declare" the variable

never declare ahead of time like in other languages.  declare in the
smallest possible scope.  in your case:

  for (my $i = 0; $i < $j; $i++) {

> my $j;
> $j = <STDIN>; # ask for the username
> chomp($j);    # remove \new line"

you could do these together:

  chomp( my $j = <STDIN> );

> for ($i = 0; $i<= $j; $i++) {

see above.

> open (MYFILE, '>>MultRecover.txt');

always, yes ALWAYS, check OS operations (open, system, fork, etc).
also, you should begin to get in the habit of using lexical
filehandles, and the three-argument version of open().

  my $file = 'MultRecover.txt';
  open my $MYFILE, '>>', $file or die "Could not open '$file': $!\n";

> print MYFILE "
>
> multved_HQrow$iIN := "0000000000000000";
>
> \n ";
> }
>
> close (MYFILE);
>
> --------------------------------------------------
>
> I get error in 2 things:
> (1) $iIN -----> i.e. I after $i

  ${i}IN

> (2) "  " are special characters. What do I do to print them.

delimit it - print "this is a doublequote: \".  ";

I would probably use printf though:

  printf 'multved_HQrow%dIN := "0000000000000000";%s', $i, "\n";

HTH,
-jp



------------------------------

Date: Fri, 04 Aug 2006 05:34:23 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Printing "" and $iIN
Message-Id: <z%AAg.13877$oz.3207@trnddc07>

vedpsingh@gmail.com wrote:
> for ($i = 0; $i<= $j; $i++) {

    for $i (0..$j)

is much easier to read and to understand.

> print MYFILE "
>
> multved_HQrow$iIN := "0000000000000000";
>
> \n ";
[...]
> I get error in 2 things:
> (1) $iIN -----> i.e. I after $i

Because Perl tries to print the variable $iIn which obviously doesn't exist 
in your program.
Enclose the variable name in curly brackets:
    multved_HQrow${i}IN

> (2) "  " are special characters. What do I do to print them.

Escape them with a leading backslash:
    := \"0000000000000000\";

jue 




------------------------------

Date: Fri, 4 Aug 2006 01:18:34 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Prototyping Subs as func expr, list As In map?
Message-Id: <qbgaq3-rkf.ln1@osiris.mauzo.dyndns.org>


Quoth "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>:
> Hi,
> I think I've noticed a discrepancy about user and built-in functions taking 
> code refs. Where as, say, List::Util::reduce (prototyped &@) let's one pass 
> a code ref, map and grep enable one to also pass an expression as the first 
> argument. So:
> 
> both:
> 
> map { lc } @list;
> 
> and
> 
> map lc, @list;
> 
> Do the same thing. Conceptually, the expression is passed as a whole and 
> evaluated lazily later on as though it was a sub-routine, I suppose.
> 
> But in this snippet dealing with a user function, trying to use an 
> expression terminated by a comma throws a syntax error:
> 
> reduce { $a * $b } @list;
> 
> reduce $a * $b, @list; # Won't compile.
> 
> That is:
> 
> Type of arg 1 to List::Util::reduce must be block or sub {} (not 
> multiplication (*))
> 
> Apparently the built-ins don't parse quite the same way as the 
> user-functions prototyped with the & character.

This is correct. There is no way to get a perl sub to parse the way map
does...

> This notion is backed up by 
> the prototype function. Asking it for the map prototype just hands me undef 
> unless I've typoed:
> 
> print prototype 'CORE::map';

 ...which is why it doesn't have a prototype :).

> Not being able to prototype reduce and my own list functions as
> 
> func EXPR, LIST
> 
> is only slightly annoying. However, I'd like to ask why this difference 
> exists. That is, why not interpret the first argument & like map and grep do 
> it, when it isn't  a code ref? From the user functions point of view it 
> could be indistinguishable from a normal code ref.
> 
> The only downside I can see is not being able to use something totally 
> different from a code ref as the first argument, of a user sub then.

I don't understand this: a &-prototyped sub can only accept a coderef.
Thus, if the first arg is not brace-delimited, it is an EXPR instead. I
suspect that map and grep are heavily special-cased in the lexer and
parser, and it would be hard to get user subs to accept EXPR as well.

> Speaking of functions in which the next comma in the list has "special 
> significance", unary list operators come to mind:
> 
> print lc 'FOO', 'bar';
> 
> lc's argument list is ended by the first comma in prints arguments. Kind of 
> like, by association, how the first comma in map separates its expression 
> and list parts.

lc can be emulated precicely, however:

    ~% perl -le'print prototype "CORE::lc"'
    ;$

A ($) or (;$) prototype is parsed exactly like builtin unary ops.

Ben

-- 
               We do not stop playing because we grow old; 
                  we grow old because we stop playing.
                        benmorrow@tiscali.co.uk


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9559
***************************************


home help back first fref pref prev next nref lref last post