Re: why this open/print not work?

2010-05-08 Thread Shlomi Fish
On Sunday 09 May 2010 08:07:20 John W. Krahn wrote: > Xiao Lan (??) wrote: > > # cat t1.pl > > use strict; > > use warnings; > > > > my $cfg = "1.txt"; > > my @x = qw/a b c 1 2 3/; > > my $fd; > > > > open $fd,">",$cfg or die $!; > > print $fd for @x; > > Perl doesn't know that $fd is a filehand

Re: why this open/print not work?

2010-05-08 Thread 小兰
On Sun, May 9, 2010 at 1:07 PM, John W. Krahn wrote: > > Just remove the foreach statement modifier: > > print $fd @x; > > Thanks John. If @x is as large as 1000+ elements, should I do this print still? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail:

Re: why this open/print not work?

2010-05-08 Thread John W. Krahn
Xiao Lan (??) wrote: # cat t1.pl use strict; use warnings; my $cfg = "1.txt"; my @x = qw/a b c 1 2 3/; my $fd; open $fd,">",$cfg or die $!; print $fd for @x; Perl doesn't know that $fd is a filehandle and so it thinks you mean: print STDOUT $fd for @x; Just remove the foreach statement modi

Re: why this open/print not work?

2010-05-08 Thread chenfengyuan
do you mean: print $fd $_ for @x; On Sun, 09 May 2010 12:07:38 +0800, Xiao Lan (小兰) wrote: use strict; use warnings; my $cfg = "1.txt"; my @x = qw/a b c 1 2 3/; my $fd; open $fd,">",$cfg or die $!; print $fd for @x; close $fd; -- Using Opera's revolutionary e-mail client: http://www.

why this open/print not work?

2010-05-08 Thread 小兰
# cat t1.pl use strict; use warnings; my $cfg = "1.txt"; my @x = qw/a b c 1 2 3/; my $fd; open $fd,">",$cfg or die $!; print $fd for @x; close $fd; # perl t1.pl GLOB(0x818ab84)GLOB(0x818ab84)GLOB(0x818ab84)GLOB(0x818ab84)GLOB(0x818ab84)GLOB(0x818ab84) As you see the script won't work on my Lin

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
"John W. Krahn" writes: [...] > Why are you using push and sprintf? > >my @relist = "$r1name\n- -\n"; Much better... this is the only place I where I have anything that could even remotely be an excuse I tried using @relist, print "blah\n" Which didn't work then went t

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread John W. Krahn
Harry Putnam wrote: I'd like to be able to use the Lettered choices with a number too, but see no way other than taking user input at those choices. Is there a way to input NUMBER LETTER where the Number is not known in advance? In the example here... I've just taken more user input at the Lett

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread John W. Krahn
Harry Putnam wrote: Philip Potter writes: I was asking, not suggesting one over the other. Â And was not offering an opinion on it don't now enough. You've trimmed the context I was referring to. But you said: But there are no trailing new lines.. guaranteed by: [example snipped] which

Printing to Windows printer

