Yes, and I think that gives us *two* reasons to always explicitly close
filehandles. :-)
David
On Sun, Jul 16, 2017 at 8:00 AM, Shawn H Corey
wrote:
> On Sun, 16 Jul 2017 07:36:39 -0400
> David Mertens wrote:
>
> > Also note that lexical filehandles close when they go out of scope
>
> True but
On Sun, 16 Jul 2017 07:36:39 -0400
David Mertens wrote:
> Also note that lexical filehandles close when they go out of scope
True but you should always explicitly close your files. This gives you
a chance to report any errors it had, have rather than silently
ignoring them.
--
Don't stop wher
ch
expression won't close until the end of the program.
David
On Wed, Jul 12, 2017 at 5:28 PM, Jim Gibson wrote:
> If you wish to terminate execution of a foreach loop without iterating
> over all of the elements (@files, in this case) use the “last” statement:
>
> foreach my $file
On Thu, 13 Jul 2017 00:50:42 +0530
perl kamal wrote:
> open (my $FH, $file) or die "could not open file\n";
A quick note: output the file name and error message to have a better
idea of what went wrong.
open (my $FH, $file) or die "could not open file $file: $!\n";
--
Don't stop where th
If you wish to terminate execution of a foreach loop without iterating over all
of the elements (@files, in this case) use the “last” statement:
foreach my $file ( @files ) {
# process file
open( my $fh, ‘<‘, $file ) or die(…);
while( my $line = <$fh> ) {
# process line
}
close
.But we could read the
> first file alone and the rest are skipped from the while loop. Please
> correct me where am i missing the logic.Thanks.
>
> use strict;
> use warnings;
> my @files=qw(Alpha.txt Beta.txt Gama.txt);
>
> foreach my $file (@files)
> {
> open (m
Hello All,
I would like to read multiple files and process them.But we could read the
first file alone and the rest are skipped from the while loop. Please
correct me where am i missing the logic.Thanks.
use strict;
use warnings;
my @files=qw(Alpha.txt Beta.txt Gama.txt);
foreach my $file
""Chris Charley"" wrote in message
news:20160912202839.22177.qm...@lists-nntp.develooper.com...
"Nathalie Conte" wrote in message
news:9d0654e0-8ec0-4051-87ca-541f90931...@ebi.ac.uk...
Dear all,
Thanks a lot for the codes various people which all work perfectly!! I
have also discover som
""Chris Charley"" wrote in message
news:20160912202839.22177.qm...@lists-nntp.develooper.com...
"Nathalie Conte" wrote in message
news:9d0654e0-8ec0-4051-87ca-541f90931...@ebi.ac.uk...
Dear all,
[snip]
many thanks again for any tips/help,
Nathalie
[Chris wrote]
[snip]
for my $name (sor
On 09/12/2016 06:48 PM, Aaron Wells wrote:
@Jim,
That eval bit i think Nathalie got from me. I need to review my core
Perl. I think i’m in the habit of assuming Perl warns against any
usage of undefined values, even in boolean context. Not so. I’ve
proven to myself that this is not the case:
@Jim,
That eval bit i think Nathalie got from me. I need to review my core Perl. I
think i’m in the habit of assuming Perl warns against any usage of undefined
values, even in boolean context. Not so. I’ve proven to myself that this is not
the case:
$ perl -E’
>my ($foo, $bar); # these aren’t
"Nathalie Conte" wrote in message
news:9d0654e0-8ec0-4051-87ca-541f90931...@ebi.ac.uk...
Dear all,
Thanks a lot for the codes various people which all work perfectly!! I have
also discover some useful functions (eval and state) which can also be very
helpful for this kind of data.
In the li
> On Sep 12, 2016, at 6:24 AM, Nathalie Conte wrote:
>
> Dear all,
>
> Thanks a lot for the codes various people which all work perfectly!! I have
> also discover some useful functions (eval and state) which can also be very
> helpful for this kind of data.
>
> In the light of this, my datas
keys %{ $hall{$name}{$subject}}) {
state ($lgrade,$lsubject,$lname,$ltimes);
my $grade = $hall{$name}{$subject};
print "grade is .$grade\n";
my $times = $hall{$name}{$subject}{$values};
print "time is .$times\n";
if (eval { $lgrade and $lname eq
s %{$nameref}'
would be the way to go.
On Sat, Sep 10, 2016, 4:11 PM Jim Gibson wrote:
>
> > On Sep 9, 2016, at 8:54 AM, Nathalie Conte wrote:
> >
> > Hello,
> > I have a question about making a calculation within a loop
> >
> > I have a hash o
> On Sep 9, 2016, at 8:54 AM, Nathalie Conte wrote:
>
> Hello,
> I have a question about making a calculation within a loop
>
> I have a hash of hashes
> ##
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> use Data::Dumper qw(Dumper);
&
Hi, Nathalie
You could try the attached code.
Best
gil
On 09/09/16 12:54, Nathalie Conte wrote:
> Hello,
> I have a question about making a calculation within a loop
>
> I have a hash of hashes
> ##
> #!/usr/bin/perl
> use strict;
> use warnings;
>
&
Hello,
I have a question about making a calculation within a loop
I have a hash of hashes
##
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper qw(Dumper);
my %grades;
$grades{"Foo "}{1} = 97;
$grades{"Foo "}{2}= 107;
$grades{"Peti "}
Hi,
Thanks you for your valuable comments,let me try the Twig module.
On 12/8/15, Kent Fredric wrote:
> On 8 December 2015 at 19:25, perl kamal wrote:
>> I am trying to parse the inner loop elements of the attached input xml
>> elements.
>> The below code doesn'
tl;dr I'm not answering your specific question here.
On Dec 8, 2015 1:26 AM, "perl kamal" wrote:
>
> Hi,
>
> I am trying to parse the inner loop elements of the attached input xml
elements.
Just fyi, I've found it easier to use xslt as an etl preprocessor to perl
On 8 December 2015 at 19:25, perl kamal wrote:
> I am trying to parse the inner loop elements of the attached input xml
> elements.
> The below code doesn't retrieve the inner loop() elements if
> the properties tag contains more than one item. Will you please point
> the
Hi,
I am trying to parse the inner loop elements of the attached input xml elements.
The below code doesn't retrieve the inner loop() elements if
the properties tag contains more than one item. Will you please point
the error and correct me.
Please find the attached input xml file. Thanks.
200
> Marco wrote:
>
> > Hello.
> >
> > I need some help in understanding why the first
> >
> > my ($Count,$Saw)=$self->{_Portobj}->read(1);
> >
> > is executed without any problem , however the second identical statement
> > inside the while
ical statement
> inside the while loop fails with the error
>
> Can't call method "read" on an undefined value at wt800.pm line 121
>
The problem is that you misspelled "_Portobj" as "_PortObj". This is easier to
catch if you use accessors:
* htt
Hello.
I need some help in understanding why the first
my ($Count,$Saw)=$self->{_Portobj}->read(1);
is executed without any problem , however the second identical statement
inside the while loop fails with the error
Can't call method "read" on an undefined value
ot clear what your array @div_array is for, as you only ever test
that it contains the number 1 ($value never changes). What is happening
is that, even for the non-primes, the `for` loop comes to an end and "is
A prime number" is printed for everything. To fix it you need to add a
`return`
Hi ,
I asked this question on linkedin but I think the best place to get answers
is here ...
I have a perl cod that check a range of numbers and print for each number
if it's prime number or not prime number.
So why its not working properly ? ...
#!C:\strawberry\perl\bin\perl
use strict;
use war
e;
> *foreach $c (keys @words){*
>print "word $words[$c]\n";
>$hash{W_c_start}++ if ($words[$c] =~ /^C.*/i);
> }
> }
>
> print "$_ :: $hash{$_}\n" foreach (keys %hash);
> ==
$c]\n";
$hash{W_c_start}++ if ($words[$c] =~ /^C.*/i);
}
}
print "$_ :: $hash{$_}\n" foreach (keys %hash);
=
I want to use "while" loop instead of "foreach" . I tried it but
ot; . $date_added->strftime("%a, %d %b %Y ") . "} ";
$date = $date_added->strftime("%d");}
On Sun, Sep 15, 2013 at 1:16 AM, J M wrote:
>
>
> <http://stackoverflow.com/questions/18809731/mysql-perl-and-latex-trying-to-loop-through-results-by-day-as-a-lat
<http://stackoverflow.com/questions/18809731/mysql-perl-and-latex-trying-to-loop-through-results-by-day-as-a-latex-sectio#>
I have written a Perl script (shown below) to loop through my MySQL
database and then output a .tex file, as a sort of programmed custom
report. As it stands, it
Thanks. I looked at this site while searching for solutions but I probably
skipped the section on sorting because I wasn't sorting the hash.
regards, Richard
--
tmqrich...@gmail.com
On Sun, Jun 16, 2013 at 3:17 AM, Peter Gordon wrote:
> On Sat, 15 Jun 2013 12:12:56 -0400, richard wrote:
> >Hi
>
On Sat, 15 Jun 2013 12:12:56 -0400, richard wrote:
>Hi
>
>I'm trying to understand the difference between the keys() and
>values () operators. What I'm not getting is why a hash must be
>reversed to get the key corresponding to a value? (as stated in
>perldoc). Can someone explain this please?
>
>
7;c', '3],
> ['d', 2],
> );
>
> To get the "value" for the element with the index 1 you need to do:
>
> my $value = $array[1][1]; #the value "2"
>
> and to get the "key" for the element with the index 1, you can do:
>
&g
and to get the "key" for the element with the index 1, you can do:
my $key = $array[1][0]; #Will get "b"
I don't know what you need to do... that's why I gave the idea of using arrays
of arrays...
--Octavian
- Original Message -
From: richard
To: beginners@
Hi
I'm trying to understand the difference between the keys() and values ()
operators. What I'm not getting is why a hash must be reversed to get the
key corresponding to a value? (as stated in perldoc). Can someone explain
this please?
Here is my test script; My perl is freebsd 5.8.9
use warnin
On May 1, 2013, at 11:27 AM, Noah wrote:
> Hi there,
>
> I want to figure out a way to create a loop that will do actions based on
> matches it collects in the loop and continue to do actions on all matches
> till these are not m
>
> Hope this pseudo code makes sense:
Hi there,
I want to figure out a way to create a loop that will do actions based
on matches it collects in the loop and continue to do actions on all
matches till these are not m
Hope this pseudo code makes sense:
1) start loop
2) find all matches
3) end loop
4) start loop
5) do some action
On 04/04/2013 00:29, Angela Barone wrote:
I'm just curious about this. If you put "no warnings" inside a loop,
is it good only for that loop, or will it be in effect until the end
of the script?
Also see `perllexwarn`
Rob
--
To unsubscribe, e-mail: beginners-unsubscr.
On 04/04/2013 00:29, Angela Barone wrote:
I'm just curious about this. If you put "no warnings" inside a loop,
is it good only for that loop, or will it be in effect until the end
of the script?
Hi Angela
The `warnings` pragma is *lexically* scoped. That means it applies
On Wed, Apr 3, 2013 at 4:29 PM, Angela Barone
wrote:
> I'm just curious about this. If you put "no warnings" inside a
> loop, is it good only for that loop, or will it be in effect until the end
> of the script?
>
See: perldoc perllexwarn
>From above
On Apr 3, 2013, at 4:29 PM, Angela Barone wrote:
> I'm just curious about this. If you put "no warnings" inside a loop,
> is it good only for that loop, or will it be in effect until the end of the
> script?
'no warnings' is lexically scoped, meaning
On Wed, Apr 3, 2013 at 8:29 PM, Angela Barone
wrote:
> I'm just curious about this. If you put "no warnings" inside a
> loop, is it good only for that loop, or will it be in effect until the end
> of the script?
>
>
Only for the loop -- warnings, along w
I'm just curious about this. If you put "no warnings" inside a loop,
is it good only for that loop, or will it be in effect until the end of the
script?
Thanks,
Angela
A2 Hosting now has Perl 5.10.1
http://www.a2hosting.com/1250.html
--
To unsubscribe, e-mail: beg
On Sun, Mar 10, 2013 at 11:06:14AM -0400, Brandon McCaig wrote:
> There is no array here. There are only lists. See perldoc
> perldata.
>
> > List value constructors
> > List values are denoted by separating individual values
> > by commas (and enclosing the list in parentheses where
semantics). Thus, in your example above you passed split
/PATTERN/ and /EXPR/ (split is built-in and its semantics are not
the same as user-defined functions), and in exchange split
returned a list of ('a', 'b', 'c'), which your for-loop then
iterated over. At no poin
On Sat, Mar 09, 2013 at 08:19:43PM -0600, Chris Stinemetz wrote:
> I don't think that is true.
>
> Example being:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> use Data::Dumper;
>
> my $firstVar = "One";
> my $secondVar = "Two";
>
> my @array;
> push @array,[$firstVar, $secondVar];
>
On Sat, Mar 9, 2013 at 2:57 PM, Brandon McCaig wrote:
> On Sat, Mar 09, 2013 at 07:24:37AM -0600, Chris Stinemetz wrote:
> > Each anonymous array @files and @newFiles has 5 total elements.
>
> Just to nitpick, @files and @newFiles are not anonymous arrays.
> They are just arrays. They have names.
On Sat, Mar 09, 2013 at 07:24:37AM -0600, Chris Stinemetz wrote:
> Each anonymous array @files and @newFiles has 5 total elements.
Just to nitpick, @files and @newFiles are not anonymous arrays.
They are just arrays. They have names. You cannot have anonymous
arrays in Perl except by reference. Th
--
Your talent is God's gift to you. What you do with it is your gift back to God.
---
From: Chris Stinemetz
To
Never mind, I got it.
I was over thinking it.
I just created one anonymous array with the elements I wanted then used the
following loop.
foreach my $file (@files) {
print join( "\t", @$file[0], @$file[1] ), "\n";
$ftp->put(@$file[0], @$file[1]) || die "can'
Thank you in advance.
Each anonymous array @files and @newFiles has 5 total elements.
How can I alter this nested for so that just the unique elements are
printed instead of each element twice?
foreach my $file (@files) {
foreach my $newFileName ( @newFiles ) {
print join( "\t", @$file, @$ne
This way works:
## read the .bib database and extract the cited out
foreach $item (@citeditems){
match($item);
}
sub match{
open my $fh2, '<', $bib_filename;
LINE: while(my $line = <$fh2>){
if ($line =~ m/@_\,/ .. $line =~ /^\}$/){
## read the .bib database and extract the cited out
open my $fh2, '<', $bib_filename;
foreach $item (@citeditems){
match($item);
}
sub match{
my $reg = @_;
LINE: while(my $line = <$fh2>){
if ($line =~ m/$reg\,/ .. $line =~ /^\}$/){
Hi Lina,
On Wed, Mar 14, 2012 at 10:15 AM, lina wrote:
> Thanks all, here comes the update one:
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> use Carp qw(croak);
> use autodie qw(open close);
> use File::Basename;
>
> croak "Usage: ./bibextract.pl tex_file.tex" unless defined $ARGV[0
Thanks all, here comes the update one:
#!/usr/bin/env perl
use strict;
use warnings;
use Carp qw(croak);
use autodie qw(open close);
use File::Basename;
croak "Usage: ./bibextract.pl tex_file.tex" unless defined $ARGV[0];
my $infile = $ARGV[0];
my $tex_file = $infile;
#my $bib_filename = "/hom
open my $fh, '<', $tex_file;
while(<$fh>){
if(/cite\{(\S+)\}/){
$cited = sprintf "%s\n",$1;
$cited =~ tr/\,/\n/;
push(@citeditems,$cited);
}
}
close($fh);
## read the .bib database and extract the cited out
open my $fh2, '<',
I updated a bit to
sr/bin/env perl
use strict;
use warnings;
use Carp qw(croak);
use autodie qw(open close);
use File::Basename;
croak "Usage: ./bibextract.pl tex_file.tex" unless defined $ARGV[0];
my $infile = $ARGV[0];
my $tex_file = $infile;
#my $bib_filename = "/home/lina/texmf/bibtex/bib/
#x27;, $tex_file;
while(<$fh>){
if(/cite\{(\S+)\}/){
$cited = sprintf "%s\n",$1;
$cited =~ tr/\,/\n/;
print $cited;
}
}
close($fh);
## read the .bib database and extract the cited out
open my $fh2, '<',
On 12-02-07 06:26 AM, Rob Dixon wrote:
in fact, if the objective is to reduce the code to something as brief as
possible then this will do the trick
my $match = (grep $_ eq $customers_zip, @{$states{$customers_state}})
? 'yes' : 'no';
You can use first from List::Util for more efficient cod
On 07/02/2012 01:39, sono...@fannullone.us wrote:
On Feb 6, 2012, at 1:42 PM, Steve Bertrand wrote:
This may be easier. It uses the hash elements directly as an
array, then uses grep to see if the zip code is within the specific
state. It returns true if the state owns that zip code, and false
On Feb 6, 2012, at 1:42 PM, Steve Bertrand wrote:
> This may be easier. It uses the hash elements directly as an array, then uses
> grep to see if the zip code is within the specific state. It returns true if
> the state owns that zip code, and false if it doesn't.
>
> if ( grep( /^$customers_z
On Mon, Feb 6, 2012 at 3:14 PM, wrote:
>So I'm creating a hash of arrays that contains a list of Zip Codes
> for the United States. I've also written a foreach loop to access this
> hash but I'd like to see if it could be written better. For example, do I
>
On 02/06/2012 04:58 PM, Parag Kalra wrote:
On Mon, Feb 6, 2012 at 1:14 PM, wrote:
For example, do I really need three foreach loops?
You can get rid of third ForLoop for sure.
you don't actually lose the third loop. grep is an implied loop.
STATE: foreach my $state
rint $match;
You are missing the point of hashes: that they can be indexed directly
by a key value, and there is no need to loop through all elements of the
has. You can reduce you code to just one loop:
foreach my $zip (@{$states{$customers_state}}) {
if ($zi
On Mon, Feb 6, 2012 at 1:14 PM, wrote:
>For example, do I really need three foreach loops?
>
>
>
You can get rid of third ForLoop for sure.
use strict;
use warnings;
my %states = (
AL => [ '350','351', ],
AK => [ '995','996', ],
AZ => [ '850','851', ],
AR => [ '
s for
the United States. I've also written a foreach loop to access this hash but
I'd like to see if it could be written better. For example, do I really need
three foreach loops?
Also, the first line that's printed contains "499" and I can't figure
out whe
I have a web form where people enter their address info and I want to
make sure that the first three digits of their Zip Code correspond to their
State.
So I'm creating a hash of arrays that contains a list of Zip Codes for
the United States. I've also written a fo
On Mon, Aug 29, 2011 at 03:27:52PM +0100, Rob Dixon wrote:
>
> Hey Mike. Ruud was just proposing a "wouldn't it be nice if" syntax. It
> isn't valid Perl!
>
> Rob
Well that explains the errors.
I've gotten so many good ideas from his posts it didn't dawn on me
to doubt the validity of this one.
On 28/08/2011 19:48, Mike McClain wrote:
On Sat, Aug 27, 2011 at 08:16:50PM +0200, Dr.Ruud wrote:
I would like 'lazy' syntax like:
<$fh> x {/^#/ or print};
to process a list.
When I tried your code like so:
open my $fh, '<', $file or die qq(Unable to open $file: $! );
<$fh>
On Sat, Aug 27, 2011 at 08:16:50PM +0200, Dr.Ruud wrote:
> I would like 'lazy' syntax like:
>
> <$fh> x {/^#/ or print};
>
> to process a list.
When I tried your code like so:
open my $fh, '<', $file or die qq(Unable to open $file: $! );
<$fh> x {/^\s*#/ or print};
close $fh
On 2011-08-26 19:23, Brandon McCaig wrote:
Personally I think that it's easier to read without the labels. I
think that any programmer that added an inner loop and didn't refactor
the corresponding 'next', 'last', or 'redo' statement should be given
up on
On 2011-08-26 21:08, Rob Dixon wrote:
But I would be sad to rule against niceties like
not /^#/ and print for <$fh>;
Which can also be written as
/^#/ or print for <$fh>;
I would like 'lazy' syntax like:
<$fh> x {/^#/ or print};
to process a list.
--
Ruud
--
To unsubscribe, e-mail:
On Aug 26, 12:25 pm, shlo...@shlomifish.org (Shlomi Fish) wrote:
> ...
> The problem starts to happen when you try to declare $a and $b using my. This
> program:
>
> [CODE]
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $a = 5;
> my $b = 6;
>
> print map { "$_\n" } sort { $a <=> $b } (9,1
On Aug 26, 12:25 pm, shlo...@shlomifish.org (Shlomi Fish) wrote:
> On Fri, 26 Aug 2011 20:08:31 +0100
>
> ...
>
> The problem starts to happen when you try to declare $a and $b using my. This
> program:
>
> [CODE]
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $a = 5;
> my $b = 6;
>
> pri
On 26/08/2011 18:12, Jim Gibson wrote:
On 8/25/11 Thu Aug 25, 2011 5:20 PM, "Rob Dixon"
scribbled:
On 25/08/2011 20:36, Shlomi Fish wrote:
If you want to use $_ so be it, but it can easily introduce subtle errors
into
your code, because $_ is so easy to modify and clobber. So I would recomm
information on which to base this decision.
> >
> > They also need to be encouraged to use "best practices". However, what
> > exactly best practices are is open to debate.
>
> I believe the fragility of $_ is apocryphal, and Shlomi's insistence on
> avoidi
On 11-08-26 03:08 PM, Rob Dixon wrote:
As an aside, the same applies to the common warning against using the
global values $a and $b 'because they are used by sort'. Once again,
sort localizes these variables within the comparison code so there is
very little chance of inadvertently modifying the
dds noise to a program and makes it frustrating to read.
As Randal says, $_ is localized everywhere it is used implicitly by a
loop, including foreach, map and grep as well as the List::Util
functions, so I believe that corrupting it is rarely a problem in
practice. The significant exception is whi
ly I think that it's easier to read without the labels. I
think that any programmer that added an inner loop and didn't refactor
the corresponding 'next', 'last', or 'redo' statement should be given
up on. :P Whenever you modify code you can potentially
On 8/25/11 Thu Aug 25, 2011 5:20 PM, "Rob Dixon"
scribbled:
> On 25/08/2011 20:36, Shlomi Fish wrote:
>>
>> If you want to use $_ so be it, but it can easily introduce subtle errors
>> into
>> your code, because $_ is so easy to modify and clobber. So I would recommend
>> against these, and st
On 25/08/2011 20:36, Shlomi Fish wrote:
If you want to use $_ so be it, but it can easily introduce subtle errors into
your code, because $_ is so easy to modify and clobber. So I would recommend
against these, and still think it's a good idea.
Please substantiate this assertion. I believe you
Hi Randal,
On Thu, 25 Aug 2011 11:41:34 -0700
mer...@stonehenge.com (Randal L. Schwartz) wrote:
> > "Shlomi" == Shlomi Fish writes:
>
> Shlomi> Well, I believe I've always avoided using an implicit $_ as
> Shlomi> preventative measure (out of thinking I know better) and so cannot
> Shlomi>
> "Shlomi" == Shlomi Fish writes:
Shlomi> Well, I believe I've always avoided using an implicit $_ as preventative
Shlomi> measure (out of thinking I know better) and so cannot present such a
case
Shlomi> first-hand. However, see:
Shlomi> http://www.forum2.org/gaal/perl/Pitfall/slide001.htm
can be clobbered and devastated too
> Shlomi> easily, which also makes depending on it error prone.
>
> Well, that's interesting. I've *never* accidentally clobbered
> $_. Nearly everything that uses $_ localizes it immediately, except for
> the implicit assignment t
one.
Well, that's interesting. I've *never* accidentally clobbered
$_. Nearly everything that uses $_ localizes it immediately, except for
the implicit assignment to $_ during a while-reading-filehandle loop, or
being the target of a s/old/new/ operation, which I consider something
to learn properl
Hi Rob,
On Wed, 24 Aug 2011 23:07:13 +0100
Rob Dixon wrote:
> On 22/08/2011 10:29, Shlomi Fish wrote:
> > Hi Alan,
> >
> > On Mon, 22 Aug 2011 14:43:48 +0530
> > Alan Haggai Alavi wrote:
> >
> >> Hello Shlomi,
> >>
> >>> It's a good idea to always use "last LABEL;" instead of "last;" (as well
>
On 22/08/2011 10:29, Shlomi Fish wrote:
Hi Alan,
On Mon, 22 Aug 2011 14:43:48 +0530
Alan Haggai Alavi wrote:
Hello Shlomi,
It's a good idea to always use "last LABEL;" instead of "last;" (as well as
"next LABEL;" etc. in case more loops are added in between.
⋮
http://perl-begin.org/tutorial
On 8/24/11 Wed Aug 24, 2011 8:32 AM, "Emeka"
scribbled:
> Do we really need "goto" here?
>
> Emeka
No, we don't need a goto here. The statement 'last' is effectively a 'goto'
but with the restriction that it will only work inside a loop
On Wed, 24 Aug 2011 16:32:30 +0100
Emeka wrote:
> Do we really need "goto" here?
>
Where do you see a "goto"? Perl 5 has a goto statement (see
http://perldoc.perl.org/functions/goto.html ) and it's pretty flexible, but we
did not use it here, and instead used "last LABEL" or "next LABEL" which
Do we really need "goto" here?
Emeka
On Mon, Aug 22, 2011 at 10:03 AM, Shlomi Fish wrote:
> Hi Alan,
>
> On Mon, 22 Aug 2011 13:10:05 +0530
> Alan Haggai Alavi wrote:
>
> > Hello Anant,
> >
> > > i want to input some numbers via in while
On 11-08-22 07:37 PM, Randal L. Schwartz wrote:
"anant" == anant mittal writes:
anant> $ln[$i]=;
I'd swear that lowercase "stdin" was deprecated already, but I can't
find any record of it in the deltas, and it still works in 5.12 (I don't
have 5.14 compiled here).
In any case, you should s
> "anant" == anant mittal writes:
anant> $ln[$i]=;
I'd swear that lowercase "stdin" was deprecated already, but I can't
find any record of it in the deltas, and it still works in 5.12 (I don't
have 5.14 compiled here).
In any case, you should shift to the proper STDIN, as everyone else's
a
On 11-08-22 05:03 AM, Shlomi Fish wrote:
It's a good idea to always use "last LABEL;" instead of "last;" (as well as
"next LABEL;" etc. in case more loops are added in between.
Good idea but try to choose meaningful names. Also, the else clause is
not needed.
[CODE]
use strict;
use warnings
Hi Alan,
On Mon, 22 Aug 2011 14:43:48 +0530
Alan Haggai Alavi wrote:
> Hello Shlomi,
>
> > It's a good idea to always use "last LABEL;" instead of "last;" (as well as
> > "next LABEL;" etc. in case more loops are added in between.
> > ⋮
> > http://perl-begin.org/tutorials/bad-elements/#flow-stm
Hello Shlomi,
> It's a good idea to always use "last LABEL;" instead of "last;" (as well as
> "next LABEL;" etc. in case more loops are added in between.
> ⋮
> http://perl-begin.org/tutorials/bad-elements/#flow-stmts-without-labels
Now I understand why it is always good to label loops that use `l
Hi Alan,
On Mon, 22 Aug 2011 13:10:05 +0530
Alan Haggai Alavi wrote:
> Hello Anant,
>
> > i want to input some numbers via in while loop.And loop should be
> > broken if any nonnumeric character is entered.So how
arr=qw( home father son sun mother drinks);
for(my $i=0;$i<=1;$i++){
pop @arr; # you can also use function "pop" to reduce the
# element of array, here using a for loop to
# iterate twice with pop we removed the last
# two
Hello Anant,
> i want to input some numbers via in while loop.And loop should be
> broken if any nonnumeric character is entered.So how it can be checked.
>
>
> .
> my @ln;
> my $i=0;
> print"Give line numbers
hello!
i want to input some numbers via in while loop.And loop should be
broken if any nonnumeric character is entered.So how it can be checked.
.
my @ln;
my $i=0;
print"Give line numbers you want to put into array.\n";
while(1){
$ln[$i
1 - 100 of 919 matches
Mail list logo