Skip to content

Instantly share code, notes, and snippets.

@jonasbn
Created September 4, 2024 19:42
Show Gist options
  • Save jonasbn/00c42291e2ea19f5742d7fdbe90e1904 to your computer and use it in GitHub Desktop.
Save jonasbn/00c42291e2ea19f5742d7fdbe90e1904 to your computer and use it in GitHub Desktop.
Simple helper script in my path to add files to .gitignore, creating it if it does not already exist
#!/usr/bin/env perl
use warnings;
use strict;
my $file = '.gitignore';
if (-e $file and -f _ and -w _) {
open my $FOUT, '>>', $file or die "Unable to open file: $file - $!";
print $FOUT "$ARGV[0]\n";
close($FOUT);
} else {
open my $FOUT, '>>', $file or die "Unable to open file: $file - $!";
print $FOUT "$ARGV[0]\n";
close($FOUT);
}
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment