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
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
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
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
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/
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
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
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
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
###
-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
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
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
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
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
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
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
, 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
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
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
[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
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
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.
--
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
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
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
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
26 matches
Mail list logo