I would have done it like this.
$var = 34.5678;
$var=~/((\d+).(\d{0,2}))/;
$var = $1;
$var=~s/\./,/sg;
printf ( The formated value is : $var);
---OUTPUT
The formated value is : 34.56
Well there may be better and more straigth forward ways, I was just trying
to get used to Patterns and
Yeup ! The the TYPE declaration is very important !.
We tend to ignore such things when we use MS platforms...:-(
Thanks for correcting me Michael .
with Regards
Rajeev Rumale
- Original Message -
From: Michael D. Risser [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, October
Thanks for your replies.
It does insert another character, but keeps the return too.
I have tried:
$text =~ s/\n/br/g;
and
$text =~ s/\r/br/g;
but it does the same thing, i.e. I get:
Line1br
Line2
What I need is:
Line1brLine2
Do you know how to get rid of the returns altogether?
Hi all,
I'm trying to get a string (held in a variable) to have all it's characters
spaced apart by a ' ' space.
ie. $input's content changes from '1234' to '1 2 3 4'
Is there some way to do this?
cheers,
-Shannon
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands,
I found a solution not long after using a loop of sorts. (and killed two
birds with one stone, as my next step was to put each item (space delimited)
into an array).
I made a loop saying, 'as long as $input still has characters in it, put
each one (one at a time) into the @front_chars array, then
Thats Great !
Yes this is infact helped me.
I was trying it in a much complicated way.
regards
Rajeev Rumale
- Original Message -
From: Shannon Murdoch [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 02, 2001 6:50 PM
Subject: Re: $variable manipulation question
I
Note: this code only replaces carriage returns, not line feeds.
Remember an ancient typewriter. The carriage return returns the carriage to
the beginning of the line, but does not advance to the next line. This
enables the typist to overstrike, underline, or embolden characters. The
linefeed
$x = join ' ', split //, $x;
That looks like a very compact way of doing it, Brian- is it possible to get
a bit of a rundown of how it works?
cheers,
-Shannon
From: [EMAIL PROTECTED] (_brian_d_foy)
Newsgroups: perl.beginners.cgi
Date: Tue, 02 Oct 2001 06:56:59 -0400
To: [EMAIL PROTECTED]
On Tue, 2 Oct 2001, Guy Tubbs wrote:
but it does the same thing, i.e. I get:
Line1br
Line2
What I need is:
Line1brLine2
Do you know how to get rid of the returns altogether?
Odd. Here's the code snippet I ran right at the command-line:
$ perl
$text = line1\nline2\n;
$text =~
Shannon Murdoch wrote:
$x = join ' ', split //, $x;
That looks like a very compact way of doing it, Brian- is it possible to get
a bit of a rundown of how it works?
perldoc -f join
perldoc -f split
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL
-Original Message-
From: Wagner Garcia Campagner [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 01, 2001 5:13 AM
To: [EMAIL PROTECTED]
Subject: formating variables again...
Hi,
I have a variable $var = 34.5678
If I
printf (%.2f, $var);
Then $var = 34.56
Is there
If you are sure its a string, maybe you can use 'unpack', and then 'join'.
- Roger -
- Original Message -
From: Shannon Murdoch [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, October 02, 2001 11:20 AM
Subject: $variable manipulation question
Hi all,
I'm trying to get a
-Original Message-
From: Shannon Murdoch [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 02, 2001 6:51 AM
To: [EMAIL PROTECTED]
Subject: Re: $variable manipulation question
I found a solution not long after using a loop of sorts. (and
killed two
birds with one stone, as my
hi
i have a problem in which i have a lists of Domain names ..k, and i need to
get there matching email address of an external site but i cant arite a shell
script so i was wondering if anyone has any ideas or code that can help me
with what im doing?
also the script needs to run so that
How did that help you? Now you have an array of individual
characters, gotten the hard way.
Originally I was aiming to space each character apart so I could use a space
' ' as the delimiting character when I brought them into an array (to be
analyzed character by character by other following
On Tue, 2 Oct 2001, Gareth Londt wrote:
i have a problem in which i have a lists of Domain names ..k, and i need to
get there matching email address of an external site but i cant arite a shell
script so i was wondering if anyone has any ideas or code that can help me
with what im doing?
i have a problem in which i have a lists of Domain names ..k, and i need to
get there matching email address of an external site but i cant arite a shell
script so i was wondering if anyone has any ideas or code that can help me
with what im doing?
Get what matching email addresses? Are
Are there free web-hosts or free Unix shell accounts with hosting that also provide
CGI capability?
Thanks,
Nelson
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Has anyone ever gotten this error from perl? How do I resolve it?
panic: frexp at IWfacschd.cgi.exp line 366.
line 366: $fte = sprintf(%2.4f, $fte);
$fte is a returned number from a database.
frexp is apparently a library that allows the printf('%f') to work but has
failed.
On Tue, 2 Oct 2001, Robert Becker wrote:
Has anyone ever gotten this error from perl? How do I resolve it?
panic: frexp at IWfacschd.cgi.exp line 366.
line 366: $fte = sprintf(%2.4f, $fte);
$fte is a returned number from a database.
frexp is apparently a library that allows
Hey everybody,
I've got a PostFix mail server set up that's working fine. However, in some
cases we want to generate output files and attach them to an e-mail instead
of just dumping the HTML data in text form into an e-mail. Anybody know how
I can do that?
Thanks in advance.
-John M. Stokes
-Original Message-
From: Stokes, John [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 02, 2001 2:13 PM
To: '[EMAIL PROTECTED]'
Subject: e-mailing an attachment with Perl
Hey everybody,
I've got a PostFix mail server set up that's working fine.
However, in some
cases we
In article [EMAIL PROTECTED],
[EMAIL PROTECTED] (Shannon Murdoch) wrote:
$x = join ' ', split //, $x;
That looks like a very compact way of doing it, Brian- is it possible to get
a bit of a rundown of how it works?
start from the right and work your way left. ;)
--
brian d foy [EMAIL
In article [EMAIL PROTECTED],
[EMAIL PROTECTED] (Shannon Murdoch) wrote:
Brian's
*ahem* - brian.
print join ' ', split //, $input;
doesn't actually change $input's content however.
if that is what you wanted then you just need to fill in the
details:
$input = join ' ',
Hi all,
I'm trying to get this string (example):
$all_codes = '4c1 4- 4c2 4-8b1 8g1';
in to an array (@codes), using it's whitespace as the delimiter.
ie. @codes = split(/ /,$all_codes);
but I keep getting extra whitespace elements picked up into the array...:
'4c1,4-,4c2,4-, ,8b1,8g1'
Hi Shannon,
Very close. You are allowed to use a pattern in a split.
my @codes = split(/\s+/,$all_codes);
Should give you what you want. This will split the string on 1 or more spaces.
Look at 'perldoc -f split' for more information.
Cheers,
Kevin
On Wed, Oct 03, 2001 at 09:47:11AM +1000,
I see now!
Worked like a charm. While we're on the topic of deletion/exclusion of
string elements when brought in to an array, how do I kill '\n' line breaks
from the string (or even just exclude them at array input time)?
ie. 'hello how are you /n I am fine'
becomes
Try this if you're using linux/unix system:
$variable =~ s/\n\r/br/g;
Alex
Guy Tubbs wrote:
Hi,
Can anyone give me the code that will replace all the carriage returns in a
variable with another character.
I am getting input from a web page and need to replace the returns with the
br tag.
In article [EMAIL PROTECTED],
[EMAIL PROTECTED] (Shannon Murdoch) wrote:
From: [EMAIL PROTECTED] (Kevin Meltzer)
my @codes = split(/\s+/,$all_codes);
Worked like a charm. While we're on the topic of deletion/exclusion of
string elements when brought in to an array, how do I kill '\n'
29 matches
Mail list logo