On 10/19/2015 07:40 PM, Kent Fredric wrote:
> On 20 October 2015 at 03:55, Lars Noodén wrote:
>> What is the main reason for the preference of File::Slurper over
>> File::Slurp these days?
>
>
> http://blogs.perl.org/users/leon_timmermans/2015/08/fileslurp-is-broken-and-wrong.html
Thanks. That
On 20 October 2015 at 03:55, Lars Noodén wrote:
> What is the main reason for the preference of File::Slurper over
> File::Slurp these days?
http://blogs.perl.org/users/leon_timmermans/2015/08/fileslurp-is-broken-and-wrong.html
--
Kent
KENTNL - https://metacpan.org/author/KENTNL
--
To unsubs
On Mon, Oct 19, 2015 at 9:46 AM, Shlomi Fish wrote:
> Hi Ian and Prashant and all,
>
> On Mon, 19 Oct 2015 09:28:15 -0500
> Ian wrote:
>
> > Take a look at File::Slurp.
> >
>
> Just for the record, using File::Slurp is no longer recommended and one
> should
> be using https://metacpan.org/pod/Pa
On Mon, Oct 19, 2015 at 07:48:06PM +0530, Prashant Thorat wrote:
> Hi All,
Hello,
> I have a file with multiple lines ,I want to assign all content to variable
> & then want to work on it.
> Like want to match pattern /window/ from it.
> how can it is possible ?
> for example -
>
> open ( F1 ,"f
On 10/19/2015 05:49 PM, Shlomi Fish wrote:
> Just for the record, using File::Slurp is no longer recommended and one should
> be using https://metacpan.org/pod/Path::Tiny or perhaps
> https://metacpan.org/pod/File::Slurper instead.
What is the main reason for the preference of File::Slurper over
F
On Mon, 19 Oct 2015 19:48:06 +0530
Prashant Thorat wrote:
> Hi All,
>
> I have a file with multiple lines ,I want to assign all content to
> variable & then want to work on it.
> Like want to match pattern /window/ from it.
> how can it is possible ?
> for example -
>
> open ( F1 ,"file.txt") |
Hi Ian and Prashant and all,
On Mon, 19 Oct 2015 09:28:15 -0500
Ian wrote:
> Take a look at File::Slurp.
>
Just for the record, using File::Slurp is no longer recommended and one should
be using https://metacpan.org/pod/Path::Tiny or perhaps
https://metacpan.org/pod/File::Slurper instead.
Fin
Take a look at File::Slurp.
Regards
On Mon, Oct 19, 2015 at 9:18 AM, Prashant Thorat
wrote:
> Hi All,
>
> I have a file with multiple lines ,I want to assign all content to
> variable & then want to work on it.
> Like want to match pattern /window/ from it.
> how can it is possible ?
> for exam
Hi All,
I have a file with multiple lines ,I want to assign all content to variable
& then want to work on it.
Like want to match pattern /window/ from it.
how can it is possible ?
for example -
open ( F1 ,"file.txt") || die "$!";
$a=;
if (/window/i){print
"it is present\n";
}
> "M" == Maggs writes:
M> sub read_file{
M> local ($filevar) = @_;
don't use local for that (or for much else). use my. local is meant now
only for special cases with dynamic scoping.
M> <$filevar>;
M> }
why do you need a whole sub to read a line? just <$filevar> does the
On Sep 23, 1:54 am, 2teezp...@gmail.com (timothy adigun) wrote:
> Hello Maggs,
>
> >> KS >Ken Slater wrote:
>
> KS>>OP was using trying to use 'open_file' to open one file handle at a
> time.
> KS>>Arguments were presumably the file handle variable, mode, and file
> name.
> KS>>Your examp
Hello Maggs,
>> KS >Ken Slater wrote:
KS>>OP was using trying to use 'open_file' to open one file handle at a
time.
KS>>Arguments were presumably the file handle variable, mode, and file
name.
KS>>Your example is very different.
I think 'KS' got the heart of what you really want, and i
On Thu, Sep 22, 2011 at 11:09 AM, John W. Krahn wrote:
> Brandon McCaig wrote:
>> open @_ or die "Can't open '$filename': $!";
>
> That won't work as the first argument to open is forced into scalar context
>
> $ perl -le'print prototype "CORE::open"'
> *;$@
>
> so if @_ contains three eleme
> -Original Message-
> From: timothy adigun [mailto:2teezp...@gmail.com]
> Sent: Thursday, September 22, 2011 2:05 PM
> To: Maggs
> Cc: beginners@perl.org
> Subject: Re: Perl file handling
>
> Hi Maggs,
>
> I don't know what you really wan
Hi Maggs,
I don't know what you really wants to achieve with your codes below:
(open...)
sub open_file {
local $/ = undef;
($filevar, $filemode, $filename) = @_;
open ($filevar, $filemode . $filename) || die ("Can't open
$filename");
}
everytime i run it i get the error: Can't use string ("FILE1
On 22 September 2011 09:54, Maggs wrote:
> am trying to open a file but the problem is on the third line
> (open...)
>
> sub open_file {
> local $/ = undef;
> ($filevar, $filemode, $filename) = @_;
> open ($filevar, $filemode . $filename) || die ("Can't open
> $filename");
> }
Are you ok instal
Brandon McCaig wrote:
On Thu, Sep 22, 2011 at 4:54 AM, Maggs wrote:
($filevar, $filemode, $filename) = @_;
open ($filevar, $filemode . $filename) || die ("Can't open
$filename");
}
everytime i run it i get the error: Can't use string ("FILE1") as a
symbol ref while "strict refs" in use.
$file
On Thu, Sep 22, 2011 at 4:54 AM, Maggs wrote:
> ($filevar, $filemode, $filename) = @_;
> open ($filevar, $filemode . $filename) || die ("Can't open
> $filename");
> }
> everytime i run it i get the error: Can't use string ("FILE1") as a
> symbol ref while "strict refs" in use.
$filevar probably c
am trying to open a file but the problem is on the third line
(open...)
sub open_file {
local $/ = undef;
($filevar, $filemode, $filename) = @_;
open ($filevar, $filemode . $filename) || die ("Can't open
$filename");
}
everytime i run it i get the error: Can't use string ("FILE1") as a
symbol ref
Guys,
Here I come with the code for the dynamic file update.
Please let me know your comments and concerns with this code.
Thanks for your support and comments.
#
#! c:/perl/bin/perl
use File::Copy;
my $file = shift;
my $old = $file;
my $new = "$file.tmp.$$";
my
On Fri, Feb 12, 2010 at 3:32 AM, elavazhagan perl <
elavazhagan.p...@gmail.com> wrote:
> *ORIGINAL CONTENT:*
>
>
>
>
>
>
>
>
>
>
>
>
>
> *DESIRED OUTPUT:*
>
>
>
>
>
>
>
>
elavazhagan perl wrote:
Yes, you are absolutely right..
We need to increment the line by one and field ID by 20.
Whatever my be the fied id..
Thanks,
OK, I give up. Does anyone else want to try eliciting a cogent and
informative response?
John
--
The programmer is fighting against the two
Yes, you are absolutely right..
We need to increment the line by one and field ID by 20.
Whatever my be the fied id..
Thanks,
On 2/12/10, John W. Krahn wrote:
>
> elavazhagan perl wrote:
>
>> Hope,this time I will make you clear.
>>
>> Our script converts the original content to current output
elavazhagan perl wrote:
Hope,this time I will make you clear.
Our script converts the original content to current output ,what we need is
the desired output.
So I take it by "line" you actually mean "Field record"?
*ORIGINAL CONTENT:*
Hi,
Please find the correction in my words.
The script should read the original content and update and append the data
to a new file upto the desired output.
Thanks.
-- Forwarded message --
From: elavazhagan perl
Date: Feb 12, 2010 3:02 PM
Subject: Re: file handling
To: "J
Hope,this time I will make you clear.
Our script converts the original content to current output ,what we need is
the desired output.
*ORIGINAL CONTENT:*
*CURRENT OUTPUT:*
elavazhagan perl wrote:
On 2/11/10, John W. Krahn wrote:
elavazhagan perl wrote:
I have a program which reads the input file,updates once and outputs in
a new file.
Ex.The first line L1 will be updated to L2.
I need to put this into a loop so that the scripts will be invoked 1000
times and t
hould indent your code consistently to aide in
readability. ]
#! c:/perl/bin/perl
use strict;
my $file = shift;
my $old = $file;
my $new = "$file.tmp.$$";
my $bak = "$file.bak";
#File Handling
open(OLD, "< $old") or die "can't open $old: $!&
Hi,
I have a program which reads the input file,updates once and outputs in a
new file.
Ex.The first line L1 will be updated to L2.
I need to put this into a loop so that the scripts will be invoked 1000
times and the
output contains the appended data(L1 TO L1000).
Please can you suggest few meth
At 11:40 AM +0530 11/6/09, Parag Kalra wrote:
Hey Folks,
I Frequently use perl to process 2 files line by line.
Most of the times I compare two files line by line and check if one line is
same to corresponding line of other file, or if one line is substring of
other line etc and many more opera
Parag Kalra wrote:
Hey Folks,
Hello,
I Frequently use perl to process 2 files line by line.
Most of the times I compare two files line by line and check if one line is
same to corresponding line of other file, or if one line is substring of
other line etc and many more operations.
The techn
Hey Folks,
I Frequently use perl to process 2 files line by line.
Most of the times I compare two files line by line and check if one line is
same to corresponding line of other file, or if one line is substring of
other line etc and many more operations.
The technique which I generally use is t
On Mar 28, 1:35 am, [EMAIL PROTECTED] (Ay) wrote:
> Hi,
>
> Current task requires me to combine a few files into a single file
> ( abc. txt ) where in each file has to be in a single page. I was able
> to create a combined file, but not able to ensure that each file
> resides in a page. Attempted a
Text files don't /have/ "pages". The number of lines per page depends
on the printer driver -> the font size, margin size, etc.
If you know the number of lines the print driver does per page, you
can fill to that point with newlines based on the number of lines
already outputted.
Or you might be in
Hi,
Current task requires me to combine a few files into a single file
( abc. txt ) where in each file has to be in a single page. I was able
to create a combined file, but not able to ensure that each file
resides in a page. Attempted a few things like 'format_lines_left'
i.e $-. in vain... One
My outfile should look like this:
STACK_CC_SS_COMMON_TYPE_REFERENCE_PROTOCOL_DIS_T => "UINT8",
STACK_CC_SS_COMMON_TYPE_REFERENCE_TRANSACTION_ID_T => "UINT8",
STACK_CC_SS_COMMON_TYPE_REFERENCE_TRANSACTION_ID_T => "UINT8",
STACK_CC_SS_COMMON_TYPE_CHANNEL_TYPE_T => "UINT8",
STACK_CC_SS_C
Hope this helps you.
use strict;
use warnings;
open my $fh, '<', "infile.txt" or die $!;
open my $ofh, '>', "outfile.txt" or die $!;
local $/ = "};";
my %printed;
my @a = <$fh>;
my @b = ();
foreach(@a){
if ($_ =~ m/(.*?)\_T\n/){
my $tomatch = $1;
my $cnt = grep /$toma
Actually my work is from the text file, i need to consider each entry in
every structure, and find its data type, to which its typedefed to and then
assign the values according to the value of the datatype. For eg:
A sample of the text file is shown below:
STACK_CC_SS_COMMON_TYPE_REFERENCE_ID_T
{
On 6/21/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
I am unable to get the desired result. Its printing all the instances of the
block.
Please post the smallest self-contained example program which other
people can use to see what you're doing, with what data. Ideally,
narrow things down
On 6/21/07, Paul Lalli <[EMAIL PROTECTED]> wrote:
On Jun 21, 9:31 am, [EMAIL PROTECTED] (Dharshana Eswaran) wrote:
> Hi All,
>
> I am reading a certain data from one file and writing to another file.
In
> the original file, there are few lines, which occur more than once in
> different lines. Wh
On Jun 21, 9:31 am, [EMAIL PROTECTED] (Dharshana Eswaran) wrote:
> Hi All,
>
> I am reading a certain data from one file and writing to another file. In
> the original file, there are few lines, which occur more than once in
> different lines. When i am writing it to the second file, i don't want i
Hi All,
I am reading a certain data from one file and writing to another file. In
the original file, there are few lines, which occur more than once in
different lines. When i am writing it to the second file, i don't want it to
be written more than once. I mean, it should not be repetitive. The
Thank you Tom!
We realy have lots of ways to do everything. In this case, is easier to use
$^I functionality, and I did. Although, it is very nice to see this code
bellow.
Cheers!
""Tom Phoenix"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 5/15/07, Bruno Schroeder <[EMAIL
On 5/15/07, Bruno Schroeder <[EMAIL PROTECTED]> wrote:
I tryed to use seek but it did not work. Can you help me on that, please? I
am using Windows XP. The following example writes at the end of the file.
use strict;
my $file = "teste_rw.txt";
open (FILE, "+<", $file) or die "Can not open $file
Hello Tom!
Hello All!
You helped a lot Tom. Still... I have some trouble.
For sure $^I is easier to use. Although in my case i would need to rewrite a
lot of code. I will do it, but it will take a while to test it. I found good
information on $^I at
http://perldoc.perl.org/perlfaq5.html#How-ca
On 5/15/07, Ken Foskey <[EMAIL PROTECTED]> wrote:
> It looks as if you're trying to edit a text file "in place". Although
> that's possible for some simple cases, it's generally easier to use
> Perl's $^I functionality.
>
What is $^I?
It is a special scalar variable that turns on/off in-place
> It looks as if you're trying to edit a text file "in place". Although
> that's possible for some simple cases, it's generally easier to use
> Perl's $^I functionality.
>
What is $^I?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn
On 5/14/07, Bruno Schroeder <[EMAIL PROTECTED]> wrote:
I am trying to read and write in a file, I am using something like:
open (FILE, "+
A little better is to include $! in the message, maybe like this:
open FILE, "+
for my $line () {
print $line;
if($line eq "X\n")
{
print F
Hello All.
I am trying to read and write in a file, I am using something like:
open (FILE, "+) {
print $line;
if($line eq "X\n")
{
print FILE "b\n"
} else
{
print FILE "c\n"
}
}
print FILE "Y\n";
close FILE;
In the attached file, I whant to write inside the $modify_clas
On Wed, 2006-07-26 at 23:57 +0530, I BioKid wrote:
> One simple question -
> I need to accept a file from the user and to store it as temp1.
> then I need to give this file as an input of another program :
> I wrote a script like this, but it is not working : Help ?
>
> #!/usr/bin/perl -w
> use CG
I BioKid wrote:
: I am able to do the second part, but am not able to get
: the users file to a variable or array ?
Read the "Files and I/O" section of the "perlintro"
file in the perl documentation.
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer
Dear Prabu and all,
My purpose is simple,
I have a web-form, that will accept a file,
I need to use this file as an input of a program in my server,
then I need to print the out put on the web page.
I am able to do the second part, but am not able to get the users file to a
variable or array ?
I
I BioKid wrote:
One simple question -
I need to accept a file from the user and to store it as temp1.
then I need to give this file as an input of another program :
I wrote a script like this, but it is not working : Help ?
#!/usr/bin/perl -w
use CGI;
my $q = new CGI;
my $file = $q->param('file'
One simple question -
I need to accept a file from the user and to store it as temp1.
then I need to give this file as an input of another program :
I wrote a script like this, but it is not working : Help ?
#!/usr/bin/perl -w
use CGI;
my $q = new CGI;
my $file = $q->param('file');
print $q->head
Hi Prabu,
> I have wrote a script to search for a pattern and replace
> it in all files of a directory,that i specified at
> commandline.I want another one thing is to be done in the
> script.That's,it should search only for the type of files I
> specified at commandline.That is,it should
Hi,
I have wrote a script to search for a pattern and replace it in all files of a
directory,that i specified at commandline.I want another one thing is to be done in
the script.That's,it should search only for the type of files I specified at
commandline.That is,it should get the extensi
ter [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 13, 2003 10:56 AM
> To: 'Pankaj Kapare'; [EMAIL PROTECTED]
> Subject: RE: File handling
>
>
> Pankaj Kapare wrote:
> > Hi
> > I want to to file handling in perl.In that I have one file which
> &
Paul Kraus wrote:
> This doesn't work with activestate on windows.
>
> perldoc -q 'change one line'
>
> Output
> No documentation for perl FAQ keyword `'change' found.
Use double quotes for brain-dead windoze:
perldoc -q "change one line"
(I just noticed this FAQ answer has changed signifi
nkaj Kapare'; [EMAIL PROTECTED]
Subject: RE: File handling
Pankaj Kapare wrote:
> Hi
> I want to to file handling in perl.In that I have one file which
> contains some lines.Now I want to modify some of lines like.. My file
> conatins line one line two
> line three
> pas
}
-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 10:56 AM
To: 'Pankaj Kapare'; [EMAIL PROTECTED]
Subject: RE: File handling
Pankaj Kapare wrote:
> Hi
> I want to to file handling in perl.In that I have one fil
Pankaj Kapare wrote:
> Hi
> I want to to file handling in perl.In that I have one file
> which contains some lines.Now I want to modify some of lines like..
> My file conatins line one
> line two
> line three
> password="password";
> Login Id ="xyz"
Hi
I want to to file handling in perl.In that I have one file which contains some
lines.Now I want to modify some of lines like..
My file conatins
line one
line two
line three
password="password";
Login Id ="xyz"
line 6
and so on
if i want to write new passord and login
John,
Thank you for your help.
Colin
-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 15 January 2003 11:00 PM
To: [EMAIL PROTECTED]
Subject: Re: File Handling
Colin Johnstone wrote:
>
> Gidday all,
Hello,
> Im having trouble reading and w
Colin Johnstone wrote:
>
> Gidday all,
Hello,
> Im having trouble reading and writing to this file, It's probably just
> something silly.
> Heres my code. I have set the permissions on the file to 775.
>
>
> my ($filename);
>
> $filename =
> "/home/bdweb8083m/johnstonefamily.com/cgi-bin/hp_da
Hi Colin
It looks like your file contains two blank lines to start with. The data
from your hash should be appended to it after the run. Try dumping your
array with:
print "<<$_>>\n" foreach @participants;
then you can see where each record starts and ends.
HTH,
Rob
"Colin Johnstone" <[E
Try using double quotes around the $filename part when you open it to write.
Dan
-Original Message-
From: Colin Johnstone [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 14, 2003 8:32 AM
To: [EMAIL PROTECTED]
Subject: File Handling
Gidday all,
Im having trouble reading and writing
Gidday all,
Im having trouble reading and writing to this file, It's probably just
something silly.
Heres my code. I have set the permissions on the file to 775.
my ($filename);
$filename =
"/home/bdweb8083m/johnstonefamily.com/cgi-bin/hp_data/participants.txt";
if( -e $filename ){
print "Ye
Steve Doerr wrote:
>
> Greetings! Could someone here offer a tip about declaring a file
> variable that is itself part variable?
>
> I can't seem to find an example of this online and I hope someone here
> could help.
>
> I'd like to put a path variable in the declaration, but can't seem to
>
Greetings! Could someone here offer a tip about declaring a file
variable that is itself part variable?
I can't seem to find an example of this online and I hope someone here
could help.
I'd like to put a path variable in the declaration, but can't seem to
get it to work.
What would the proper
I don't know if I sent my first email correctly. Sorry for the repeat if I
did, I'm new :)
Hello,
The code below takes all files in my current directory that have filenames
ending with ".txt". Using this stuff I can loop through those files and do
what I need to do.
My problem is, I want to
On Thu, Aug 02, 2001 at 03:00:24PM -0400, Bob Showalter wrote:
> I played around with this a bit and found that:
>
>perl -e 'print scalar(glob("*")) for (1..2)'
>
> prints two different files, while
>
>perl -e 'print scalar(glob("*")), scalar(glob("*"))'
>
> prints the same file twice.
> -Original Message-
> From: Michael Fowler [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 02, 2001 2:48 PM
> To: Bob Showalter
> Cc: [EMAIL PROTECTED]
> Subject: Re: File Handling question - easy
>
>
> On Thu, Aug 02, 2001 at 02:31:28PM -0400, Bob Sh
On Thu, Aug 02, 2001 at 02:31:28PM -0400, Bob Showalter wrote:
> P.S. I'm surprised this works with while(). I didn't realize fileglobs
> were magical inside while(), but it appears they are... Is this documented?
Yes, perldoc perlop, in the I/O Operators section (5.6.1 version):
A (file)g
Bob,
I got it from "Perl Black Book" by S. Holzner, section on globs. Very very
good book to learn Perl from, extremely easy to read, excellent for
beginners and I'm not going to know this for a long while but I think it is
an excellent book for intermediate Perl dudes too. End of section rea
Jon,
Read all the files in the directory then go through them based on the
file ext
and do what you want.
opendir( PROGRAM, "./" );
foreach $program ( readdir( PROGRAM )) {
if( $program =~ ".txt" ) {
### do stuff, given a filename
}elsif( $program =~ ".this" ) {
### do stuff, given
Bob-Mike-Jerry,
Thanks guys
Jon
At 01:36 PM 8/2/01 -0500, Jerry Preston wrote:
>Jon,
>
>Read all the files in the directory then go through them based on the
>file ext
>and do what you want.
>
> opendir( PROGRAM, "./" );
> foreach $program ( readdir( PROGRAM )) {
> if( $program =~ ".txt"
> -Original Message-
> From: Jon [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 02, 2001 2:03 PM
> To: [EMAIL PROTECTED]
> Subject: File Handling question - easy
>
>
> I don't know if I sent my first email correctly. Sorry for
> the repeat if
On Thu, Aug 02, 2001 at 11:03:23AM -0700, Jon wrote:
> My problem is, I want to do this for a bunch of different patterns (ex.
> ".txt", ".this", ".that").
You could say <*.txt *.this *.that>, or you can use opendir, readdir, and a
regex (perhaps grep).
> How can I make what is inside the angl
78 matches
Mail list logo