Re: Problem with adding a connection with Win32::NetResource

2008-01-01 Thread Rob Dixon
Nash wrote: Hi all, I'm new to Perl and I'm trying to use it to connect to a shared disc through a home network. This is what I've tried: #!/usr/bin/perl -w use

Looping through lines stored in a scalar

2008-01-01 Thread Jean-Rene David
Hi, I wonder what idioms are available to loop through the lines stored in a scalar variable. I guess I'm looking for something analogous to these idioms for files and arrays respectively: while(FH) { # do stuff } foreach (@array) { # do stuff } When I had to do this I split the scalar in an

absolute beginner: perlrefs to stack values

2008-01-01 Thread gst
hi, iirc, in C if I store somwhere a pointer to a stack value (e.g.: call a function with an auto variable, return its pointer) i know i'm going to mess things, since that piece of data will be most probably overwritten by subsequent calls. if I do the same in Perl (with a hard ref), do I have

Re: Looping through lines stored in a scalar

2008-01-01 Thread Chas. Owens
On Dec 31, 2007 5:56 PM, Jean-Rene David [EMAIL PROTECTED] wrote: Hi, I wonder what idioms are available to loop through the lines stored in a scalar variable. I guess I'm looking for something analogous to these idioms for files and arrays respectively: while(FH) { # do stuff }

Re: Looping through lines stored in a scalar

2008-01-01 Thread Tom Phoenix
On Dec 31, 2007 2:56 PM, Jean-Rene David [EMAIL PROTECTED] wrote: When I had to do this I split the scalar in an array: @array = split \n, $scalar; foreach (@array) { # do stuff } What would be some other ways to do this? (This is purely curiosity.) This type of curiosity would be well

Re: Looping through lines stored in a scalar

2008-01-01 Thread yitzle
You can skip the array assignment and just do: foreach ( split \n, $scalar ) { ... } I predict a reply that uses map()... though I think that using a map isn't really another solution, but just an alternative to the for loop. map {stuff}, split \n, $scalar; But I think the answer is basically

Re: absolute beginner: perlrefs to stack values

2008-01-01 Thread Tom Phoenix
On Dec 31, 2007 2:43 PM, gst [EMAIL PROTECTED] wrote: iirc, in C if I store somwhere a pointer to a stack value (e.g.: call a function with an auto variable, return its pointer) i know i'm going to mess things, since that piece of data will be most probably overwritten by subsequent calls.

Re: absolute beginner: perlrefs to stack values

2008-01-01 Thread yitzle
IIRC, the stack pointer is part of the operating system, not the C language. When a subroutine is called, the parameters are pushed to the stack, and the return value is stored in a specific register. When a routine creates a variable, the system's memory allocator finds a new piece of unused

Re: absolute beginner: perlrefs to stack values

2008-01-01 Thread Chas. Owens
On Dec 31, 2007 5:43 PM, gst [EMAIL PROTECTED] wrote: hi, iirc, in C if I store somwhere a pointer to a stack value (e.g.: call a function with an auto variable, return its pointer) i know i'm going to mess things, since that piece of data will be most probably overwritten by subsequent

Re: absolute beginner: perlrefs to stack values

2008-01-01 Thread Chas. Owens
On Jan 1, 2008 2:12 PM, Chas. Owens [EMAIL PROTECTED] wrote: snip if I do the same in Perl (with a hard ref), do I have any guarantee that the same behavior (implicit aliasing) does - or does not (every new scalar is guaranteed to not alias the old non existant value) - apply? snip Saying

Re: absolute beginner: perlrefs to stack values

2008-01-01 Thread Peter Scott
On Mon, 31 Dec 2007 14:43:44 -0800, gst wrote: iirc, in C if I store somwhere a pointer to a stack value (e.g.: call a function with an auto variable, return its pointer) i know i'm going to mess things, since that piece of data will be most probably overwritten by subsequent calls. if I do

Re: absolute beginner: perlrefs to stack values

2008-01-01 Thread Chas. Owens
On Jan 1, 2008 2:32 PM, Chas. Owens [EMAIL PROTECTED] wrote: snip You can deal with this by using the anonymous arrayref generator: snip Oh, the proper term is anonymous array composer (at least according to the 3rd Camel). I knew anonymous arrayref generator sounded wrong. -- To unsubscribe,

Re: Looping through lines stored in a scalar

2008-01-01 Thread Rob Dixon
Jean-Rene David wrote: Hi, I wonder what idioms are available to loop through the lines stored in a scalar variable. I guess I'm looking for something analogous to these idioms for files and arrays respectively: while(FH) { # do stuff } foreach (@array) { # do stuff } When I had to do this I

Re: Looping through lines stored in a scalar

2008-01-01 Thread John W. Krahn
Jean-Rene David wrote: Hi, Hello, I wonder what idioms are available to loop through the lines stored in a scalar variable. I guess I'm looking for something analogous to these idioms for files and arrays respectively: while(FH) { # do stuff } open FH, '', \$scalar or die Cannot open

Re: absolute beginner: perlrefs to stack values

2008-01-01 Thread Jenda Krynicky
From: gst [EMAIL PROTECTED] iirc, in C if I store somwhere a pointer to a stack value (e.g.: call a function with an auto variable, return its pointer) i know i'm going to mess things, since that piece of data will be most probably overwritten by subsequent calls. if I do the same in Perl

Re: Looping through lines stored in a scalar

2008-01-01 Thread Chas. Owens
On Jan 1, 2008 12:21 PM, yitzle [EMAIL PROTECTED] wrote: You can skip the array assignment and just do: foreach ( split \n, $scalar ) { ... } I predict a reply that uses map()... though I think that using a map isn't really another solution, but just an alternative to the for loop. map

Re: absolute beginner: perlrefs to stack values

2008-01-01 Thread Paul Johnson
On Mon, Dec 31, 2007 at 02:43:44PM -0800, gst wrote: hi, iirc, in C if I store somwhere a pointer to a stack value (e.g.: call a function with an auto variable, return its pointer) i know i'm going to mess things, since that piece of data will be most probably overwritten by subsequent

Re: Looping through lines stored in a scalar

2008-01-01 Thread Paul Johnson
On Mon, Dec 31, 2007 at 05:56:35PM -0500, Jean-Rene David wrote: I wonder what idioms are available to loop through the lines stored in a scalar variable. I guess I'm looking for something analogous to these idioms for files and arrays respectively: while(FH) { # do stuff } foreach

Re: Looping through lines stored in a scalar

2008-01-01 Thread John W. Krahn
Chas. Owens wrote: If you have a recent enough version of Perl* you can say open my $fh, , \$scalar or die could not attach a file handle to \$scalar: $!; while (my $line = $fh) { chomp($line); #do stuff with $line } * 5.8 can do this, but I am not sure about 5.6.* perldoc -f