[30140] in Perl-Users-Digest
Perl-Users Digest, Issue: 1383 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 21 21:09:53 2008
Date: Fri, 21 Mar 2008 18:09:13 -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, 21 Mar 2008 Volume: 11 Number: 1383
Today's topics:
Re: FAQ 6.21 What's wrong with using grep in a void con <brian.d.foy@gmail.com>
Re: FAQ 6.21 What's wrong with using grep in a void con <brian.d.foy@gmail.com>
Re: FAQ 6.21 What's wrong with using grep in a void con <szrRE@szromanMO.comVE>
Re: FAQ 6.21 What's wrong with using grep in a void con <szrRE@szromanMO.comVE>
Re: FAQ 6.21 What's wrong with using grep in a void con <benkasminbullock@gmail.com>
Re: FAQ 7.3 Do I always/never have to quote my strings <brian.d.foy@gmail.com>
Re: FAQ 7.3 Do I always/never have to quote my strings <szrRE@szromanMO.comVE>
fishing small 2008 usa <milta1980x@hotmail.com>
Re: generic declaration of variables <cartercc@gmail.com>
Re: generic declaration of variables <hjp-usenet2@hjp.at>
Re: generic declaration of variables <benkasminbullock@gmail.com>
hot girls in uae <milta1980x@hotmail.com>
Perl code to fill-in online form <minhaztuhin@hotmail.com>
Re: Perl code to fill-in online form <joost@zeekat.nl>
Re: Perl code to fill-in online form <benkasminbullock@gmail.com>
Re: Perl code to fill-in online form <benkasminbullock@gmail.com>
Problems with Perl 5.10 on Mac OS 10.5.2 <jimsgibson@gmail.com>
Re: strategys other than subroutine and OO? <ben@morrow.me.uk>
Re: Table creation <cartercc@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 21 Mar 2008 17:45:39 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 6.21 What's wrong with using grep in a void context?
Message-Id: <210320081745398491%brian.d.foy@gmail.com>
In article <frvbn902r5m@news2.newsguy.com>, szr <szrRE@szromanMO.comVE>
wrote:
> PerlFAQ Server wrote:
>
> > 6.21: What's wrong with using grep in a void context?
> >
> >
> > The problem is that grep builds a return list, regardless of the
> > context. This means you're making Perl go to the trouble of
> > building a list that you then just throw away. If the list is
> > large, you waste both time and space. If your intent is to iterate
> > over the list, then use a for loop for this purpose.
> >
> > In perls older than 5.8.1, map suffers from this problem as well.
> > But since 5.8.1, this has been fixed, and map is context aware -
> > in void context, no lists are constructed.
>
> So why not simply make grep context aware too? Seems grep would benefit
> from this just as much, if not more, as map.
You're missing the point. grep makes no sense in void context because
it exists to output a list. Although the Perl internals might recognize
and optimize that, why should we have to clutter Perl with
optimizations for people doing the wrong thing? It's dump that we had
to do it with map() because so many people were doing it wrong.
If you want to go a list to run some block of code, use foreach(). That
can be optimized for the task. Making map and grep do things they
weren't designed for is just needless complexity.
------------------------------
Date: Fri, 21 Mar 2008 17:46:33 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 6.21 What's wrong with using grep in a void context?
Message-Id: <210320081746331733%brian.d.foy@gmail.com>
In article <frvqig0204d@news2.newsguy.com>, szr <szrRE@szromanMO.comVE>
wrote:
> I get that, though I think there may be some cases where one might want
> to use grep and it's filtering to compare the 'size' it returns to the
> original size of the array.
If you're doing that, you don't have grep in void context.
------------------------------
Date: Fri, 21 Mar 2008 16:15:17 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: FAQ 6.21 What's wrong with using grep in a void context?
Message-Id: <fs1fi60195f@news2.newsguy.com>
brian d foy wrote:
> In article <frvqig0204d@news2.newsguy.com>, szr
> <szrRE@szromanMO.comVE> wrote:
>
>
>> I get that, though I think there may be some cases where one might
>> want to use grep and it's filtering to compare the 'size' it returns
>> to the original size of the array.
>
> If you're doing that, you don't have grep in void context.
Oh, my apologies. I guess I was refering to anything-but-list context.
Sorry for the mistake.
--
szr
------------------------------
Date: Fri, 21 Mar 2008 16:22:44 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: FAQ 6.21 What's wrong with using grep in a void context?
Message-Id: <fs1g04019qt@news2.newsguy.com>
brian d foy wrote:
> In article <frvbn902r5m@news2.newsguy.com>, szr
> <szrRE@szromanMO.comVE> wrote:
>
>> PerlFAQ Server wrote:
>>
>>> 6.21: What's wrong with using grep in a void context?
>>>
>>>
>>> The problem is that grep builds a return list, regardless of the
>>> context. This means you're making Perl go to the trouble of
>>> building a list that you then just throw away. If the list is
>>> large, you waste both time and space. If your intent is to
>>> iterate over the list, then use a for loop for this purpose.
>>>
>>> In perls older than 5.8.1, map suffers from this problem as well.
>>> But since 5.8.1, this has been fixed, and map is context aware -
>>> in void context, no lists are constructed.
>>
>> So why not simply make grep context aware too? Seems grep would
>> benefit from this just as much, if not more, as map.
>
> You're missing the point. grep makes no sense in void context because
> it exists to output a list.
Yes I admit I may have jumped a little too quickly into my initial reply
and did not fully grasp the main issue. I see where map might be used in
void context, and that it's pointless to use grep in the same way.
However, I think a similar optimization might be useful for grep for
scalar context for instance.
> Although the Perl internals might recognize and optimize that, why
> should we have to clutter Perl with optimizations for people doing
> the wrong thing? It's dump that we had to do it with map() because
> so many people were doing it wrong.
Well, what I said initially was to make grep "context aware", not to use
it void context, as I agree it would not make much sense. I think it
/does/ make some sense to optimize when used in scalar context, and I
already posted one example where grep could be useful in such a context.
> If you want to go a list to run some block of code, use foreach().
> That can be optimized for the task. Making map and grep do things they
> weren't designed for is just needless complexity.
I agree with you there, though it never hurts to make a great tool even
better if the there is a need.
--
szr
------------------------------
Date: Fri, 21 Mar 2008 23:23:45 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: FAQ 6.21 What's wrong with using grep in a void context?
Message-Id: <fs1g21$sc$1@ml.accsnet.ne.jp>
On Fri, 21 Mar 2008 01:10:55 -0700, szr wrote:
> For example:
>
> my @a1 = ( [qw/A B C/], [qw/D E F/], [qw/G H I/] ); my @a2 = ( [qw/A
> B C/], [qw/D E F/], [qw/G H I/] );
>
> my $match =
> @a1 == grep { my $i = $_;
> @{$a1[$i]} == grep {
> $a1[$i][$_] eq $a2[$i][$_];
> } (0..$#{$a1[$i]})
> } (0..$#a1);
>
> print $match;
That isn't "void context", it's "scalar context".
> I don't see why there should be a performance penalty in this example,
> if it was avoided with map. Making grep context aware would be real nice
> if you change the arrays to have 100_000 elements each.
You've misunderstood what "void context" means. The FAQ entry is about
grep "called in a void context". "Void context" is a fancy way of saying
that grep's return value is completely ignored. But in your example the
return value of grep is not ignored.
------------------------------
Date: Fri, 21 Mar 2008 17:42:29 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 7.3 Do I always/never have to quote my strings or use semicolons and commas?
Message-Id: <210320081742297080%brian.d.foy@gmail.com>
In article <frvbvv02rob@news2.newsguy.com>, szr <szrRE@szromanMO.comVE>
wrote:
> > 7.3: Do I always/never have to quote my strings or use semicolons and
> > commas?
> > This is like this
> > ------------ ---------------
> > $foo{line} $foo{'line'}
> > bar => stuff 'bar' => stuff
>
> Shouldn't this be:
>
> bar => 'stuff' 'bar' => 'stuff'
It's not the literal string 'stuff', just a placeholder. It's just, um,
stuff.
------------------------------
Date: Fri, 21 Mar 2008 16:28:28 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: FAQ 7.3 Do I always/never have to quote my strings or use semicolons and commas?
Message-Id: <fs1gau01abk@news2.newsguy.com>
brian d foy wrote:
> In article <frvbvv02rob@news2.newsguy.com>, szr
> <szrRE@szromanMO.comVE> wrote:
>
>
>
>
>>> 7.3: Do I always/never have to quote my strings or use semicolons
>>> and commas?
>
>
>>> This is like this
>>> ------------ ---------------
>>> $foo{line} $foo{'line'}
>>> bar => stuff 'bar' => stuff
>>
>> Shouldn't this be:
>>
>> bar => 'stuff' 'bar' => 'stuff'
>
> It's not the literal string 'stuff', just a placeholder. It's just,
> um, stuff.
I figured as much, though I don't think being that loose is a good idea
for an FAQ example snippet of code. I may understand what you meant, as
do you and many others, but I still think care should be taken in
situations like this where code could too easily be misread by those
it's meant to help :-)
--
szr
------------------------------
Date: Fri, 21 Mar 2008 11:35:25 -0700 (PDT)
From: =?windows-1256?B?0uXRySDN0u3k5Q==?= <milta1980x@hotmail.com>
Subject: fishing small 2008 usa
Message-Id: <abd2b5fc-e90e-4326-84f8-b7bff8556657@d21g2000prf.googlegroups.com>
http://groups.google.com/group/at-f
------------------------------
Date: Fri, 21 Mar 2008 12:02:59 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: generic declaration of variables
Message-Id: <c843df50-fa8a-4fd5-83bc-09e696427d83@e39g2000hsf.googlegroups.com>
On Mar 21, 10:50 am, Lawrence Statton <yankeeinex...@gmail.com> wrote:
> ccc31807 <carte...@gmail.com> writes:
> > Thanks. I was afraid that I would get an answer like this, 'You do it
> > that way because Larry said to.'
>
> I don't understand that statement at all -- every language has it's
> syntax rules ... When writing C we use parens to indicate function
> calls, not because Dennis said to, but because that's what the
> compiler will accept.
I didn't mean to be insulting. Maybe I should have said, 'You do it
this way because this is the way you do it.' I remember the first time
anyone really explained objects to me (in Java). I had been writing
Java the way it's taught, classes, objects, properties, methods, etc.,
just by rote. Then, one day, someone who really knew what he was doing
explained ADTs, the difference between primitive types and classes,
allocation of the heap, references, and so on. It made a lot more
sense with a mental picture of using 'new' to allocate storage for an
object based on a class definition.
It's one thing to follow the rules, it's another to understand the
rationale for the rules. I understand the necessity of conforming to
the syntax of a language, but I also attempt to understand the reason
for the syntax.
Thanks again, CC.
------------------------------
Date: Sat, 22 Mar 2008 01:07:03 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: generic declaration of variables
Message-Id: <slrnfu8jd7.pi0.hjp-usenet2@hrunkner.hjp.at>
On 2008-03-21 19:02, ccc31807 <cartercc@gmail.com> wrote:
> On Mar 21, 10:50 am, Lawrence Statton <yankeeinex...@gmail.com> wrote:
>> ccc31807 <carte...@gmail.com> writes:
>> > Thanks. I was afraid that I would get an answer like this, 'You do it
>> > that way because Larry said to.'
>>
>> I don't understand that statement at all -- every language has it's
>> syntax rules ... When writing C we use parens to indicate function
>> calls, not because Dennis said to, but because that's what the
>> compiler will accept.
And of course the C compiler will accept it because Dennis said it
should ;-).
> I didn't mean to be insulting. Maybe I should have said, 'You do it
> this way because this is the way you do it.'
[...]
> It's one thing to follow the rules, it's another to understand the
> rationale for the rules. I understand the necessity of conforming to
> the syntax of a language, but I also attempt to understand the reason
> for the syntax.
You'd have to ask Larry why he chose this particular syntax. One reason
why Perl is "strange" is that Larry - unlike most programming language
designers - is a linguist. So he borrowed lots of concepts from natural
languages. The sigils are articles (the English language has only one
specific article "the", which is used for singular and plural and all
genders, but most European languages distinguish between singular and
plural - so does Perl).
hp
------------------------------
Date: Sat, 22 Mar 2008 00:08:02 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: generic declaration of variables
Message-Id: <fs1il2$sc$2@ml.accsnet.ne.jp>
On Fri, 21 Mar 2008 08:13:44 -0700, ccc31807 wrote:
> I didn't understand the concept, but now I see it. I'm not entirely
> comfortable with it, but I at least have a head knowledge, and assume
> that the experiential knowledge will come with use. Perl has been
> accused of being willfully obscure, and at moments like this I
> sympathize with this accusation.
When we put a $ in front of a hash or array, we tell Perl to think of the
hashes and arrays as if they are scalars:
for (my $i=0;$i<@ARGV;$i++) {
$args{$usage[$i]} = $ARGV[$i];
}
When we put a @ there, we tell Perl to think of a hash or array as a
whole array:
@args{@usage} = @ARGV;
So Perl is very clever, it can understand that we want to bung a whole
list of stuff into a hash indexed by another list of stuff without typing
"<", "=", "0", "$" seven times, "+" twice, "[]" twice, "()", "{}", and ;
once, and also without having to type "for", or "ARGV" twice, or "$i"
five times.
------------------------------
Date: Fri, 21 Mar 2008 11:36:24 -0700 (PDT)
From: =?windows-1256?B?0uXRySDN0u3k5Q==?= <milta1980x@hotmail.com>
Subject: hot girls in uae
Message-Id: <2246700e-507b-4785-b220-c8f25a947980@i12g2000prf.googlegroups.com>
http://groups.google.com/group/at-f
------------------------------
Date: Fri, 21 Mar 2008 16:57:02 -0700 (PDT)
From: Babul <minhaztuhin@hotmail.com>
Subject: Perl code to fill-in online form
Message-Id: <bde14ad5-57f9-434e-9f3e-6a71370ac732@e39g2000hsf.googlegroups.com>
Hello everyone,
I am trying to write a program in perl (windows) that I will use to
fill out online form.
Here are the steps that I follow to get the online form:
1. I go to the web site first and get a Login form
2. I fill in the Login form and submit that form. Then a page open
with a link "Choose a period". When I click on that link, a small
window pops up with links for different weeks. I click on my desired
week.
3. Now a page display with some project names, dates of my choosen
week and box field to enter time that I spent on that progect.
I tried WWW::Mechanize to get the contents of the web page.
Here are the steps I followed to grab the contents of the web page:
#! /usr/local/bin/perl
use Tk;
use Cwd;
use WWW::Mechanize;
$currentDir = getcwd;
$mech = WWW::Mechanize->new();
$mech->get("web address from the 3rd step above");
$contents = $mech->content();
open WF, ">$currentDir/temp.txt";
print WF "$contents\n";
close WF;
But the contents I get is the source code of the Login page (from step
1 above). My purpose is to get the source code of the web page which
is displayed in step 3.
If any one can help me I would appreciate that.
Note: I also noticed that If I go to View->Source on the Internet
Explorer to view the HTML source code of that web page, it does not
display. But I can view source code using View->Source for any other
web sites.
Regards,
Babul
------------------------------
Date: Sat, 22 Mar 2008 01:05:32 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Perl code to fill-in online form
Message-Id: <8763vfk4hf.fsf@zeekat.nl>
Babul <minhaztuhin@hotmail.com> writes:
> Hello everyone,
hi!
> I am trying to write a program in perl (windows) that I will use to
> fill out online form.
> 2. I fill in the Login form and submit that form. Then a page open
> with a link "Choose a period". When I click on that link, a small
> window pops up with links for different weeks. I click on my desired
> week.
ok
> I tried WWW::Mechanize to get the contents of the web page.
That's usually the best module to use for this, yes. but it sounds like
the popup is opened via javascript and WWW::Mechanize doesn't support
javascript.
You either have to figure out how to get at the popup's url via
WWW::Mechanize (probably using some hand-written rules), and/or you'll
need to "mechanize" a javascript capable browser. Since you're on
windows, you may want to try Win32::IE::Mechanize.
See <http://search.cpan.org/~abeltje/Win32-IE-Mechanize-0.009/lib/Win32/IE/Mechanize.pm>
I think this is all mentioned in the docs for WWW::Mechanize too.
[ ...]
> open WF, ">$currentDir/temp.txt";
You don't need to specify the current directory. That's what a current
directory is for.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Sat, 22 Mar 2008 00:23:06 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: Perl code to fill-in online form
Message-Id: <fs1jh9$sc$3@ml.accsnet.ne.jp>
On Fri, 21 Mar 2008 16:57:02 -0700, Babul wrote:
> Hello everyone,
>
> I am trying to write a program in perl (windows) that I will use to fill
> out online form.
>
> Here are the steps that I follow to get the online form: 1. I go to the
> web site first and get a Login form 2. I fill in the Login form and
> submit that form. Then a page open with a link "Choose a period". When I
> click on that link, a small window pops up with links for different
> weeks. I click on my desired week.
> 3. Now a page display with some project names, dates of my choosen week
> and box field to enter time that I spent on that progect.
>
> I tried WWW::Mechanize to get the contents of the web page.
>
> Here are the steps I followed to grab the contents of the web page: #!
> /usr/local/bin/perl
>
> use Tk;
> use Cwd;
> use WWW::Mechanize;
> $currentDir = getcwd;
>
> $mech = WWW::Mechanize->new();
> $mech->get("web address from the 3rd step above"); $contents =
> $mech->content();
> open WF, ">$currentDir/temp.txt";
> print WF "$contents\n";
> close WF;
>
> But the contents I get is the source code of the Login page (from step 1
> above). My purpose is to get the source code of the web page which is
> displayed in step 3.
>
> If any one can help me I would appreciate that.
You probably need to actually log in via Perl and get the cookies (login
cookie, session cookie) via Perl. Even if your browser is logged in, Perl
isn't able to share the cookies from the browser to access the web page.
Here are some code fragments from a similar automated login which might
help get you started:
# modules I used
use LWP::UserAgent;
use HTML::Form;
use HTTP::Cookies;
# from the generic user agent starter for my login:
sub my_module::start_user_agent
{
my $ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt",
autosave => 1));
return $ua;
}
# from the automated login script:
my $name = $form->find_input ("Name", "text")->value;
my $remember = $form->find_input ("Remember", "checkbox")->value;
my $password;# = $form->find_input ("Password", "text")->value;
$form->value ("Name", "myusername");
$form->value ("Remember", "1");
$form->value ("Password", "mypassword");
$request = $form->click;
$response = $ua->request($request);
# end
I ran the login script as a different script since once I had the cookies
I didn't need to run it again.
Alternatively, if you want to automatically fill in the form from your
browser, don't use Perl, use greasemonkey instead.
------------------------------
Date: Sat, 22 Mar 2008 00:53:59 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: Perl code to fill-in online form
Message-Id: <fs1lb7$sc$4@ml.accsnet.ne.jp>
On Sat, 22 Mar 2008 01:05:32 +0100, Joost Diepenmaat wrote:
> Babul <minhaztuhin@hotmail.com> writes:
>
>> Hello everyone,
>
> hi!
>
>> I am trying to write a program in perl (windows) that I will use to
>> fill out online form.
>
>> 2. I fill in the Login form and submit that form. Then a page open with
>> a link "Choose a period". When I click on that link, a small window
>> pops up with links for different weeks. I click on my desired week.
>
> ok
>
>> I tried WWW::Mechanize to get the contents of the web page.
>
> That's usually the best module to use for this, yes. but it sounds like
> the popup is opened via javascript and WWW::Mechanize doesn't support
> javascript.
It's possible but highly unlikely. I think you didn't read where the
poster said that he keeps getting the source code for the login window
when he tries to access the page he wants. The problem is lack of
authentication. If he has the URL for the popup window, window 3, which
he said that he does:
$mech->get("web address from the 3rd step above");
it doesn't matter how window 2 opens window 3. Being opened with
JavaScript has nothing to do with it.
> You either have to figure out how to get at the popup's url via
> WWW::Mechanize (probably using some hand-written rules), and/or you'll
> need to "mechanize" a javascript capable browser. Since you're on
> windows, you may want to try Win32::IE::Mechanize.
No, no, no, this is really bad advice. You didn't read the poster's
question properly.
------------------------------
Date: Fri, 21 Mar 2008 12:44:23 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Problems with Perl 5.10 on Mac OS 10.5.2
Message-Id: <210320081244236778%jimsgibson@gmail.com>
This is a heads-up for Mac Perl users.
Yesterday I took the plunge and downloaded the Perl 5.10.0 source and
built it on my Mac Pro running OSX 10.5.2. I used all of the default
configuration parameters, except building for threads, for which I said
"yes".
The build went OK, but 'make test' had one error in lib/locale.t,
something about a missing locale for test 99, which appears to be the
"C" locale.
I went ahead and did the install, anyway, since I am not too concerned
about locales. Everything looked fine, and I was able to update a CPAN
module that wasn't testing well under perl 5.10.
Today I ran the cpan shell to install a module and encountered the
following error:
jgibson 129% cpan
CPAN: File::HomeDir loaded ok (v0.65)
Can't locate Mac/Files.pm in @INC (@INC contains: /sw/lib/perl5
/sw/lib/perl5/darwin /Users/gibson/Library/Perl
/Users/gibson/Library/Perl/CPAN
/usr/local/lib/perl5/5.10.0/darwin-thread-multi-2level
/usr/local/lib/perl5/5.10.0
/usr/local/lib/perl5/site_perl/5.10.0/darwin-thread-multi-2level
/usr/local/lib/perl5/site_perl/5.10.0
/usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl
/Users/gibson/Library/Perl/src/Mac-Carbon-0.77) at
/usr/local/lib/perl5/site_perl/5.8.8/File/HomeDir/Darwin.pm line 54.
The Mac::Files entry at CPAN points to:
(<http://search.cpan.org/~cnandor/Mac-Carbon-0.77/Files/Files.pm>)
I downloaded the tar file and tried to install with the "tar x;perl
Makefile.PL;make;make test;make install" sequence. "make test" fails on
AppleEvents/t/event with a "Too many arguments to AEBuildParameters()"
error.
This looks like a 10.5.2 incompatibility. There are already 2 bugs
submitted to CPAN for what looks like this problem.
Has anybody else seen this problem? Is there a workaround? If not, I
will have to wait for the hopefully forthcoming fix. :(
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Sat, 22 Mar 2008 00:38:48 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: strategys other than subroutine and OO?
Message-Id: <o11eb5-qqs.ln1@osiris.mauzo.dyndns.org>
Quoth "szr" <szrRE@szromanMO.comVE>:
> Ben Morrow wrote:
> > Quoth Frank Seitz <devnull4711@web.de>:
> >>
> >> Who the hell uses goto today???
> >
> > Depends on the language. While I have never used goto in Perl
>
> Just a sort of a semi-tangent question, isn't using next and last with
> labels (to, say, break out of a parent loop from an inner loop in a set
> of nested loops) implicitly using `goto` ?
Of course. The principle difference, for me, is that next/last/redo
always jump to the top (or right out) of a block, so blocks are always
executed straight through up to the point where you jump out. Even
though it's logically the same (and operationally very slightly slower),
I would prefer
begin_stuff();
FOO: {
do_stuff();
redo FOO if condition();
}
end_stuff();
to
begin_stuff();
FOO:
do_stuff();
goto FOO if condition();
end_stuff();
just because the potentially-repeated section gets its own block.
Ben
------------------------------
Date: Fri, 21 Mar 2008 11:54:36 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Table creation
Message-Id: <f665a65a-c053-4ffc-a413-3ea7e8df6052@z38g2000hsc.googlegroups.com>
On Mar 21, 9:22 am, "Venkatesh can....can..."
<venkatesh.sou...@gmail.com> wrote:
> How to create a table in perl ?
> The table should just be displayed as output in the cli not in any
> Database.
> can anyone pls help??
Do you want this in memory, storage, or as some kind of output?
If output, do you ultimately want to save it to a file, print it on
paper, display it to a browser, or export it to another application
such as a database table? I know you mention the monitor, but normally
you wouldn't go to the trouble of displaying something on the monitor
if it were even the least little bit important.
If you just want to display output, you can do it like this:
print "output\n";
print "$output\n";
printf "%s\n", $output;
CC
------------------------------
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 V11 Issue 1383
***************************************