2010-05-08 Thread keithvb
Trying to print from Perl to my local printer. Using Active Perl v5.10.1, Win32::Printer. I'm able to print stuff on a page but what I need to do is print the text generated by my script to a printer. Actually the text is in a frame. thanks, Keith (Sorry that this isn't a new thread but

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Uri Guttman
> "HP" == Harry Putnam writes: HP> "Uri Guttman" writes: >> yes, i disable syntax coloring since it makes it HARDER for me to >> see HP> [...] HP> I'm terrible about leaving out one of "" '' () {} [] etc.. Emacs catches HP> them and leads me to them pretty quickly with syntax

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
Philip Potter writes: >> I was asking, not suggesting one over the other.  And was not offering >> an opinion on it don't now enough. > > You've trimmed the context I was referring to. But you said: > >> But there are no trailing new lines.. guaranteed by: [example snipped] > > which looks li

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
"John W. Krahn" writes: [...] > Much simpler as: > > for ( my $i = 0; $i <= $#ar1; $i += 3 ) { > dispt( $r1name, @ar1[ $i .. $i + 2 ] ); > } Trying to make use of you suggestions. And has resulted in a much tidier script. I may have tortured you examples beyond recognition, and ha

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Philip Potter
On 8 May 2010 15:43, Harry Putnam wrote: > Philip Potter writes: > >> You are quite correct - there is no practical difference in this situation. >> >> [nitpick: actually, if $/ has been set to something other than "\n", >> $chosen may have a trailing "\n" character.] > > I was asking, not sugges

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
Philip Potter writes: > You are quite correct - there is no practical difference in this situation. > > [nitpick: actually, if $/ has been set to something other than "\n", > $chosen may have a trailing "\n" character.] I was asking, not suggesting one over the other. And was not offering an op

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Philip Potter
On 8 May 2010 14:47, Harry Putnam wrote: > Philip Potter writes: >> On 8 May 2010 13:35, Harry Putnam wrote: >>> I'm curious about one thing I see there: >>> >>>  `/\A\d+\z/ ' as opposed to `/^\d+$/' >>> >>> in this snippet: >>> >>>        if ( $chosen =~ /\A\d+\z/ && $chosen >= 1 && $chosen <=

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
Harry Putnam writes: > You mentioned once being an emacs user. > I notice when I write arrays qw like suggested... It confuses the > syntax highlight in cperl-mode and throws the highlight completely out > the window. Emacs is apparently using the quotes as part of how it > finds what to highli

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
Shawn H Corey writes: > Harry Putnam wrote: >> Steve Bertrand writes: >> >>> use vi(m). >> >> Oh my god... the `V' word. I'll have to gouge my eyes out now, just >> from looking. >> >> > Then use cream :D I just meant I'm a dedicated emacs user for coding. I do

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
Philip Potter writes: > On 8 May 2010 13:35, Harry Putnam wrote: >> I'm curious about one thing I see there: >> >>  `/\A\d+\z/ ' as opposed to `/^\d+$/' >> >> in this snippet: >> >>        if ( $chosen =~ /\A\d+\z/ && $chosen >= 1 && $chosen <= @h ) { >>            print "Taking some action on $

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Philip Potter
On 8 May 2010 13:35, Harry Putnam wrote: > I'm curious about one thing I see there: > >  `/\A\d+\z/ ' as opposed to `/^\d+$/' > > in this snippet: > >        if ( $chosen =~ /\A\d+\z/ && $chosen >= 1 && $chosen <= @h ) { >            print "Taking some action on $h[$chosen - 1]\n"; >            la

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
"John W. Krahn" writes: > Much simpler as: > > for ( my $i = 0; $i <= $#ar1; $i += 3 ) { > dispt( $r1name, @ar1[ $i .. $i + 2 ] ); > } [...] Man, that is a heck of a lot tidier. I was completely unfamiliar with that way of getting at parts of an array (though now I remember seeing some

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Philip Potter
On 8 May 2010 13:09, Harry Putnam wrote: > "Uri Guttman" writes: > >> yes, i disable syntax coloring since it makes it HARDER for me to >> see > > [...] > > I'm terrible about leaving out one of "" '' () {} [] etc.. I always enter them in pairs. eg I first type if (condition) {} then put the c

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
"Uri Guttman" writes: > yes, i disable syntax coloring since it makes it HARDER for me to > see [...] I'm terrible about leaving out one of "" '' () {} [] etc.. Emacs catches them and leads me to them pretty quickly with syntax hilight. my @ar = ( "one", "two". "three",

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Shawn H Corey
Harry Putnam wrote: Steve Bertrand writes: use vi(m). Oh my god... the `V' word. I'll have to gouge my eyes out now, just from looking. Then use cream :D -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization and

Re: how to arrange a default action in a dispatch table

2010-05-08 Thread Harry Putnam
Steve Bertrand writes: > use vi(m). Oh my god... the `V' word. I'll have to gouge my eyes out now, just from looking. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/