On 12-03-13 12:11 PM, oxy wrote:
I have a problem with the following structure:
while(){$thevariable=$1 if (/variable1=(.*)/)};
Now I wanna be sure that variable1 was really set in the above
statement (it could have an old value from a previous embracing loop).
Then I tried:
while(){if (/varia
On 3/13/12 Tue Mar 13, 2012 9:11 AM, "oxy"
scribbled:
> hi all,
>
> I have a problem with the following structure:
>
> while(){$thevariable=$1 if (/variable1=(.*)/)};
>
> Now I wanna be sure that variable1 was really set in the above
> statement (it could have an old value from a previous em
Hi Oxy,
In addition,
On Mon, Mar 12, 2012 at 6:34 PM, Jim Gibson wrote:
> On 3/12/12 Mon Mar 12, 2012 10:17 AM, "oxy"
> scribbled:
>
> > Hi,
> >
> > i have the following file content: numbers = one two three four
> >
> > I run the code:
> > = begin code ==
> > #
On 3/12/12 Mon Mar 12, 2012 10:17 AM, "oxy"
scribbled:
> Hi,
>
> i have the following file content: numbers = one two three four
>
> I run the code:
> = begin code ==
> #!/usr/bin/perl -w
> $AG2 = non;
> $AG3 = non;
> open (file , "
> while(){if (/(.*)\s*=\s*.
rl.org
Sent: Fri, 12 August, 2011 14:13:26
Subject: Re: while(@data) works but why
On 8/12/11 Fri Aug 12, 2011 12:02 PM, "Tony Esposito"
scribbled:
> .
> .
> .
> while(@dat = $sth->fetchrow) {
> print "@dat\n";
> .
> .
> .
>
> This cod
got it ... thank you. cheers!
From: Brandon McCaig
To: Tony Esposito
Cc: beginners@perl.org
Sent: Fri, 12 August, 2011 14:08:52
Subject: Re: while(@data) works but why
On Fri, Aug 12, 2011 at 3:02 PM, Tony Esposito
wrote:
> .
> .
> .
> while
On 8/12/11 Fri Aug 12, 2011 12:02 PM, "Tony Esposito"
scribbled:
> .
> .
> .
> while(@dat = $sth->fetchrow) {
> print "@dat\n";
> .
> .
> .
>
> This code works yet there is no 'my @dat' defined anywhere in the code.
> Using Perl 5.8.x - 5.14.x
>
> Q: Why does the variable @dat not nee
On Fri, Aug 12, 2011 at 3:02 PM, Tony Esposito
wrote:
> .
> .
> .
> while(@dat = $sth->fetchrow) {
> print "@dat\n";
> .
> .
> .
>
> This code works yet there is no 'my @dat' defined anywhere in the code.
> Using Perl 5.8.x - 5.14.x
>
> Q: Why does the variable @dat not need a 'my' in front
Uri Guttman wrote:
"JWK" == John W Krahn writes:
>> Also, how does 'eval' work and when is it useful? What is the difference if
>> we put a block inside eval like: eval ( };
JWK> eval interprets a string as Perl code and compiles and runs it. If
JWK> you are using a block eval then
> "JWK" == John W Krahn writes:
>> Also, how does 'eval' work and when is it useful? What is the difference if
>> we put a block inside eval like: eval ( };
JWK> eval interprets a string as Perl code and compiles and runs it. If
JWK> you are using a block eval then the block must b
Arun P Menon wrote:
Hello All,
Hello,
Could you tell me what does the following do?
1 while (<>);
That reads through all the files listed on the command line, or if there
are no files listed on the command line then it reads through STDIN, and
does nothing with the lines read, but does se
John W. Krahn wrote:
Peter Daum wrote:
Unfortunately, this leads right to the next problem:
I also need "binmode" to turn off cr/lf conversion on DOS;
with "while (<>)" I don't know where to do this anymore,
because AFAIK, this has to be done after open, but before
the 1st I/O; now before the "
From: Peter Daum
> I occasionally have to write Perl scripts that should behave the same on
> Unix- and DOS-like Systems. One little problem I encounter there is:
>
> For quick hacks, the "while(<>)" mechanism is very handy, because it
> saves a lot of typing. On Unix, I can call a script as a fi
Peter Daum wrote:
Shawn H. Corey wrote:
I've always used:
beg...@argv=glob(@ARGV)}
... I still need at least:
BEGIN{ @ARGV=map { glob($_) } @ARGV }
but that's already much shorter - thanks :-)
Unfortunately, this leads right to the next problem:
I also need "binmode" to turn off cr/lf con
Shawn H. Corey wrote:
Peter Daum wrote:
Unfortunately, this leads right to the next problem:
I also need "binmode" to turn off cr/lf conversion on DOS;
with "while (<>)" I don't know where to do this anymore,
because AFAIK, this has to be done after open, but before
the 1st I/O; now before th
From: Peter Daum
>
> I occasionally have to write Perl scripts that should behave the same
on
> Unix- and DOS-like Systems. One little problem I encounter there is:
I am using Camelbox Perl on WinXP. This is my command line for unit
tests:
perl -MTest::Harness -e "@ARGV= map glob, @ARGV if $^O =
Peter Daum wrote:
Shawn H. Corey wrote:
I've always used:
beg...@argv=glob(@ARGV)}
... I still need at least:
BEGIN{ @ARGV=map { glob($_) } @ARGV }
but that's already much shorter - thanks :-)
Unfortunately, this leads right to the next problem:
I also need "binmode" to turn off cr/lf con
Ed Avis wrote:
Peter Daum yahoo.de> writes:
With more recent Perl versions, when
a script is called with '*.xyz' it will just try to open '*.xyz' and
fail.
What version of Perl do you have? (perl -V)
... when I 1st encountered this problem, it was with ActivePerl 5.8
generally, I try t
Shawn H. Corey wrote:
I've always used:
beg...@argv=glob(@ARGV)}
... I still need at least:
BEGIN{ @ARGV=map { glob($_) } @ARGV }
but that's already much shorter - thanks :-)
Unfortunately, this leads right to the next problem:
I also need "binmode" to turn off cr/lf conversion on DOS;
wit
Peter Daum yahoo.de> writes:
>With more recent Perl versions, when
>a script is called with '*.xyz' it will just try to open '*.xyz' and
>fail.
What version of Perl do you have? (perl -V)
--
Ed Avis
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail:
Peter Daum wrote:
Is all this really necessary, or is there a better / more elegant way?
I've always used:
beg...@argv=glob(@ARGV)}
--
Just my 0.0002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
My favourite four-lett
On Thu, Jul 23, 2009 at 21:29, Steve Bertrand wrote:
> I just ran into an issue where I was loosing literally half of some
> expected data, which for a theoretical accounting system, would make for
> some interesting audit trails (I already shave a fraction for myself,
> but 50% will be noticeable
Jo for lists and groups wrote:
Are you supposed to be printing something here?
Somewhat newb, but this doesn't look right to me:
print (FO);
That is short for:
print( FO $_ );
The $_ variable is the default in a lot of places in Perl code.
I'm guessing you want to remove commas an
Are you supposed to be printing something here?
Somewhat newb, but this doesn't look right to me:
print (FO);
I'm guessing you want to remove commas and so are rewriting the line into a
new file after subst. I'd probably do
print FO "$_";
I suspect your way may just be leaving the server
- CFS
[mailto:david.wag...@fedex.com]
Sent: Thursday, July 16, 2009 1:46 PM
To: Patrick K Christopher TANAGER; beginners@perl.org
Subject: RE: While issues
> -Original Message-
> From: Patrick K Christopher TANAGER
> [mailto:pchristop...@tanagerinc.com]
> Sent: Thursday, July 16
> -Original Message-
> From: Patrick K Christopher TANAGER
> [mailto:pchristop...@tanagerinc.com]
> Sent: Thursday, July 16, 2009 11:39
> To: beginners@perl.org
> Subject: While issues
>
> I can't seem to find this oddness in this script.
> #! /usr/bin/perl
You should use strict
Patrick K Christopher TANAGER wrote:
I can't seem to find this oddness in this script.
#! /usr/bin/perl
open(FH,"<$ARGV[0]") || die ("File failed to open!\n");
open(FO,">$ARGV[1]") || die ("Output failed to open!\n");
while (){
s/,//g
s/,//g;
# Watch your semi-colons :)
print (FO);
}
clo
On Sep 5, 5:32 am, [EMAIL PROTECTED] (Hridyesh Pant) wrote:
> in my case this works
> while (<>) {
> chomp;
> my ($id, $record) = split(/\t+/,$_);
> push @{$table{$id}}, $record;
> }
>
> foreach $id (sort keys %table) {
> print "$id ";
> my @records = @{$table{
On Fri, 2008-09-05 at 15:27 +0200, Dr.Ruud wrote:
> Why use $1 if you can get the match by putting the regex in a list
> context?
>
> while ( <$in> ) {
> if( my ($id) = m/^\s*(\d+)/ ) {
> $longz{$id} = $_;
> }
> else {
> die "no ID in line $.: $_";
> }
"Mr. Shawn H. Corey" schreef:
> while( ){
> if( /^\s*(\d+)/ ){
> my $id = $1;
> $longz{$id} = $_;
> }else{
> die "no ID in line $.: $_";
> }
> }
Why use $1 if you can get the match by putting the regex in a list
context?
while ( <$in> ) {
if( my ($id) = m/^\s*(\d+)/ )
On Fri, 2008-09-05 at 20:35 +0800, Jeff Pang wrote:
> 2008/9/5 Mr. Shawn H. Corey <[EMAIL PROTECTED]>:
>
> > if( /^\s*(\d+)/ ){
> >my $id = $1;
> >$longz{$id} = $_;
>
> I prefer the shorter one:
>
> $longz{$1} = $_;
I prefer defencive programming techniques. After every match, assign
2008/9/5 Mr. Shawn H. Corey <[EMAIL PROTECTED]>:
> if( /^\s*(\d+)/ ){
>my $id = $1;
>$longz{$id} = $_;
I prefer the shorter one:
$longz{$1} = $_;
--
Regards,
Jeff.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
in my case this works
while (<>) {
chomp;
my ($id, $record) = split(/\t+/,$_);
push @{$table{$id}}, $record;
}
foreach $id (sort keys %table) {
print "$id ";
my @records = @{$table{$id}};
print join ', ', sort @records;
print "\n";
}
--Hridyesh
fraz
On Thu, 2008-09-04 at 14:03 -0700, frazzmata wrote:
> I have a problem
> I am trying to take lines in a text file that look like this. although
> there are 500 more or so (and they have more realistic names)
>
> 25727 dude, some M MEX.AMER. DORM1
> 25797 dude, other M BLACK DORM2
>
frazzmata wrote:
I have a problem
I am trying to take lines in a text file that look like this. although
there are 500 more or so (and they have more realistic names)
25727 dude, some M MEX.AMER. DORM1
25797 dude, other M BLACK DORM2
29291 guy, randomM BLACK DORM3
3024
From: Richard Lee
>John W. Krahn wrote:
>> Richard Lee wrote:
>>> I am begining to read bit of low level(assembly) book to just gain
>>> some knoweldge on inner workings of memory.
>>>
>>> My quesiton is, if machine is 32 bit, even if it's accessing string
>>> 'A', it will have to fetch 32 bit (i
Richard Lee wrote:
Just one more question on the topic,
I am trying to understand how it works in binary world.
So, If let's say I take a pcap file. I am assuming here that
ethereal/wireshark will take binaries on the wire and then decoding it
based on pcap standard(? hex? ) and then present t
John W. Krahn wrote:
Richard Lee wrote:
I am begining to read bit of low level(assembly) book to just gain
some knoweldge on inner workings of memory.
My quesiton is, if machine is 32 bit, even if it's accessing string
'A', it will have to fetch 32 bit (instead of 8 bit that requires to
make
John W. Krahn wrote:
Richard Lee wrote:
I am begining to read bit of low level(assembly) book to just gain
some knoweldge on inner workings of memory.
My quesiton is, if machine is 32 bit, even if it's accessing string
'A', it will have to fetch 32 bit (instead of 8 bit that requires to
make
Richard Lee wrote:
I am begining to read bit of low level(assembly) book to just gain some
knoweldge on inner workings of memory.
My quesiton is, if machine is 32 bit, even if it's accessing string 'A',
it will have to fetch 32 bit (instead of 8 bit that requires to make
that letter A ) ?
I
Richard Lee wrote:
>
> I am begining to read bit of low level(assembly) book to just gain some
> knoweldge on inner workings of memory.
>
> My quesiton is, if machine is 32 bit, even if it's accessing string 'A',
> it will have to fetch 32 bit (instead of 8 bit that requires to make
> that lett
In article <[EMAIL PROTECTED]>, Richard Lee
<[EMAIL PROTECTED]> wrote:
> While reading 'mastering perl', I run into @- and @+ for the first time.
> Trying to understand what's going on, I ran the code from the book, but
>
> $-[1] and $+[1] shoudln't match only the first match? (in this case,
> sh
John W. Krahn wrote:
Richard Lee wrote:
Thanks John for detailed explanation!!
I just dont' understand why \ (also didn't know that within [ ], \
has to be escaped.) needs to be watch out for within " " ..
\ use can be tricky, for example:
$ perl -le"print 'hello'"
hello
$ perl -le"print '
Richard Lee wrote:
Thanks John for detailed explanation!!
I just dont' understand why \ (also didn't know that within [ ], \ has
to be escaped.) needs to be watch out for within " " ..
\ use can be tricky, for example:
$ perl -le"print 'hello'"
hello
$ perl -le"print 'he\llo'"
he\llo
$ perl
John W. Krahn wrote:
Richard Lee wrote:
Took your advice and start to read 'Mastering regular expression' by
Jeffrey E.F.Friedl,
Can you explain below further?
on page, 205
push(@fields, $+) while $text =~ m{
"([^\"\\]*(?:\\.[^\"\\]*)*)",? #standard quoted string(with
possible co
Richard Lee wrote:
Took your advice and start to read 'Mastering regular expression' by
Jeffrey E.F.Friedl,
Can you explain below further?
on page, 205
push(@fields, $+) while $text =~ m{
"([^\"\\]*(?:\\.[^\"\\]*)*)",? #standard quoted string(with
possible comma)
| ([^,]+),?
Say you have the string "abcdefghi".
The positions in the string are:
a b c d e f g h i
^ ^ ^ ^ ^ ^ ^ ^ ^ ^
0 1 2 3 4 5 6 7 8 9
If you have the regular expression:
/(de)/
Then the match starts at position 3, moves forward two characters, and
ends at position 5, where the next match, i
Rob Dixon wrote:
Richard Lee wrote:
Rob Dixon wrote:
Perhaps it would help to think of the offset as being the index of the
points between the characters, so the start of the string is at offset
zero, after 'a' (and before 'b') is at offset one and so on. Then can
you see how offset 7 is befor
Richard Lee wrote:
Rob Dixon wrote:
Perhaps it would help to think of the offset as being the index of the
points between the characters, so the start of the string is at offset
zero, after 'a' (and before 'b') is at offset one and so on. Then can
you see how offset 7 is before 'hi' and offset
Richard Lee wrote:
John W. Krahn wrote:
Richard Lee wrote:
While reading 'mastering perl', I run into @- and @+ for the first time.
perldoc perlvar
Trying to understand what's going on, I ran the code from the book, but
$-[1] and $+[1] shoudln't match only the first match? (in this case,
Rob Dixon wrote:
Richard Lee wrote:
John W. Krahn wrote:
Richard Lee wrote:
While reading 'mastering perl', I run into @- and @+ for the first
time.
perldoc perlvar
Trying to understand what's going on, I ran the code from the book,
but
$-[1] and $+[1] shoudln't match only the first mat
Richard Lee wrote:
John W. Krahn wrote:
Richard Lee wrote:
While reading 'mastering perl', I run into @- and @+ for the first time.
perldoc perlvar
Trying to understand what's going on, I ran the code from the book, but
$-[1] and $+[1] shoudln't match only the first match? (in this case,
John W. Krahn wrote:
Richard Lee wrote:
While reading 'mastering perl', I run into @- and @+ for the first time.
perldoc perlvar
Trying to understand what's going on, I ran the code from the book, but
$-[1] and $+[1] shoudln't match only the first match? (in this case,
shoudln't it be, 7 t
Richard Lee wrote:
While reading 'mastering perl', I run into @- and @+ for the first time.
perldoc perlvar
Trying to understand what's going on, I ran the code from the book, but
$-[1] and $+[1] shoudln't match only the first match? (in this case,
shoudln't it be, 7 to 8 ?, instead of 7 to
> -Original Message-
> From: John W. Krahn [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 15, 2008 1:39 PM
> To: Perl Beginners
> Subject: Re: while and last
> my $data = ; # Grap one line from file
Doh!
Thanks :)
Kevin Viel, PhD
Post-doctoral fellow
Depa
Kevin Viel wrote:
Hello,
Hello,
If I only want the data on the first line of a file, can I use "last" to
exit the loop or should I consider another tool?
Don't use a loop at all:
my $data = ; # Grap one line from file
John
--
Perl isn't a toolbox, but a small machine shop where you
ca
On 2/7/07, Rob Dixon <[EMAIL PROTECTED]> wrote:
Igor Sutton wrote:
> Hi fellows,
>
>> Dave, you wanted to use
>>
>> while (1) {
>> ...
>> the code to be repeated
>> ..
>> }
>>
>
> The above code could be written like this:
>
> {
>...
># the code to be repeated
>...
>redo;
>
Igor Sutton wrote:
Hi fellows,
Dave, you wanted to use
while (1) {
...
the code to be repeated
..
}
The above code could be written like this:
{
...
# the code to be repeated
...
redo;
}
Do you think this is better or worse than the other idiom? I like the
last more.
Done it, thank you all for your help.
My next problem is regexp, you my be hearing from me :)
Regards
Brad
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
Brad Cahoon wrote:
> Hi Perl Masters
Hello,
> I have a problem with a script which is suposed to open a huge text
> file and take 70 lines, create a file, then take the next 70 lines
> create a file and so on until it has parsed the whole file. My code
> just doesn't work and my brain cannot figu
Brad Cahoon wrote:
Hi Perl Masters
I have a problem with a script which is suposed to open a huge text
file and take 70 lines, create a file, then take the next 70 lines
create a file and so on until it has parsed the whole file. My code
just doesn't work and my brain cannot figure out while{whi
Brad Cahoon wrote:
> Hi Perl Masters
>
> I have a problem with a script which is suposed to open a huge text
> file and take 70 lines, create a file, then take the next 70 lines
> create a file and so on until it has parsed the whole file. My code
> just doesn't work and my brain cannot figure out
On May 25, Jay Savage said:
On 5/25/05, Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
On May 25, Jay Savage said:
/e(?{push @bar, pos})/g;
should work, but seems to ignore the /g.
Because as you wrote it, the regex is in void context, which means it'll
only match once. Put it in list co
On 5/25/05, Jay Savage <[EMAIL PROTECTED]> wrote:
[snip]
>/p(?:{push @bar, pos})attern(?!)/g
oops!
make that:
/p(?{push @bar, pos})attern(?!)/g
--
daggerquill [at] gmail [dot] com
http://www.engatiki.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional c
On 5/25/05, Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote:
> On May 25, Jay Savage said:
>
> > /e(?{push @bar, pos})/g;
> >
> > should work, but seems to ignore the /g.
>
> Because as you wrote it, the regex is in void context, which means it'll
> only match once. Put it in list context:
>
>
On May 25, Jay Savage said:
/e(?{push @bar, pos})/g;
should work, but seems to ignore the /g.
Because as you wrote it, the regex is in void context, which means it'll
only match once. Put it in list context:
() = /e(?{ push @bar, pos })/g;
But this looks weird to almost anyone. I'd d
On 5/25/05, Jay Savage <[EMAIL PROTECTED]> wrote:
> On 5/24/05, Robert Citek <[EMAIL PROTECTED]> wrote:
> > I like your idea. Unfortunately, the above works only in the special
> > case where the regular expression match is actually a single-
> > character, exact match.
> >
> > Regards,
> > - Robe
On 5/24/05, Robert Citek <[EMAIL PROTECTED]> wrote:
>
> On May 24, 2005, at 3:14 PM, Jay Savage wrote:
> > One thing that springs to mind is:
> >
> >perl -le '
> >$foo = "fee fie foe foo";
> >map {$i++; push @bar, $i if $_ eq "e"} split //, $foo;
> >print join(":",@bar)'
> >
> > I'
On 5/24/05, Robert Citek wrote:
>
> I found a variation of this in the Perl Nutshell book:
>
> $ perl -le '
> $foo="fee fie foe foo" ;
> while ($foo =~ m/e/g ) {
> push @bar, pos $foo ;
> }
> print join(":", @bar); '
> 2:3:7:11
>
> Is there an equivalent way to do the same using map
Xavier Noria [XN], on Tuesday, May 24, 2005 at 22:12 (+0200) typed the
following:
XN> my $i = 0;
XN> my @bar = map $_->[1], # take second component
XN>grep $_->[0] eq 'e', # let 'e's pass
XN>map [$_, ++$i],# arrayref [char, index of cha
Am Dienstag, 24. Mai 2005 19.22 schrieb Robert Citek:
> I found a variation of this in the Perl Nutshell book:
>
> $ perl -le '
> $foo="fee fie foe foo" ;
> while ($foo =~ m/e/g ) {
> push @bar, pos $foo ;
> }
> print join(":", @bar); '
> 2:3:7:11
>
> Is there an equivalent way to do th
On May 24, 2005, at 19:22, Robert Citek wrote:
I found a variation of this in the Perl Nutshell book:
$ perl -le '
$foo="fee fie foe foo" ;
while ($foo =~ m/e/g ) {
push @bar, pos $foo ;
}
print join(":", @bar); '
2:3:7:11
Is there an equivalent way to do the same using map instead of a
- Original Message -
From: TapasranjanMohapatra <[EMAIL PROTECTED]>
Date: Wednesday, February 9, 2005 9:17 am
Subject: while(1){print "a"; sleep 1;}
> Hi All,
Hello,
>
> Why I dont get a's printed with the code below?
Works well on my system, are you sure you are not redirecting the out
TapasranjanMohapatra ha scritto:
Hi All,
Why I dont get a's printed with the code below?
+++
while(1)
{
print "a";
sleep 1;
}
+++
It works well if I print a newline with a, i.e
while(1)
{
print "a\n"; # newline with a
sleep 1;
}
Please hel
-Original Message-
From: Chris Devers [mailto:[EMAIL PROTECTED]
Sent: Wed 2/9/2005 8:01 PM
To: TapasranjanMohapatra
Cc: Perl Beginners List
Subject:Re: while(1){print "a"; sleep 1;}
On Wed, 9 Feb 2005, TapasranjanMohapatra wrote:
> Why I dont get a
On Wed, 9 Feb 2005, TapasranjanMohapatra wrote:
> Why I dont get a's printed with the code below?
Apparently it's an output buffering issue.
If you flush output, it works:
$ perl -e 'while(1){print"a";sleep 1}'
^C
$ perl -e '$|=1;while(1){print"a";sleep 1}'
aaa^C
$
So, setting $|
TapasranjanMohapatra [T], on Wednesday, February 9, 2005 at 19:47
(+0530) typed the following:
T> It works well if I print a newline with a, i.e
I hope it works without sleep 1, try that, and you will see the
answer.
--
...m8s, cu l8r, Brano.
["You should never go in there without a mongoos
On Monday, Nov 17, 2003, at 09:04 US/Pacific, Jeff 'japhy' Pinyan wrote:
[..]
which only reads ONE line at a time, whereas
for () { ... }
reads ALL the lines of the file at once, into a list.
really good point there.
but wouldn't the position been just a tad stronger
had you noted that the abo
On Nov 17, angie ahl said:
>I keep getting hung up on deciding whether to use for or while for
>loops.
Well, it usually depends on how the code "reads". I use 'while' for loops
based on a condition that will change in some execution of the block.
while () {
# eventually, will return unde
Sorry guys. There's a keyboard shortcut set up on my PC that
sends my current mail that I often hit accidentally. It means
I occasionally post half-finished mails. I'll knuckle-down
and fix it. This is the post as it should have been:
Hi Trevor.
Trevor Morrison wrote:
>
> I am trying to step th
From: "Morrison, Trevor (Trevor)" <[EMAIL PROTECTED]>
> What I am trying to do is to process a file that has say 1000 orders
> in it all pretty much of the same format. I want to open up the file,
> and then using a while loop go down through all of the order
> one-at-a-time and once I have all th
al Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2003 3:01 PM
To: [EMAIL PROTECTED]
Subject: Re: While loop on a file handle
Sorry guys. There's a keyboard shortcut set up on my PC that
sends my current mail that I often hit accidentally. It means
I occasionally pos
"Trevor Morrison" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hi,
>
> I am trying to step through each line of a file that contains orders that
> were place through a internet shopping cart. I have this code:
>
> open(ORDER,$order) or die "Error opening \"$order\": $OS_ERROR\n"
--On Wednesday, August 06, 2003 2:50 PM +0200 Jenda Krynicky
<[EMAIL PROTECTED]> wrote:
From: "Morrison, Trevor (Trevor)" <[EMAIL PROTECTED]>
What I am trying to do is to process a file that has say 1000 orders
in it all pretty much of the same format. I want to open up the file,
and then usin
On Tuesday, August 05, 2003 12:13, Trevor Morrison wrote:
>
>Hi,
>
>I am trying to step through each line of a file that contains orders that
>were place through a internet shopping cart. I have this code:
>
> open(ORDER,$order) or die "Error opening \"$order\": $OS_ERROR\n";
>
>print "HI\n";
> wh
Thank you all for your responses!! I finally have a handle on it and used a little of
everyones suggestions. This list rocks because of people like you. Thanks again!
Hi Bill,
I know you've had lots of comments on this, but I thought I'd throw my own
style in. Why not do your check at the bottom with a "do until"? First time
round the check is useless anyway, and will give you 'undef' type warnings
with perl -w. It also allows you to be more positive in your co
>Hi all!
>I have this while loop in my script:
>while (($type ne "Windows") || ($type ne "Linux")) {
>print "Enter TYPE of server to build. Linux or Windoze [linux, windows]:\n";
>$type = ;
>chomp $type;
>$type =~ tr/a-z/A-Z/;
>if (($type eq "LINUX") || ($type eq "L")) {
>$type = "Linux"; }
>i
Bill Akins <[EMAIL PROTECTED]> wrote:
:
: while (($type ne "Windows") || ($type ne "Linux")) {
This will always be true. Try:
while ( $type ne 'Windows' && $type ne 'Linux' ) {
^^
HTH,
Charles K. Clarkson
--
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Sorry...
In article <[EMAIL PROTECTED]>, Kevin Pfeiffer wrote:
> In article <[EMAIL PROTECTED]>, Kevin Pfeiffer wrote:
>
>
>> Here's an 'or' version:
>> my $type1 = '';
>> while ( $type1 !~ /wisteria|lime/i ) {
>>print "Enter COLOR of server. Lime or Wisteria [lime, wisteria]: ";
>>chom
In article <[EMAIL PROTECTED]>, Kevin Pfeiffer wrote:
> Here's an 'or' version:
> my $type1 = '';
> while ( $type1 !~ /wisteria|lime/i ) {
>print "Enter COLOR of server. Lime or Wisteria [lime, wisteria]: ";
>chomp( $type1 = ucfirst lc );
>$type1 = 'Wisteria' if $type1 eq 'W';
>$
In article <[EMAIL PROTECTED]>, John W. Krahn wrote:
> Bill Akins wrote:
>>
>> Hi all!
>
> Hello,
>
>> I have this while loop in my script:
>>
>> while (($type ne "Windows") || ($type ne "Linux")) {
>
> Your problem is that you are using or when you should be using and.
>
>
>> print "Enter
> > while (($type ne "Windows") || ($type ne "Linux")) {
> Right here, you must have the full string "Windows" or "Linux"
Yes, correct.
> > print "Enter TYPE of server to build. Linux or Windoze
> > [linux, windows]:
> > \n";
> > $type = ;
> > chomp $type;
> > $type =~ tr/a-z/A-Z/;
>
> Here yo
Bill Akins wrote:
>
> Hi all!
Hello,
> I have this while loop in my script:
>
> while (($type ne "Windows") || ($type ne "Linux")) {
Your problem is that you are using or when you should be using and.
> print "Enter TYPE of server to build. Linux or Windoze [linux, windows]:
> \n";
> $type =
> -Original Message-
> From: Bill Akins [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 02, 2003 3:48 PM
> To: [EMAIL PROTECTED]
> Subject: While loop, confused...
>
>
> Hi all!
>
> I have this while loop in my script:
>
> while (($type ne "Windows") || ($type ne "Linux")) {
Right
> Finally occurred to me to try using ARGV in slurp mode, which does
> indeed do the Right Thing:
>
>> #!/usr/bin/perl -l
>> use strict;
>> use warnings;
>>
>> die usage() if (@ARGV == 0)
>> or (@ARGV == 1 and -t STDIN);
>>
>> my $pattern = shift;
>> l
On Tue, Jun 17, 2003 at 04:34:04AM -0400, Steve Grazzini wrote:
> On Mon, Jun 16, 2003 at 10:33:28PM -0700, Bryan Harris wrote:
> > Pretty neat, Steve, thanks.
Well don't thank me too soon!
Finally occurred to me to try using ARGV in slurp mode, which does
indeed do the Right Thing:
> #!/usr
On Mon, Jun 16, 2003 at 10:33:28PM -0700, Bryan Harris wrote:
> Pretty neat, Steve, thanks. The only thing that'd be nice to
> fix is making it so it gives the usage line if you enter:
>
> % showme 'ah\d'
>
> instead of waiting for STDIN. Aside from that it works perfectly.
> And I learned a
- Original Message -
From: "Bryan Harris" <[EMAIL PROTECTED]>
To: "Beginners Perl" <[EMAIL PROTECTED]>
Sent: Tuesday, June 17, 2003 1:33 AM
Subject: Re: while (<>)
>
> > #!/usr/bin/perl
> >
> > my $showme = shift
> &g
> #!/usr/bin/perl
>
> my $showme = shift
> or die "Usage: $0 [FILES]\n";
>
> while (defined(my $line = <>)) {
> $_ .= $line;
> next unless eof; # [1]
>
> my $prefix = ($ARGV eq '-')? '' : "$ARGV: "; # [2]
>
> print "${prefix}$1\n" while /(
1 - 100 of 137 matches
Mail list logo