Dr.Ruud wrote:
Gunnar Hjalmarsson schreef:
my $content = do { local $/; <$file> };
That idiom uses an extra buffer, as big as the file.
my $content; { local $/; $content = }
Or:
read( FH, my $content, -s FH ) == -s FH or warn "Could not read the entire
file.\n";
John
Dr.Ruud wrote:
Gunnar Hjalmarsson schreef:
Dr.Ruud:
Gunnar Hjalmarsson:
my $content = do { local $/; <$file> };
That idiom uses an extra buffer, as big as the file.
my $content; { local $/; $content = }
Does it? In that case, why is it mentioned at
http://faq.perl.org/perlfa
Gunnar Hjalmarsson schreef:
> Dr.Ruud:
>> Gunnar Hjalmarsson:
>>> my $content = do { local $/; <$file> };
>>
>> That idiom uses an extra buffer, as big as the file.
>>
>>my $content; { local $/; $content = }
>
> Does it? In that case, why is it mentioned at
> http://faq.perl.org/perl
Dr.Ruud wrote:
Gunnar Hjalmarsson schreef:
my $content = do { local $/; <$file> };
That idiom uses an extra buffer, as big as the file.
my $content; { local $/; $content = }
Does it? In that case, why is it mentioned at
http://faq.perl.org/perlfaq5.html#How_can_I_read_in_an
Gunnar Hjalmarsson schreef:
> my $content = do { local $/; <$file> };
That idiom uses an extra buffer, as big as the file.
my $content; { local $/; $content = }
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mai
Jeff Pang wrote:
2007/8/24, Gunnar Hjalmarsson <[EMAIL PROTECTED]>:
Yoyoyo Yoyoyoyo wrote:
I have a file that I need to use the substitute operator on to get
rid of spaces, and apostrophes and such. The only way I can think of
doing it is this:
1. Open the file and go through it one line at
2007/8/24, Gunnar Hjalmarsson <[EMAIL PROTECTED]>:
> Yoyoyo Yoyoyoyo wrote:
> > I have a file that I need to use the substitute operator on to get
> > rid of spaces, and apostrophes and such. The only way I can think of
> > doing it is this:
> >
> > 1. Open the file and go through it one line at
Use one-liner Perl to do the replacement without calling 'open' and
'<>' and 'close' directly.
$ perl -pi.bak -e 's/abc/def/' file.txt
2007/8/24, Yoyoyo Yoyoyoyo <[EMAIL PROTECTED]>:
> Hi all,
>
> I have a file that I need to use the substitute operator on to get rid of
> spaces, and apostrophes
Yoyoyo Yoyoyoyo wrote:
I have a file that I need to use the substitute operator on to get
rid of spaces, and apostrophes and such. The only way I can think of
doing it is this:
1. Open the file and go through it one line at a time with the
diamond operator.
2. Make the substitutions on the
Hi all,
I have a file that I need to use the substitute operator on to get rid of
spaces, and apostrophes and such. The only way I can think of doing it is this:
1. Open the file and go through it one line at a time with the diamond
operator.
2. Make the substitutions on the $_ variable and
Hi Group,
Am working with Unicode (UTF8 coded) stuff and facing problem with regular
expression.
s/(\p{HinNumerals})\s+($tokenize_string)+\s+(\p{HinNumerals})/$1$2$3/g;
and, my HinNumerals is defined as,
sub HinNumerals {
return <
At 05:01 PM 1/7/2002 -0500, Jeff 'japhy' Pinyan wrote:
>Anyway, you want s/[.:-]+//g, or something to that effect. Be warned,
>though, that [.-:] is NOT what you want, since that means "characters from
>'.' to '-'", which is the following list:
> . / 0 1 2 3 4 5 6 7 8 9 :
And that was my newbi
On Jan 7, Scott said:
>At 04:12 PM 1/7/2002 -0500, Jeff 'japhy' Pinyan wrote:
>> >>So s/[.-]+//g, or perhaps tr/.-//d;
>> >I might have worded it wrong, I need to replace a period (.) and a dash
>> >(-), they may not be together ie (.-), they could be in any of the
>> >fields in the array. Some
At 04:12 PM 1/7/2002 -0500, Jeff 'japhy' Pinyan wrote:
> >>So s/[.-]+//g, or perhaps tr/.-//d;
> >I might have worded it wrong, I need to replace a period (.) and a dash
> >(-), they may not be together ie (.-), they could be in any of the
> >fields in the array. Some of the fields are numbers (5
On Jan 7, McCollum, Frank said:
>so, if a character is inside of square brackets [], then perl recognizes
>that it is part of a character class and never uses it as a quantifier or
>special character??
Very few characters need escaping a char class. ] does (unless it's the
first character of th
On Jan 7, Scott said:
>At 04:04 PM 1/7/2002 -0500, Jeff 'japhy' Pinyan wrote:
>>No, the [...] is needed. Otherwise, you're removing all occurrences of
>>the string ".-" which is not what was intended.
>>
>>So s/[.-]+//g, or perhaps tr/.-//d;
>
>I might have worded it wrong, I need to replace a p
4:04 PM
To: McCollum, Frank
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: global substitution
On Jan 7, McCollum, Frank said:
>$record =~ s/[\.\-]//g;
Neither of those two slashes are needed.
>if it is a '.' or a '-' replace it with nothing.
>Actually, I don't
At 04:04 PM 1/7/2002 -0500, Jeff 'japhy' Pinyan wrote:
>No, the [...] is needed. Otherwise, you're removing all occurrences of
>the string ".-" which is not what was intended.
>
>So s/[.-]+//g, or perhaps tr/.-//d;
I might have worded it wrong, I need to replace a period (.) and a dash
(-), the
I think:
foreach $value(@fields)
{
$value = s/\.\-//g;
}
- Original Message -
From: "Scott" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 07, 2002 4:02 PM
Subject: global substitution
> Hi all:
>
> I have two files that I am r
On Jan 7, McCollum, Frank said:
>$record =~ s/[\.\-]//g;
Neither of those two slashes are needed.
>if it is a '.' or a '-' replace it with nothing.
>Actually, I don't even think the [] is necessary, so it could just be:
>$record =~ s/\.\-//g;
No, the [...] is needed. Otherwise, you're removin
2 PM
To: [EMAIL PROTECTED]
Subject: global substitution
Hi all:
I have two files that I am reading into an array, I want to substitute a
period and a dash,
actually I want to remove them completely. Here is my code:
while (my $record = ){
my $policies = ;
my @fields = split( /\t/, $record );
Hi all:
I have two files that I am reading into an array, I want to substitute a
period and a dash,
actually I want to remove them completely. Here is my code:
while (my $record = ){
my $policies = ;
my @fields = split( /\t/, $record );
my @policies = split( /\t/, $policies );
When I need a r
22 matches
Mail list logo