Extracting variables from a string

2006-04-18 Thread Ed
How would I get the various elements out of a string of known format. A previous post about a similar topic approaches a solution but I need help with the regular expression to pass to the m function. Here's an example of a string: net user cknotts somepassword /add /active:yes /expires:never

Re: Extracting variables from a string

2006-04-18 Thread Joshua Colson
On Tue, 2006-04-18 at 11:20 -0600, Ed wrote: How would I get the various elements out of a string of known format. A previous post about a similar topic approaches a solution but I need help with the regular expression to pass to the m function. Here's an example of a string: net user

Re: Extracting variables from a string

2006-04-18 Thread John W. Krahn
Ed wrote: How would I get the various elements out of a string of known format. A previous post about a similar topic approaches a solution but I need help with the regular expression to pass to the m function. Here's an example of a string: net user cknotts somepassword /add /active:yes

Re: Extracting variables from a string

2006-04-18 Thread John W. Krahn
John W. Krahn wrote: Ed wrote: How would I get the various elements out of a string of known format. A previous post about a similar topic approaches a solution but I need help with the regular expression to pass to the m function. Here's an example of a string: net user cknotts somepassword

Interpolating variables in a string from a file

2005-12-01 Thread Andrew Brosnan
How can I make this do what I mean? #!/usr/bin/perl use warnings; use strict; my $var = 'world'; undef $/; my $data = DATA; print $data; #oops __DATA__ hello $var -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

RE: Interpolating variables in a string from a file

