in reply to user input file
G'day torres09,
Update: Having posted this, I now see (from Re^4: user input file) that you only want users to enter the filename, not the data. Your OP asked about "file", not "filename" and "my @lines=<FILE>;" (in your posted code) suggested you were interested in data — you can ignore the remainder of my response (which is now hidden within <spoiler> tags).
To be honest, I would get your users to create CSV files with whatever spreadsheet software you normally use.
If you want them to create CSV files on-the-fly from within your code, I'd take a look at Text::CSV.
If you really have a requirement to roll-your-own code for this, which I think would be highly unlikely, the guts of it might look something like the following.
$ ls -l pm_user_input_file ls: pm_user_input_file: No such file or directory
$ perl -Mstrict -Mwarnings -E ' use autodie qw{:all}; open my $fh, q{>}, q{pm_user_input_file}; while (<>) { print {$fh} $_; } ' 1,2,3 q,w,e a,s,d z,x,c
$ ls -l pm_user_input_file -rw-r--r-- 1 ken staff 24 19 Jun 23:49 pm_user_input_file
$ cat pm_user_input_file 1,2,3 q,w,e a,s,d z,x,c
Again, just so you are clear on this, unless you are doing this purely out of personal interest or for some similar reason, this is a really poor option which I'd advise you avoid!
-- Ken
|
|---|