2005-12-01 Thread Timothy Johnson
perldoc -f eval -Original Message- From: Andrew Brosnan [mailto:[EMAIL PROTECTED] Sent: Thursday, December 01, 2005 5:06 PM To: beginners@perl.org Subject: Interpolating variables in a string from a file How can I make this do what I mean? #!/usr/bin/perl use warnings; use strict

RE: Interpolating variables in a string from a file

2005-12-01 Thread Andrew Brosnan
01, 2005 5:06 PM To: beginners@perl.org Subject: Interpolating variables in a string from a file How can I make this do what I mean? #!/usr/bin/perl use warnings; use strict; my $var = 'world'; undef $/; my $data = DATA; print $data; #oops __DATA__ hello $var

Re: Interpolating variables in a string from a file

2005-12-01 Thread Jeff 'japhy' Pinyan
On Dec 1, Andrew Brosnan said: my $var = 'world'; my $data = DATA; __DATA__ hello $var Read 'perldoc -q expand'. -- Jeff japhy Pinyan% How can we ever be the sold short or RPI Acacia Brother #734% the cheated, we who for every service http://www.perlmonks.org/ % have long

RE: Interpolating variables in a string from a file

2005-12-01 Thread Timothy Johnson
variables in a string from a file On 12/1/05 at 5:10 PM, [EMAIL PROTECTED] (Timothy Johnson) wrote: perldoc -f eval Yes, I've read that. I can't seem to make it work though. Perhaps you could show me since you know how :-) -Original Message- From: Andrew Brosnan [mailto:[EMAIL PROTECTED

RE: Interpolating variables in a string from a file

2005-12-01 Thread Andrew Brosnan
### -Original Message- From: Andrew Brosnan [mailto:[EMAIL PROTECTED] Sent: Thursday, December 01, 2005 5:20 PM To: Timothy Johnson Cc: beginners@perl.org Subject: RE: Interpolating variables in a string from a file On 12/1/05 at 5:10 PM, [EMAIL PROTECTED] (Timothy Johnson) wrote

Re: Interpolating variables in a string from a file

2005-12-01 Thread Andrew Brosnan
On 12/1/05 at 9:07 PM, [EMAIL PROTECTED] (Jeff 'japhy' Pinyan) wrote: On Dec 1, Andrew Brosnan said: my $var = 'world'; my $data = DATA; __DATA__ hello $var Read 'perldoc -q expand'. $data =~ s/(\$\w+)/$1/eeg; Interesting, matching and substituting interpolates, so by

Re: $variables in a string

2005-05-16 Thread Jeff 'japhy' Pinyan
On May 15, Paul D. Kraus said: Hello, my $image = Image::Magick-new; # trouble open(IMAGE, 'images/products/unprocessed/$sku_unprocessed.jpg'); open(IMAGE, images/products/unprocessed/$sku_unprocessed.jpg); That needs to be open(IMAGE, images/products/unprocessed/${sku}_unprocessed.jpg); That's

$variables in a string

2005-05-15 Thread Grant
Hello, my Perl skills are very weak. I have a chunk of code that works great as long as I hard-code everything. When I try to use $variables in the strings, things don't work. Please let me know if you know how to use $variables in these contexts: my $image = Image::Magick-new; # trouble

Re: $variables in a string

2005-05-15 Thread Paul D. Kraus
Hello, my $image = Image::Magick-new; # trouble open(IMAGE, 'images/products/unprocessed/$sku_unprocessed.jpg'); open(IMAGE, images/products/unprocessed/$sku_unprocessed.jpg); You need to use double quotes if you want it to use the variable. or if you reall wanted single quotes you could have

Re: $variables in a string

2005-05-15 Thread Grant
Hello, my $image = Image::Magick-new; # trouble open(IMAGE, 'images/products/unprocessed/$sku_unprocessed.jpg'); open(IMAGE, images/products/unprocessed/$sku_unprocessed.jpg); You need to use double quotes if you want it to use the variable. or if you reall wanted single quotes you

Creating variables of a string

2002-04-02 Thread Michael Stearman
Hi, I have a string that contains a word and 2 numbers. For example, Michael 57 3 I want to assign each of these three to different variables. My only problem is that the word and the numbers are always different and the space between the words and numbers is always different as

Re: Creating variables of a string

2002-04-02 Thread Tanton Gibbs
, April 02, 2002 12:02 PM Subject: Creating variables of a string Hi, I have a string that contains a word and 2 numbers. For example, Michael 57 3 I want to assign each of these three to different variables. My only problem is that the word and the numbers are always different

Re: Creating variables of a string

2002-04-02 Thread Tanton Gibbs
Actually, since the others are numbers you could replace the last two \S+ with \d+ - Original Message - From: Tanton Gibbs [EMAIL PROTECTED] To: Michael Stearman [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, April 02, 2002 12:06 PM Subject: Re: Creating variables of a string my

Re: Creating variables of a string

2002-04-02 Thread Jeff 'japhy' Pinyan
On Apr 2, Michael Stearman said: Michael 57 3 I want to assign each of these three to different variables. My only problem is that the word and the numbers are always different and the space between the words and numbers is always different as well. Does anyone know how I would

Re: Creating variables of a string

2002-04-02 Thread John W. Krahn
[Please don't top-post] Michael Stearman wrote: Right now it is not working and I was wondering if I sent the code maybe someone with more experience with this will see the problem. I am very new to this. The line I am trying to create the variables from is C6xxxSimulator(TI) 61

RE: Creating variables of a string

2002-04-02 Thread David Gray
Michael Stearman wrote: Right now it is not working and I was wondering if I sent the code maybe someone with more experience with this will see the problem. I am very new to this. The line I am trying to create the variables from is C6xxxSimulator(TI) 61 1

RE: Creating variables of a string

2002-04-02 Thread Jeff 'japhy' Pinyan
On Apr 2, David Gray said: Michael Stearman wrote: my ($target, $count, $num) = split ' ', $word; I think that needs to be: my ($target,$count,$num) = split /\s+/, $word; to handle multiple spaces between the values. No. As the split() documentation states, split(' ') is magical. --

RE: Creating variables of a string

2002-04-02 Thread Timothy Johnson
So if you wanted to split on just one space, would split / /,$variable be treated as magical as well? -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 02, 2002 11:50 AM To: David Gray Cc: [EMAIL PROTECTED] Subject: RE: Creating variables

RE: Creating variables of a string

2002-04-02 Thread Jeff 'japhy' Pinyan
On Apr 2, Timothy Johnson said: So if you wanted to split on just one space, would split / /,$variable be treated as magical as well? No. As the split() documentation ALSO states, only split(' ') and split( ) are treated magically. split(/ /) splits on a single space; the others split as if

Re: Creating variables of a string

2002-04-02 Thread John W. Krahn
Nikola Janceski wrote: That always confused me, by default split splits by /\s+/ so why confuse us more by making and ' ' magical. No, the default is NOT /\s+/, the following are all equivalent: @words = split; @words = split ' '; @words = split ' ', $_; John -- use Perl; program

RE: Creating variables of a string

2002-04-02 Thread Nikola Janceski
a split(' ', $_) internally. -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 02, 2002 3:54 PM To: [EMAIL PROTECTED] Subject: Re: Creating variables of a string Nikola Janceski wrote: That always confused me, by default split splits by /\s